create-rule
Create Cursor rules for persistent AI guidance. Use when the user wants to create a rule, add coding standards, set up project…
Build AI applications with OpenAI Agents SDK - text agents, voice agents, multi-agent handoffs, tools with Zod schemas, guardrails, and streaming. Prevents 11 documented errors. Use when: building agents with tools, voice agents with WebRTC, multi-agent workflows, or
Claude Code
$ npx -y skills add coco-research/coco --skill openai-agents --agent claude-code
Codex
$ npx skills add coco-research/coco --skill openai-agents -a codex -y
Cursor
$ npx skills add coco-research/coco --skill openai-agents -a cursor -y
Gemini CLI
$ npx skills add coco-research/coco --skill openai-agents -a gemini-cli -y
GitHub Copilot
$ npx skills add coco-research/coco --skill openai-agents -a github-copilot -y
OpenCode
$ npx skills add coco-research/coco --skill openai-agents -a opencode -y
Windsurf
$ npx skills add coco-research/coco --skill openai-agents -a windsurf -y
name: openai-agents description: | Build AI applications with OpenAI Agents SDK - text agents, voice agents, multi-agent handoffs, tools with Zod schemas, guardrails, and streaming. Prevents 11 documented errors. Use when: building agents with tools, voice agents with WebRTC, multi-agent workflows, or troubleshooting MaxTurnsExceededError, tool call failures, reasoning defaults, JSON output leaks. user-invocable: true domain: engineering
Build AI applications with text agents, voice agents (realtime), multi-agent workflows, tools, guardrails, and human-in-the-loop patterns.
---
npm install @openai/agents zod@4 # v0.4.0+ requires Zod 4 (breaking change) npm install @openai/agents-realtime # Voice agents export OPENAI_API_KEY="your-key"
**Breaking Change (v0.4.0)**: Zod 3 no longer supported. Upgrade to `zod@4`.
**Runtimes**: Node.js 22+, Deno, Bun, Cloudflare Workers (experimental)
---
**Agents**: LLMs with instructions + tools
import { Agent } from '@openai/agents';
const agent = new Agent({ name: 'Assistant', tools: [myTool], model: 'gpt-5-mini' });**Tools**: Functions with Zod schemas
import { tool } from '@openai/agents';
import { z } from 'zod';
const weatherTool = tool({
name: 'get_weather',
parameters: z.object({ city: z.string() }),
execute: async ({ city }) => `Weather in ${city}: sunny`,
});**Handoffs**: Multi-agent delegation
const triageAgent = Agent.create({ handoffs: [specialist1, specialist2] });**Guardrails**: Input/output validation
const agent = new Agent({ inputGuardrails: [detector], outputGuardrails: [filter] });**Structured Outputs**: Type-safe responses
const agent = new Agent({ outputType: z.object({ sentiment: z.enum(['positive', 'negative']) }) });---
**Basic**: `const result = await run(agent, 'What is 2+2?')`
**Streaming**:
const stream = await run(agent, 'Tell me a story', { stream: true });
for await (const event of stream) {
if (event.type === 'raw_model_stream_event') process.stdout.write(event.data?.choices?.[0]?.delta?.content || '');
}---
const billingAgent = new Agent({ name: 'Billing', handoffDescription: 'For billing questions', tools: [refundTool] });
const techAgent = new Agent({ name: 'Technical', handoffDescription: 'For tech issues', tools: [ticketTool] });
const triageAgent = Agent.create({ name: 'Triage', handoffs: [billingAgent, techAgent] });**Agent-as-Tool Context Isolation**: When using `agent.asTool()`, sub-agents do NOT share parent conversation history (intentional design to simplify debugging).
**Workaround**: Pass context via tool parameters:
const helperTool = tool({
name: 'use_helper',
parameters: z.object({
query: z.string(),
context: z.string().optional(),
}),
execute: async ({ query, context }) => {
return await run(subAgent, `${context}\n\n${query}`);
},
});**Source**: [Issue #806](https://github.com/openai/openai-agents-js/issues/806)
---
**Input**: Validate before processing
const guardrail: InputGuardrail = {
execute: async ({ input }) => ({ tripwireTriggered: detectHomework(input) })
};
const agent = new Agent({ inputGuardrails: [guardrail] });**Output**: Filter responses (PII detection, content safety)
---
const refundTool = tool({ name: 'process_refund', requiresApproval: true, execute: async ({ amount }) => `Refunded $${amount}` });
let result = await runner.run(input);
while (result.interruption?.type === 'tool_approval') {
result = await promptUser(result.interruption) ? result.state.approve(result.interruption) : result.state.reject(result.interruption);
}**Streaming HITL**: When using `stream: true` with `requiresApproval`, must explicitly check interruptions:
const stream = await run(agent, input, { stream: true });
let result = await stream.finalResult();
while (result.interruption?.type === 'tool_approval') {
const approved = await promptUser(result.interruption);
result = approved
? await result.state.approve(result.interruption)
: await result.state.reject(result.interruption);
}**Example**: [human-in-the-loop-stream.ts](https://github.com/openai/openai-agents-js/blob/main/examples/agent-patterns/human-in-the-loop-stream.ts)
---
**Create**:
import { RealtimeAgent } from '@openai/agents-realtime';
const voiceAgent = new RealtimeAgent({
voice: 'alloy', // alloy, echo, fable, onyx, nova, shimmer
model: 'gpt-5-realtime',
tools: [weatherTool],
});**Browser Session**:
import { RealtimeSession } from '@openai/agents-realtime';
const session = new RealtimeSession(voiceAgent, { apiKey: sessionApiKey, transport: 'webrtc' });
await session.connect();**CRITICAL**: Never send OPENAI_API_KEY to browser! Generate ephemeral session tokens server-side.
**Voice Handoffs**: Voice/model must match across agents (cannot change during handoff)
**Limitations**:
**Templates**:
**References**:
---
**Cloudflare Workers** (experimental):
export default {
async fetch(request: Request, env: Env) {
// Disable tracing or use startTracingExportLoop()
process.env.OTEL_SDK_DISABLED = 'true';
process.env.OPENAI_API_KEY = env.O495 personas across 13 departments, 229 skills[^installed] and 388 commands in the full catalog (coco 1.9.0, 2026-10-21). Agent skills, slash commands and subagents for Claude Code, Cursor, Codex and other AI coding agents.
Create Cursor rules for persistent AI guidance. Use when the user wants to create a rule, add coding standards, set up project…
Guides users through creating effective Agent Skills for Cursor. Use when the user wants to create, write, or author a new skill,…
Create custom subagents for specialized AI tasks. Use when the user wants to create a new type of subagent, set up task-specific…
Convert 'Applied intelligently' Cursor rules (.cursor/rules/*.mdc) and slash commands (.cursor/commands/*.md) to Agent Skills…
Modify Cursor/VSCode user settings in settings.json. Use when the user wants to change editor settings, preferences,…
Train and optimize AI agents using Microsoft's Agent Lightning framework with reinforcement learning. Use when setting up agent…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.