Use this file to discover all available pages before exploring further.
Build custom agents that interact with MCP tools to complete tasks. An agent is essentially a loop that calls your LLM, executes tools based on its decisions, and continues until the task is complete.
An agent follows this lifecycle:The agent keeps calling your LLM and executing tools until the LLM stops requesting tools, indicating the task is complete.
Client lifecycle - Auto-creates MCP client from task.mcp_config, cleans up after execution
Tool discovery - Discovers tools from servers, applies allowed_tools/disallowed_tools filtering
Lifecycle tools - Automatically runs setup_tool and evaluate_tool, hides them from your LLM
The execution loop - Calls your methods in sequence, handles errors gracefully
Telemetry - Automatic tracing and logging when auto_trace=True or verbose=True
The main loop:
while not done and step < max_steps: response = await agent.get_response(messages) # Your method if response.tool_calls: results = await agent.call_tools(response.tool_calls) messages.extend(await agent.format_tool_results(tool_calls, results)) # Your method else: done = True
See the Agents Reference for configuration options like auto_respond, allowed_tools, etc.