1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80# Examples
Learn Volcano SDK through hands-on examples, from simple to advanced.
## Getting Started
```bash
export OPENAI_API_KEY="your-key-here"
tsx examples/01-hello-world.ts
```
## Examples
### Basics
**01-hello-world.ts** - Your first agent
Multi-step reasoning in ~10 lines
**02-with-tools.ts** - Automatic tool selection
The agent picks the right MCP tools automatically
**02b-with-stdio.ts** - stdio MCP servers
Use local tools via stdio transport (not HTTP)
**03-streaming.ts** - Real-time responses
Stream tokens as they're generated
**04-structured-outputs.ts** - Type-safe data
Extract structured JSON with Zod schemas
### Composition
**05-sub-agents.ts** - Reusable components
Build modular agents with `.runAgent()`
**06-multi-agent.ts** - Autonomous delegation
Coordinator automatically routes to specialists
**07-patterns.ts** - Advanced workflows
`parallel()`, `branch()`, `forEach()`, `retryUntil()`
### Production
**08-context.ts** - Conversation history
Manage context across multiple steps
**09-observability.ts** - Monitoring & traces
OpenTelemetry integration for production
**10-providers.ts** - Multiple LLMs
Switch between OpenAI, Claude, etc.
**11-email-triage.ts** - Real use case
Full workflow: classify, extract, respond
## Running MCP Servers
Some examples need MCP servers:
```bash
# Terminal 1
tsx examples/mcp/weather/server.ts
# Terminal 2
tsx examples/mcp/tasks/server.ts
# Terminal 3
tsx examples/02-with-tools.ts
```
See [mcp/README.md](mcp/README.md) for details.
## Tips
- Start with 01-04 to learn the basics
- Try 05-06 to understand composition
- Check 11 for a real-world example
- All examples are standalone and copy-paste ready