text
stringlengths
0
59.1k
const supervisorAgent = new Agent({
name: "Project Manager",
instructions: "You are a project manager who coordinates expert agents.",
llm: new VercelAIProvider(),
model: openai("gpt-4o"),
subAgents: [researchAgent, writerAgent], // Add subagents
supervisorConfig: {
customGuidelines: [
"Always assign the right task to the right agent",
"Check the outputs of agents",
"Give clear and organized answers to the user",
],
},
});
// Usage
const response = await supervisorAgent.generateText(
"Can you write a comprehensive article about Bitcoin?"
);
```
In the following example, the supervisor automatically:
1. Makes the Researcher research on Bitcoin
2. Makes the Writer translate this research into an article
3. Shows the result to the user
### 2. Pipeline Pattern
Sometimes agents need to be run in order. For example, in an e-commerce app:
<ZoomableMermaid chart={`
graph LR
A[Product Data] --> B[Product Analyzer]
B --> C[Analysis Results]
C --> D[Price Optimizer]
D --> E[Price Strategy]
E --> F[Inventory Manager]
F --> G[Stock Recommendations]
G --> H[Final Product Setup]
classDef input fill:#ecfdf5,stroke:#10b981,stroke-width:2px
classDef agent fill:#059669,color:#ffffff
classDef output fill:#6ee7b7,color:#000000
classDef final fill:#10b981,color:#ffffff
class A input
class B,D,F agent
class C,E,G output
class H final
`} />
```ts
// E-commerce pipeline example
const productAnalyzer = new Agent({
name: "Product Analyzer",
instructions: "Analyze and categorize product information",
// ... configuration
});
const priceOptimizer = new Agent({
name: "Price Optimizer",
instructions: "Do competitive price analysis",
// ... configuration
});
const inventoryManager = new Agent({
name: "Inventory Manager",
instructions: "Check inventory status and provide suggestions",
// ... configuration
});
```
## VoltAgent Orchestration Benefits
### 1. TypeScript-First Development
Although the Python community is the strongest, VoltAgent is highly pragmatic for JavaScript/TypeScript developers. Type safety is present, IDE support is excellent.
### 2. Observability Built-In (VoltOps)
One of the best problems is watching what agents are doing. With VoltOps, you see everything that is happening in terms of agent interactions:
```ts
const agent = new Agent({
// ... other configurations
voltOpsClient: new VoltOpsClient({
publicKey: "your-public-key",
secretKey: "your-secret-key",
}),
});
```
Which agent ran when, how long it took, what flow it ran - it's all on the dashboard.
### 3. Modular Architecture
You can even share tools with multiple agents: