Integrating Tools with Agents
AutoGen agents can use tools to interact with external systems, execute code, search databases, and more. Learn how to integrate tools effectively.Basic Tool Integration
The simplest way to add tools is by passing Python functions to agents:Async Tools
Tools can be async for I/O operations:Tool Call Behavior
Control how agents handle tool calls:Reflect on Tool Use
Whenreflect_on_tool_use=True, the agent makes another LLM call to generate a natural language response:
Direct Tool Results
Whenreflect_on_tool_use=False, tool results are returned directly:
Multiple Tool Iterations
Control how many tool call rounds an agent can make:Function Tool Class
For more control, use theFunctionTool class:
Structured Tool Inputs
Use Pydantic models for complex tool inputs:Tools in Multi-Agent Teams
Different agents can have different tools:In v0.4, you don’t need a separate executor agent for tools. The
AssistantAgent calls and executes tools automatically.Code Execution
For code execution, useCodeExecutorAgent:
Docker Code Execution
Execute code in isolated Docker containers:Custom Tool Results
Return rich tool results:Error Handling in Tools
Handle errors gracefully:Tool Call Summary Format
Customize how tool results are formatted:Parallel Tool Calls
By default, multiple tool calls execute in parallel:Best Practices
Advanced: Custom Tool Classes
Implement custom tool classes for complex behavior:Related Resources
- MCP Servers - Connect to MCP protocol servers
- Custom Agents - Build agents with custom tool handling
- Multi-Agent Workflows - Use tools in teams