text
stringlengths
0
59.1k
const cheapAgent = new Agent({
name: "Classifier",
model: openai("gpt-4o-mini"), // Cheap model
instructions: "Just determine the category",
});
const expensiveAgent = new Agent({
name: "Complex Analyzer",
model: openai("gpt-4o"), // Expensive model
instructions: "Do detailed analysis",
});
```
### 6. Maintenance & Debugging
It's easier to discover problems in orchestration:
- What all agents do is clearly defined
- You can see which agent is at fault with VoltOps
- Fixing one agent won't disrupt others
- Tests are easier to write
### 7. Real-World Business Alignment
Orchestration is more suitable for actual business workflows:
- Businesses have departments (sales, marketing, technical)
- Every department has experts
- Agents must work this way too
- Business flows are easily represented
## Orchestration Patterns
### 1. Supervisor Pattern (Most Used)
In this pattern, there's a "boss" agent, and other agents report to it. This is very simple in VoltAgent:
<ZoomableMermaid chart={`
graph TD
A[User] --> B[Supervisor Agent]
B --> C{Analyze Request}
C --> D[Delegate to Research Agent]
C --> E[Delegate to Writer Agent]
C --> F[Delegate to Analysis Agent]
D --> G[Research Agent]
E --> H[Writer Agent]
F --> I[Analysis Agent]
G --> J[Research Results]
H --> K[Written Content]
I --> L[Analysis Results]
J --> M[Supervisor Agent]
K --> M
L --> M
M --> N[Coordinate & Combine]
N --> O[Final Response]
O --> A
classDef user fill:#ecfdf5,stroke:#10b981,stroke-width:2px
classDef supervisor fill:#059669,color:#ffffff
classDef agent fill:#34d399,color:#000000
classDef result fill:#6ee7b7,color:#000000
classDef process fill:#10b981,color:#ffffff
class A user
class B,M supervisor
class G,H,I agent
class J,K,L result
class C,D,E,F,N process
class O user
`} />
```ts
import { Agent } from "@voltagent/core";
import { VercelAIProvider } from "@voltagent/vercel-ai";
import { openai } from "@ai-sdk/openai";
// Let's create expert agents
const researchAgent = new Agent({
name: "Researcher",
purpose: "Expert in collecting and analyzing data from the web",
instructions: "You are a research expert. You collect detailed and accurate information.",
llm: new VercelAIProvider(),
model: openai("gpt-4o-mini"),
});
const writerAgent = new Agent({
name: "Writer",
purpose: "Professional content writing expert",
instructions: "You are a writer. You write clear and effective texts.",
llm: new VercelAIProvider(),
model: openai("gpt-4o-mini"),
});
// Supervisor agent