Workflow:Microsoft Autogen Tool Augmented Agent
| Knowledge Sources | |
|---|---|
| Domains | LLM_Orchestration, Tool_Use, MCP_Integration, Function_Calling |
| Last Updated | 2026-02-11 18:00 GMT |
Overview
End-to-end process for creating LLM-powered agents augmented with custom function tools, MCP server connections, and nested agent or team tools for enhanced task-solving capabilities.
Description
This workflow demonstrates how to equip AutoGen agents with external capabilities through the tool system. Agents can invoke FunctionTool wrappers around Python callables, connect to MCP servers for standardized tool discovery and execution, and use AgentTool or TeamTool to delegate subtasks to other agents or entire teams.
The process covers defining custom functions as tools, configuring workbenches (static tool sets or MCP connections), attaching tools to an AssistantAgent, and handling the tool execution loop including optional reflection on results. This pattern is essential for building agents that interact with APIs, databases, file systems, or other external services.
Usage
Execute this workflow when an agent needs capabilities beyond pure text generation. Typical scenarios include:
- An agent that searches the web, queries a database, or calls an API
- An agent that performs calculations, generates images, or executes code
- A coordinator agent that delegates subtasks to specialized agents or teams
- Any scenario requiring integration with external MCP-compatible tool servers
You have Python functions, MCP servers, or inner agents that you want to expose as callable tools to an LLM-powered agent.
Execution Steps
Step 1: Define Custom Function Tools
Wrap Python functions as FunctionTool instances. Each function becomes a tool the LLM can invoke by name, with the function's docstring and type annotations used to generate the tool schema automatically.
Key considerations:
- Functions should have clear docstrings and typed parameters for schema generation
- Both synchronous and asynchronous functions are supported
- Return values are converted to strings and passed back to the LLM
- Keep functions focused on a single responsibility
Step 2: Configure Tool Workbenches
Organize tools into workbenches. A StaticWorkbench holds a fixed set of FunctionTools. An McpWorkbench connects to an MCP server (via stdio, WebSocket, or HTTP) for dynamic tool discovery.
Workbench types:
- StaticWorkbench: Pre-defined set of tools, resolved at creation time
- McpWorkbench with StdioServerParams: Launch an MCP server as a subprocess (e.g., via uv or npx)
- McpWorkbench with StreamableHttpServerParams: Connect to an HTTP-based MCP server
Step 3: Create the Tool-Augmented Agent
Instantiate an AssistantAgent with the tools or workbench attached. Configure tool execution behavior including reflection, iteration limits, and summary formatting.
Key parameters:
- tools: Direct list of tools or callables for simple setups
- workbench: Workbench instance for organized or dynamic tool management
- reflect_on_tool_use: When True, the agent makes a follow-up LLM call to interpret tool results
- max_tool_iterations: Number of consecutive tool call rounds allowed before forcing a text response
- tool_call_summary_format: Template for formatting tool results when reflection is disabled
Step 4: Configure Agent or Team Tools (Optional)
For hierarchical delegation, wrap inner agents as AgentTool or inner teams as TeamTool. This allows the outer agent to delegate complex subtasks to specialized agents or full multi-agent teams.
Key considerations:
- Parallel tool calls must be disabled when using AgentTool or TeamTool
- return_value_as_last_message controls whether only the final message or the full conversation is returned
- The inner agent or team runs to completion before returning results
Step 5: Execute and Handle Tool Loops
Run the agent on a task. The agent enters a tool execution loop: it calls the LLM, which may request tool invocations, the tools execute, results are fed back, and the LLM decides whether to make more tool calls or produce a final response.
Execution flow:
- LLM generates a response which may include tool call requests
- Tool calls execute concurrently (or sequentially for agent/team tools)
- Results are added to the model context
- If reflect_on_tool_use is enabled, a follow-up inference interprets the results
- The loop continues for up to max_tool_iterations rounds
Step 6: Process Results
Consume the agent output which includes both the final response and inner events capturing each tool call and execution result. The inner_messages list on the Response object provides full visibility into the tool execution chain.
Output includes:
- ToolCallRequestEvent for each tool invocation the LLM initiated
- ToolCallExecutionEvent with execution results
- Final TextMessage or ToolCallSummaryMessage depending on reflection settings
- Token usage across all LLM calls including tool-related inference