Skip to content

Commit 4aac4ac

Browse files
committed
docs: Update Agents docs to align with openai/openai-agents-python#1650
1 parent bddda90 commit 4aac4ac

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

docs/src/content/docs/guides/agents.mdx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import simpleAgent from '../../../../../examples/docs/agents/simpleAgent.ts?raw'
88
import agentWithTools from '../../../../../examples/docs/agents/agentWithTools.ts?raw';
99
import agentWithContext from '../../../../../examples/docs/agents/agentWithContext.ts?raw';
1010
import agentWithAodOutputType from '../../../../../examples/docs/agents/agentWithAodOutputType.ts?raw';
11+
import agentsAsTools from '../../../../../examples/docs/agents/agentsAsTools.ts?raw';
1112
import agentWithHandoffs from '../../../../../examples/docs/agents/agentWithHandoffs.ts?raw';
1213
import agentWithDynamicInstructions from '../../../../../examples/docs/agents/agentWithDynamicInstructions.ts?raw';
1314
import agentWithLifecycleHooks from '../../../../../examples/docs/agents/agentWithLifecycleHooks.ts?raw';
@@ -76,14 +77,27 @@ plain text.
7677

7778
---
7879

79-
## Handoffs
80+
## Multi-agent system design patterns
8081

81-
An Agent can **delegate** to other Agents via the `handoffs` property. A common pattern is to
82-
use a _triage agent_ that routes the conversation to a more specialised sub‑agent.
82+
There are many ways to compose agents together. Two patterns we regularly see in
83+
production apps are:
8384

84-
<Code lang="typescript" code={agentWithHandoffs} title="Agent with handoffs" />
85+
1. **Manager (agents as tools)** – a central agent owns the conversation and invokes specialized agents that are exposed as tools.
86+
2. **Handoffs** – the initial agent delegates the entire conversation to a specialist once it has identified the user's request.
87+
88+
These approaches are complementary. Managers give you a single place to enforce guardrails or rate limits, while handoffs let each agent focus on a single task without retaining control of the conversation.
89+
90+
### Manager (agents as tools)
91+
92+
In this pattern the manager never hands over control—the LLM uses the tools and the manager summarizes the final answer. Read more in the [tools guide](/openai-agents-js/guides/tools#agents-as-tools).
8593

86-
You can read more about this pattern in the [handoffs guide](/openai-agents-js/guides/handoffs).
94+
<Code lang="typescript" code={agentsAsTools} title="Agents as tools" />
95+
96+
### Handoffs
97+
98+
With handoffs the triage agent routes requests, but once a handoff occurs the specialist agent owns the conversation until it produces a final output. This keeps prompts short and lets you reason about each agent independently. Learn more in the [handoffs guide](/openai-agents-js/guides/handoffs).
99+
100+
<Code lang="typescript" code={agentWithHandoffs} title="Agent with handoffs" />
87101

88102
---
89103

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Agent } from '@openai/agents';
2+
3+
const bookingAgent = new Agent({
4+
name: 'Booking expert',
5+
instructions: 'Answer booking questions and modify reservations.',
6+
});
7+
8+
const refundAgent = new Agent({
9+
name: 'Refund expert',
10+
instructions: 'Help customers process refunds and credits.',
11+
});
12+
13+
const customerFacingAgent = new Agent({
14+
name: 'Customer-facing agent',
15+
instructions:
16+
'Talk to the user directly. When they need booking or refund help, call the matching tool.',
17+
tools: [
18+
bookingAgent.asTool({
19+
toolName: 'booking_expert',
20+
toolDescription: 'Handles booking questions and requests.',
21+
}),
22+
refundAgent.asTool({
23+
toolName: 'refund_expert',
24+
toolDescription: 'Handles refund questions and requests.',
25+
}),
26+
],
27+
});

0 commit comments

Comments
 (0)