text stringlengths 0 59.1k |
|---|
onToolStart: async ({ agent, tool, context }) => { |
const reqId = context.context.get("requestId"); |
console.log(`[${reqId}] Tool starting: ${tool.name}`); |
}, |
onToolEnd: async ({ agent, tool, output, context }) => { |
const reqId = context.context.get("requestId"); |
console.log(`[${reqId}] Tool completed: ${tool.name}`, output); |
}, |
onError: async ({ agent, error, context }) => { |
const reqId = context.context.get("requestId"); |
console.error(`[${reqId}] Error occurred:`, error); |
// Error tracking services integration |
}, |
}); |
const productionAgent = new Agent({ |
name: "Production Agent", |
// ... other config |
hooks, // Full observability |
}); |
``` |
## Real Project Examples |
### E-commerce Customer Support Bot |
```typescript |
import { createTool } from "@voltagent/core"; |
const orderQueryTool = createTool({ |
name: "query_order", |
description: "Query order status by order number", |
parameters: z.object({ |
orderNumber: z.string().describe("Order number"), |
}), |
execute: async ({ orderNumber }) => { |
// Database query |
const order = await database.orders.findOne({ id: orderNumber }); |
return { |
status: order.status, |
trackingCode: order.trackingCode, |
estimatedDelivery: order.estimatedDelivery, |
}; |
}, |
}); |
const supportAgent = new Agent({ |
name: "customer-support", |
instructions: "E-commerce customer support that can track orders", |
tools: [orderQueryTool, refundTool, humanHandoffTool], |
memory: new LibSQLStorage(), |
llm: new VercelAIProvider(), |
model: openai("gpt-4o"), |
}); |
``` |
Results with this system: |
- 35% less human intervention |
- 60% faster response time |
- 24/7 availability |
### Content Generation Pipeline |
```typescript |
// Research → Writing → Review → Publishing workflow |
const contentPipeline = new Agent({ |
name: "Content Creator", |
instructions: "Coordinator that researches, writes, and reviews blog posts", |
subAgents: [researchAgent, writerAgent, editorAgent], |
tools: [seoAnalyzer, plagiarismChecker, publishTool], |
}); |
const result = await contentPipeline.generateText( |
"Write an SEO-optimized blog post about new features in React 19" |
); |
``` |
## Debugging & Monitoring: VoltOps Console |
Visual debugging console integrated with the framework: |
```bash |
npm run dev |
# VoltOps Console: https://console.voltagent.dev |
``` |
What you can do from the console: |
- **Real-time conversation monitoring** |
- **Tool execution tracing** |
- **Memory state inspection** |
- **Performance metrics** |
- **Error debugging** |
 |
This visual-first approach makes the debugging process more understandable. |
## Migration Guide |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.