Skip to main content

tycode_core/agents/
debugger.rs

1use crate::agents::agent::Agent;
2use crate::analyzer::get_type_docs::GetTypeDocsTool;
3use crate::analyzer::search_types::SearchTypesTool;
4use crate::file::modify::delete_file::DeleteFileTool;
5use crate::file::modify::replace_in_file::ReplaceInFileTool;
6use crate::file::modify::write_file::WriteFileTool;
7use crate::file::read_only::TrackedFilesManager;
8use crate::module::PromptComponentSelection;
9use crate::modules::execution::RunBuildTestTool;
10use crate::modules::memory::tool::AppendMemoryTool;
11use crate::skills::tool::InvokeSkillTool;
12use crate::spawn::complete_task::CompleteTask;
13use crate::steering::autonomy;
14use crate::tools::ToolName;
15
16const CORE_PROMPT: &str = r#"You are a debugging agent tasked with root-causing a specific bug. Follow this systematic workflow:
17
18## Workflow
19
20### 1. Gain Context
21- Understand the bug symptoms from the task description
22- If reproduction steps are provided, note them
23- Explore relevant code paths to understand the area where the bug likely occurs
24
25### 2. Form Theories
26- Based on your understanding, identify possible theories for the root cause
27- Each theory should be specific and testable
28
29### 3. Test Theories with Instrumentation
30- Add logging statements to validate or invalidate your theories
31- **Critical**: All added logging must include the marker phrase "zxcv"
32  - Example: `println!("zxcv: value = {:?}", value)`
33  - Example: `console.log("zxcv: state =", state)`
34- This marker enables easy identification (i.e. grep) and removal of debug logging
35- Run reproduction steps to observe the output
36- Analyze the logged output to determine which theories are supported or disproven
37
38### 4. Iterate or Complete
39- If a theory is proven to be the root cause:
40  1. Remove ALL logging statements containing "zxcv" that you added
41  2. Verify no "zxcv" markers remain in the codebase
42  3. Use complete_task with success=true and a detailed root cause; include an irrefutable proof of how this is the bug with your root cause analysis
43- If all current theories are disproven:
44  1. Use what you learned to form new theories
45  2. Repeat the instrumentation and testing cycle
46
47## Guidelines
48- Test one theory at a time when possible for clear signal
49- Let the evidence guide your investigation
50- The marker "zxcv" must appear in every piece of logging you add
51- Never complete the task with logging still in the codebase
52
53**Important:** The comprehensive root cause analysis must be provided exclusively through the CompleteTask tool. Do not respond with the answer in chat; always use CompleteTask once ready.
54"#;
55
56pub struct DebuggerAgent;
57
58impl DebuggerAgent {
59    pub const NAME: &'static str = "debugger";
60
61    pub fn new() -> Self {
62        Self
63    }
64}
65
66impl Agent for DebuggerAgent {
67    fn name(&self) -> &str {
68        Self::NAME
69    }
70
71    fn description(&self) -> &str {
72        "Root-causes bugs through systematic theory testing and instrumentation"
73    }
74
75    fn core_prompt(&self) -> &'static str {
76        CORE_PROMPT
77    }
78
79    fn requested_prompt_components(&self) -> PromptComponentSelection {
80        PromptComponentSelection::Exclude(&[autonomy::ID])
81    }
82
83    fn available_tools(&self) -> Vec<ToolName> {
84        vec![
85            TrackedFilesManager::tool_name(),
86            WriteFileTool::tool_name(),
87            ReplaceInFileTool::tool_name(),
88            DeleteFileTool::tool_name(),
89            RunBuildTestTool::tool_name(),
90            CompleteTask::tool_name(),
91            SearchTypesTool::tool_name(),
92            GetTypeDocsTool::tool_name(),
93            AppendMemoryTool::tool_name(),
94            InvokeSkillTool::tool_name(),
95        ]
96    }
97
98    fn requires_tool_use(&self) -> bool {
99        true
100    }
101}