Overview
TheAutogenDeepSearchAgent is a sophisticated agent that performs deep web searches and analysis using a multi-agent system. It coordinates between a researcher agent (for thinking and analysis) and an executor agent (for executing search operations).
Class Definition
Parameters
LLM configuration dictionary. If not provided, defaults to service configuration for “deepsearch”.Structure:
model: Model name to useapi_key: API key for the LLM servicebase_url: Base URL for the APItemperature: Temperature for generation (0-1)- Other provider-specific parameters
Code execution configuration. Defaults to
{"work_dir": 'coding', "use_docker": False}Structure:work_dir: Working directory for code executionuse_docker: Whether to use Docker for code execution
Whether to return the full chat history along with the final answer
Whether to save execution logs to file
Methods
deep_search
The user’s search query or research question
The final answer to the search query, or a tuple of (answer, chat_history) if
return_chat_history is Trueweb_agent_answer
deep_search. Uses asyncio.run() internally.
The initial search query
JSON string containing search results
a_web_agent_answer
web_agent_answer with error handling.
The initial search query
Search results or error message if the search fails
run
The search query
Dictionary containing:
final_answer: The final search resulttrajectory: Full chat history of the search process
Configuration
Internal Agents
TheAutogenDeepSearchAgent creates two internal agents:
-
Researcher Agent (
ExtendedAssistantAgent)- Responsible for thinking, analysis, and planning
- Uses the configured LLM to generate search strategies
- Determines when to terminate the search
-
Executor Agent (
DeepSearchExecutor)- Executes search and browse operations
- Processes tool calls from the researcher
- Summarizes tool responses when they exceed token limits
Message Summarization
The agent automatically summarizes long tool responses to manage context:max_tool_messages_before_summary: Default 2 roundstoken_limit: Default 2000 tokens- Uses
cl100k_baseencoding for token counting
Tool Registration
The agent registers the following tools:searching: Web search functionalitybrowsing: Web page browsing and content extraction
Advanced Usage
Custom LLM Configuration
Custom Working Directory
Error Handling
The async methods include built-in error handling:Notes
- The agent uses a maximum of 30 conversation turns by default
- Messages are automatically summarized using LLM when tool responses exceed token limits
- The agent supports termination detection via
TERMINATEkeyword in messages - All searches are logged if
save_log=True