Skip to main content
The Deep Search Agent provides powerful web search capabilities with intelligent result synthesis. It searches the web, browses pages, and generates comprehensive answers based on real-time information.

Overview

Implemented in src/services/agents/deep_search_agent.py:103, the AutogenDeepSearchAgent class orchestrates web search operations through two specialized agents:
  • Researcher Agent: Plans search strategies and analyzes results
  • Executor Agent: Executes web searches and browses content

Key Features

Real-time Search

Access current information beyond the model’s knowledge cutoff

Intelligent Browsing

Automatically browse and extract relevant content from web pages

Result Synthesis

Generate comprehensive answers by synthesizing multiple sources

Context Management

Automatically summarize long search results to maintain context

Usage

Basic Usage

from src.services.agents.deep_search_agent import AutogenDeepSearchAgent
from configs.oai_config import get_llm_config
import asyncio

# Initialize the agent
llm_config = get_llm_config(service_type="deepsearch")
agent = AutogenDeepSearchAgent(llm_config=llm_config)

# Perform a search
query = "What are the latest developments in quantum computing?"
result = asyncio.run(agent.deep_search(query))
print(result)

CLI Mode

# Launch Deep Search Agent directly
python launcher.py --mode deepsearch

# Interactive prompt
🤔 Please enter search question: What is the latest AI research?
🔍 Searching...
📋 Search results: [comprehensive answer based on web search]

Methods

Execute a deep web search and return synthesized results.
query
str
required
The search query or research question
Returns: str - Comprehensive answer based on web search results Source: src/services/agents/deep_search_agent.py:269
async def deep_search(self, query: str) -> str:
    """
    Execute deep search and return results
    
    Args:
        query: User's query question
        
    Returns:
        Search results and answer
    """

web_agent_answer()

Synchronous wrapper for deep_search.
query
str
required
The search query
Returns: str - Search results as a string Source: src/services/agents/deep_search_agent.py:332
def web_agent_answer(self, query: str) -> str:
    """Execute deep search and return results (sync version)"""
    return asyncio.run(self.deep_search(query))

run()

Execute search and return both final answer and conversation trajectory.
query
str
required
The search query
Returns: dict - Dictionary containing final_answer and trajectory Source: src/services/agents/deep_search_agent.py:344
async def run(self, query: str) -> str:
    """Execute deep search with full trajectory"""
    final_answer, chat_result = await self.deep_search(query)
    return {
        "final_answer": final_answer,
        "trajectory": chat_result
    }

Configuration

Initialization Parameters

llm_config
dict
default:"None"
LLM configuration dictionary. If None, uses get_llm_config(service_type="deepsearch")
code_execution_config
dict
default:"None"
Code execution configuration. If None, uses {"work_dir": 'coding', "use_docker": False}
return_chat_history
bool
default:"False"
Whether to return the full chat history along with results
save_log
bool
default:"False"
Whether to save search logs to file

Advanced Configuration

agent = AutogenDeepSearchAgent(
    llm_config=custom_llm_config,
    code_execution_config={"work_dir": "./search_workspace"},
    return_chat_history=True,  # Get full conversation history
    save_log=True  # Save logs for debugging
)

# Configure context management
agent.max_tool_messages_before_summary = 3  # Summarize every 3 tool calls
agent.token_limit = 3000  # Maximum tokens before summarization

Available Tools

The Deep Search Agent has access to the following tools (registered in src/services/agents/deep_search_agent.py:154):

searching()

Perform web searches using search engines. Implementation: AgentToolLibrary.searching

browsing()

Browse and extract content from web pages. Implementation: AgentToolLibrary.browsing

Context Management

The agent automatically manages context to handle long search sessions:
Automatic Summarization: When search results exceed the token limit (default: 2000 tokens), the agent automatically summarizes them to maintain context while staying within LLM limits.
Configuration:
  • max_tool_messages_before_summary: Number of tool calls before summarizing (default: 2)
  • token_limit: Token count threshold for triggering summarization (default: 2000)
  • Uses tiktoken with cl100k_base encoding for accurate token counting

Example Use Cases

# Research a technical topic
query = """
What are the key differences between RAG and fine-tuning 
for LLM customization? Include recent research findings.
"""
result = asyncio.run(agent.deep_search(query))

Architecture

Error Handling

The agent includes comprehensive error handling:
try:
    result = await agent.a_web_agent_answer(query)
except Exception as e:
    # Errors are logged to search_error_log.txt
    print(f"Search error: {e}")
Error logs are saved to: search_error_log.txt (source: src/services/agents/deep_search_agent.py:372)

Limitations

  • No Code Execution: The Deep Search Agent focuses on information retrieval and does not execute code
  • Web Dependency: Requires active internet connection and search API access
  • Rate Limits: Subject to search engine API rate limits
  • Context Window: Very long search sessions may still hit context limits despite summarization

Next Steps

Programming Assistant

Learn about general coding assistance

Repository Agent

Explore repository analysis capabilities

Build docs developers (and LLMs) love