From e984a1b92d55f1244a4690dc4e3219b717683f77 Mon Sep 17 00:00:00 2001 From: WEVAL-Ambre Date: Mon, 30 Mar 2026 21:51:31 +0200 Subject: [PATCH] feat: explorer subagent + TodoWrite pattern + verifier in prompt --- .../deerflow/agents/lead_agent/prompt.py | 8 ++++ .../deerflow/subagents/builtins/__init__.py | 3 ++ .../subagents/builtins/explorer_agent.py | 46 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 backend/packages/harness/deerflow/subagents/builtins/explorer_agent.py diff --git a/backend/packages/harness/deerflow/agents/lead_agent/prompt.py b/backend/packages/harness/deerflow/agents/lead_agent/prompt.py index e4ddd0a..9720afe 100644 --- a/backend/packages/harness/deerflow/agents/lead_agent/prompt.py +++ b/backend/packages/harness/deerflow/agents/lead_agent/prompt.py @@ -40,6 +40,7 @@ You are running with subagent capabilities enabled. Your role is to be a **task - **general-purpose**: For ANY non-trivial task - web research, code exploration, file operations, analysis, etc. - **bash**: For command execution (git, build, test, deploy operations) - **verifier**: For adversarial verification of implementations. Use AFTER code changes to test correctness. Returns VERDICT: PASS/FAIL/PARTIAL +- **explorer**: For deep codebase exploration WITHOUT modifying files. Use BEFORE planning changes to understand architecture, dependencies, and data flow **Your Orchestration Strategy:** @@ -342,6 +343,13 @@ combined with a FastAPI gateway for REST API access [citation:FastAPI](https://f - Multi-task: Better utilize parallel tool calling to call multiple tools at one time for better performance - Language Consistency: Keep using the same language as user's - Always Respond: Your thinking is internal. You MUST always provide a visible response to the user after thinking. + +**TASK DECOMPOSITION (TodoWrite pattern):** +- For complex tasks, decompose into numbered sub-tasks in your thinking BEFORE starting +- Track each sub-task status: PENDING -> IN_PROGRESS -> DONE or BLOCKED +- Do not declare "done" until ALL sub-tasks are DONE +- If a sub-task is BLOCKED, explain why and propose alternatives +- After completing all sub-tasks, verify the overall result matches the original request """ diff --git a/backend/packages/harness/deerflow/subagents/builtins/__init__.py b/backend/packages/harness/deerflow/subagents/builtins/__init__.py index 547a942..d60d88a 100644 --- a/backend/packages/harness/deerflow/subagents/builtins/__init__.py +++ b/backend/packages/harness/deerflow/subagents/builtins/__init__.py @@ -3,11 +3,13 @@ from .bash_agent import BASH_AGENT_CONFIG from .general_purpose import GENERAL_PURPOSE_CONFIG from .verifier_agent import VERIFIER_AGENT_CONFIG +from .explorer_agent import EXPLORER_AGENT_CONFIG __all__ = [ "GENERAL_PURPOSE_CONFIG", "BASH_AGENT_CONFIG", "VERIFIER_AGENT_CONFIG", + "EXPLORER_AGENT_CONFIG", ] # Registry of built-in subagents @@ -15,4 +17,5 @@ BUILTIN_SUBAGENTS = { "general-purpose": GENERAL_PURPOSE_CONFIG, "bash": BASH_AGENT_CONFIG, "verifier": VERIFIER_AGENT_CONFIG, + "explorer": EXPLORER_AGENT_CONFIG, } diff --git a/backend/packages/harness/deerflow/subagents/builtins/explorer_agent.py b/backend/packages/harness/deerflow/subagents/builtins/explorer_agent.py new file mode 100644 index 0000000..04f2dc6 --- /dev/null +++ b/backend/packages/harness/deerflow/subagents/builtins/explorer_agent.py @@ -0,0 +1,46 @@ +"""Explorer subagent - inspired by Claude Code Explore pattern. + +This subagent searches and analyzes codebases without creating or modifying files. +It focuses on thorough investigation using search strategies. +""" + +from deerflow.subagents.config import SubagentConfig + +EXPLORER_SYSTEM_PROMPT = """You are an explorer specialist. Your role is to thoroughly investigate codebases, documentation, and systems WITHOUT creating or modifying any files. + +=== CORE RULES === +1. NEVER create, modify, or delete files. You are READ-ONLY. +2. Use search strategies: grep, glob, read_file, web_search, web_fetch. +3. Be thorough -- check multiple angles before concluding. +4. Report findings with exact file_path:line_number references. +5. If you cannot find something, say so clearly -- do not fabricate. + +=== SEARCH STRATEGIES === +- Start broad, then narrow: first glob for file patterns, then grep for content. +- Check imports and dependencies to understand architecture. +- Look at tests to understand expected behavior. +- Read README, CHANGELOG, and config files first. +- Follow the data flow: entry point -> processing -> output. + +=== OUTPUT FORMAT === +Structure your findings as: +### Finding: [what you discovered] +**Location:** file_path:line_number +**Evidence:** [exact code or text snippet] +**Relevance:** [why this matters for the task] + +End with a **Summary** of key findings and recommended next steps. +""" + +EXPLORER_AGENT_CONFIG = SubagentConfig( + name="explorer", + description=( + "Codebase exploration specialist that searches and analyzes code WITHOUT " + "creating or modifying files. Use for deep research, architecture understanding, " + "dependency analysis, and finding relevant code before planning changes." + ), + system_prompt=EXPLORER_SYSTEM_PROMPT, + disallowed_tools=["task", "write_file", "str_replace"], + max_turns=25, + timeout_seconds=300, +)