How sjtu-sai-agents/browse-master works
Project Type and Purpose
• BrowseMaster is an open-source, LLM-based “Planner–Executor” web-browsing agent.
• Purpose: Given a user query, it uses a planner LLM to create a high-level search strategy, then an executor LLM plus code-based search primitives to run thousands of page queries, decide when to replan, and produce a final answer.
File Structure
• Entry point: agent.py orchestrates the end-to-end pipeline.
• Configuration:
• config/model_config.yaml holds model endpoint URLs (DeepSeek-R1, etc.).
• config/r1_tool.jinja is a Jinja template for wrapping tool calls.
• Core package: llm_agent/
• base_agent.py: LLM invocation wrapper.
• context.py: Maintains conversation state, memory, and confidence scores.
• tools/tool_manager.py: Exposes primitives (batch_search, generate_keywords, check_condition) to the executor.
• utils.py: Shared helpers (parsing, logging, metrics).
• Prompts: prompts/*.txt define planner & executor system messages and prefixes.
• Logs: logs/examples.jsonl captures sample runs.
README for Additional Insights
• Emphasizes a two-phase architecture:
1) Planner – high-level strategy generation
2) Executor – code-driven search primitives + confidence-guided replanning
• Mentions external dependencies: local “mcp_sandbox” for safe code execution, and a Toolbox service (toolbox URL).
Planner Module Deep Dive
• Inputs: user query, context (history, previous plans)
• Process: load prompts/planner_prefix.txt + prompts/planner_prompt.txt, fill in context via Jinja
• Invoke base_agent to call LLM endpoint (DeepSeek-R1-0528)
• Parse LLM response into a structured “plan” (steps with keywords, browse actions)
• Emit plan back to orchestrator
Executor Module Deep Dive
• Inputs: plan (sequence of sub-tasks), context, confidence threshold
• Process loop:
1) Load executor prompts (executor_prefix.txt, executor_prompt.txt)
2) For each step, invoke tool_manager.batch_search or generate_keywords or check_condition
3) Collect results, update context, compute confidence
5) Otherwise, continue until plan completion
• Output: final synthesized answer