text
stringlengths
0
59.1k
```ts
// You can also share tools
const sharedTools = [weatherTool, searchTool, calculatorTool];
const agents = [
new Agent({ name: "Agent1", tools: [sharedTools[0], sharedTools[1]] }),
new Agent({ name: "Agent2", tools: [sharedTools[1], sharedTools[2]] }),
];
```
## Real-World Examples
### Customer Service Orchestration
<ZoomableMermaid chart={`
graph TD
A[Customer Request] --> B[Ticket Classifier]
B --> C{Request Type?}
C -->|Technical| D[Technical Support Agent]
C -->|Billing| E[Billing Agent]
C -->|General| F[General Support Agent]
D --> G[Technical Solution]
E --> H[Billing Resolution]
F --> I[General Response]
G --> J[Customer Service Supervisor]
H --> J
I --> J
J --> K[Quality Check]
K --> L[Final Response]
L --> A
classDef customer fill:#ecfdf5,stroke:#10b981,stroke-width:2px
classDef classifier fill:#10b981,color:#ffffff
classDef agent fill:#34d399,color:#000000
classDef supervisor fill:#059669,color:#ffffff
classDef solution fill:#6ee7b7,color:#000000
class A,L customer
class B classifier
class D,E,F agent
class J,K supervisor
class G,H,I solution
class C classifier
`} />
This creates an end-to-end customer service pipeline where requests are routed and categorized automatically to the proper specialist agent.
```ts
const classifierAgent = new Agent({
name: "Ticket Classifier",
instructions: "Categorize incoming requests: technical, billing, general",
// ...
});
const technicalAgent = new Agent({
name: "Technical Support",
instructions: "Solve technical problems, use documentation",
// ...
});
const billingAgent = new Agent({
name: "Billing Expert",
instructions: "Answer billing questions",
// ...
});
const customerServiceSupervisor = new Agent({
name: "Customer Service Coordinator",
instructions: "Route customer requests to the right department",
subAgents: [classifierAgent, technicalAgent, billingAgent],
supervisorConfig: {
customGuidelines: [
"First classify the request",
"Route to the right expert agent",
"If there's ambiguity, ask the user for clarification",
],
},
});
```
### Content Production Pipeline
```ts
const contentPipeline = new Agent({
name: "Content Production Manager",
instructions: "Manage the content production process",
subAgents: [
new Agent({
name: "Trend Researcher",
instructions: "Research current trends and suggest topics",
}),
new Agent({
name: "Content Writer",
instructions: "Write SEO-friendly content",
}),