Research - Research Sub-Agent Feature Deletion
Date: 2026-01-26
Owner: agent
Phase: Research
Goal
Map all components of the research_codebase sub-agent feature for clean removal. The feature is already disabled in production (commented out in agent_config.py).
Findings
Critical Status: ALREADY DISABLED
The research tool is already commented out in production:
# src/tunacode/core/agents/agent_components/agent_config.py:37-39
# TODO: Re-enable research_codebase subagent after fixing parameter name mismatch
# See: memory-bank/research/2026-01-25_limited-read-file-parameter-mismatch.md
# from tunacode.core.agents.delegation_tools import create_research_codebase_tool
Impact: No active users, no runtime impact, safe to delete.
Files to DELETE (7 files)
Core Implementation (2 files)
| File |
Lines |
Purpose |
src/tunacode/core/agents/delegation_tools.py |
154 |
Tool factory with create_research_codebase_tool(), ResearchResult TypedDict |
src/tunacode/core/agents/research_agent.py |
249 |
Agent factory with create_research_agent(), ProgressTracker, limited read_file wrapper |
UI Renderer (1 file)
| File |
Lines |
Purpose |
src/tunacode/ui/renderers/tools/research.py |
296 |
ResearchRenderer class, ResearchData dataclass, 4-zone panel layout |
Prompt Sections (4 files)
| File |
Purpose |
src/tunacode/prompts/research/sections/agent_role.xml |
Research agent role definition |
src/tunacode/prompts/research/sections/tool_use.xml |
Tool usage guidelines |
src/tunacode/prompts/research/sections/constraints.xml |
Research constraints |
src/tunacode/prompts/research/sections/output_format.xml |
Output format spec |
Also delete the parent directory: src/tunacode/prompts/research/
Files to MODIFY (17 files)
Core Layer (5 files)
| File |
Line(s) |
Change |
src/tunacode/core/agents/agent_components/agent_config.py |
37-39, 423-428 |
Remove commented import and tool registration |
src/tunacode/core/agents/agent_components/orchestrator/tool_dispatcher.py |
23, 30 |
Remove RESEARCH_TOOL_NAME and TOOL_START_RESEARCH_LABEL constants |
src/tunacode/core/agents/agent_components/agent_helpers.py |
54 |
Remove research case from get_readable_tool_description() |
src/tunacode/core/prompting/templates.py |
48-60 |
Remove RESEARCH_TEMPLATE definition |
src/tunacode/core/prompting/__init__.py |
14, 26 |
Remove RESEARCH_TEMPLATE import and export |
Constants & Config (2 files)
| File |
Line(s) |
Change |
src/tunacode/constants.py |
78, 88 |
Remove RESEARCH_CODEBASE from ToolName enum and READ_ONLY_TOOLS |
src/tunacode/configuration/settings.py |
32 |
Remove ToolName.RESEARCH_CODEBASE from tool list |
UI Layer (2 files)
| File |
Line(s) |
Change |
src/tunacode/ui/renderers/tools/__init__.py |
29, 69 |
Remove render_research_codebase import and __all__ export |
src/tunacode/ui/renderers/panels.py |
504, 518 |
Remove research renderer from registry |
Tests (2 files)
| File |
Line(s) |
Change |
tests/integration/tools/test_tool_dispatcher_coverage.py |
30, 62-65, 236 |
Remove RESEARCH_TOOL_NAME constant and test |
tests/integration/core/test_tool_call_lifecycle.py |
75 |
Remove research from filter logic |
Scripts (1 file)
| File |
Line(s) |
Change |
scripts/preview_tool_panels.py |
211, 264, 390-396 |
Remove research preview builder |
Documentation (5 files)
| File |
Section |
Change |
docs/codebase-map/modules/core-agents.md |
102-154 |
Remove delegation/research section |
docs/codebase-map/modules/core-prompting.md |
34, 61 |
Remove RESEARCH_TEMPLATE documentation |
docs/codebase-map/modules/ui-overview.md |
90 |
Remove research renderer reference |
docs/codebase-map/structure/02-core-directory.md |
30, 60-64 |
Remove research_agent.py mentions |
docs/codebase-map/structure/tree-structure.txt |
63, 160 |
Remove research files from tree |
Key Patterns / Solutions Found
Architecture Layers Affected
┌─────────────────────────────────────────────────┐
│ PROMPTS research/sections/ (4 XML) │ DELETE
├─────────────────────────────────────────────────┤
│ TEMPLATES RESEARCH_TEMPLATE │ REMOVE
├─────────────────────────────────────────────────┤
│ AGENTS delegation_tools.py │ DELETE
│ research_agent.py │ DELETE
├─────────────────────────────────────────────────┤
│ CONSTANTS ToolName.RESEARCH_CODEBASE │ REMOVE
│ READ_ONLY_TOOLS │ REMOVE
├─────────────────────────────────────────────────┤
│ DISPATCHER RESEARCH_TOOL_NAME │ REMOVE
├─────────────────────────────────────────────────┤
│ UI research.py (renderer) │ DELETE
│ panels.py (registry) │ MODIFY
├─────────────────────────────────────────────────┤
│ TESTS dispatcher_coverage.py │ MODIFY
│ tool_call_lifecycle.py │ MODIFY
└─────────────────────────────────────────────────┘
Comparison to Planning Feature Deletion
| Layer |
Planning (completed) |
Research (this task) |
| Tool |
present_plan.py |
delegation_tools.py + research_agent.py |
| UI |
plan_approval.py |
research.py (renderer) |
| Prompts |
present_plan_prompt.xml |
prompts/research/sections/ (4 files) |
| Constants |
EXIT_PLAN_MODE_SENTINEL |
RESEARCH_TOOL_NAME, MAX_RESEARCH_FILES |
| Types |
PlanApprovalCallback |
ResearchResult, ResearchCodeExample |
| Status |
Was active |
Already disabled |
Knowledge Gaps
- Circular import handling:
research_agent.py:194 has lazy import from agent_config.py - verify no other modules depend on this pattern
- Test coverage: Need to verify no additional tests import from
delegation_tools.py or research_agent.py
- Script dependencies:
preview_tool_panels.py may have additional research references beyond line 390
Deletion Strategy (5 Phases)
Phase 1: Delete Standalone Files
- Delete prompt sections directory
- Delete research renderer
Phase 2: Remove Agent Files
- Delete
delegation_tools.py
- Delete
research_agent.py
Phase 3: Remove Constants & Config
- Remove from
ToolName enum
- Remove from
READ_ONLY_TOOLS
- Remove from settings
- Remove from dispatcher constants
Phase 4: Remove Prompting Template
- Remove
RESEARCH_TEMPLATE definition
- Remove exports from
__init__.py
Phase 5: Update Tests & Docs
- Update test files
- Update documentation
- Update preview script
References
src/tunacode/core/agents/delegation_tools.py - Main tool factory
src/tunacode/core/agents/research_agent.py - Agent creation
src/tunacode/ui/renderers/tools/research.py - UI renderer
memory-bank/research/2026-01-25_limited-read-file-parameter-mismatch.md - Bug that disabled feature
memory-bank/research/2026-01-26_planning-feature-deletion.md - Similar deletion pattern
1---2name: 552-2026-01-26-16-41-59-research-subagent-deletion-1dc753733description: Research - Research Sub-Agent Feature Deletion4---5# Research - Research Sub-Agent Feature Deletion67**Date:** 2026-01-268**Owner:** agent9**Phase:** Research1011## Goal1213Map all components of the `research_codebase` sub-agent feature for clean removal. The feature is already disabled in production (commented out in agent_config.py).1415## Findings1617### Critical Status: ALREADY DISABLED1819The research tool is already commented out in production:2021```python22# src/tunacode/core/agents/agent_components/agent_config.py:37-3923# TODO: Re-enable research_codebase subagent after fixing parameter name mismatch24# See: memory-bank/research/2026-01-25_limited-read-file-parameter-mismatch.md25# from tunacode.core.agents.delegation_tools import create_research_codebase_tool26```2728**Impact**: No active users, no runtime impact, safe to delete.2930---3132## Files to DELETE (7 files)3334### Core Implementation (2 files)3536| File | Lines | Purpose |37|------|-------|---------|38| `src/tunacode/core/agents/delegation_tools.py` | 154 | Tool factory with `create_research_codebase_tool()`, `ResearchResult` TypedDict |39| `src/tunacode/core/agents/research_agent.py` | 249 | Agent factory with `create_research_agent()`, `ProgressTracker`, limited read_file wrapper |4041### UI Renderer (1 file)4243| File | Lines | Purpose |44|------|-------|---------|45| `src/tunacode/ui/renderers/tools/research.py` | 296 | `ResearchRenderer` class, `ResearchData` dataclass, 4-zone panel layout |4647### Prompt Sections (4 files)4849| File | Purpose |50|------|---------|51| `src/tunacode/prompts/research/sections/agent_role.xml` | Research agent role definition |52| `src/tunacode/prompts/research/sections/tool_use.xml` | Tool usage guidelines |53| `src/tunacode/prompts/research/sections/constraints.xml` | Research constraints |54| `src/tunacode/prompts/research/sections/output_format.xml` | Output format spec |5556Also delete the parent directory: `src/tunacode/prompts/research/`5758---5960## Files to MODIFY (17 files)6162### Core Layer (5 files)6364| File | Line(s) | Change |65|------|---------|--------|66| `src/tunacode/core/agents/agent_components/agent_config.py` | 37-39, 423-428 | Remove commented import and tool registration |67| `src/tunacode/core/agents/agent_components/orchestrator/tool_dispatcher.py` | 23, 30 | Remove `RESEARCH_TOOL_NAME` and `TOOL_START_RESEARCH_LABEL` constants |68| `src/tunacode/core/agents/agent_components/agent_helpers.py` | 54 | Remove research case from `get_readable_tool_description()` |69| `src/tunacode/core/prompting/templates.py` | 48-60 | Remove `RESEARCH_TEMPLATE` definition |70| `src/tunacode/core/prompting/__init__.py` | 14, 26 | Remove `RESEARCH_TEMPLATE` import and export |7172### Constants & Config (2 files)7374| File | Line(s) | Change |75|------|---------|--------|76| `src/tunacode/constants.py` | 78, 88 | Remove `RESEARCH_CODEBASE` from `ToolName` enum and `READ_ONLY_TOOLS` |77| `src/tunacode/configuration/settings.py` | 32 | Remove `ToolName.RESEARCH_CODEBASE` from tool list |7879### UI Layer (2 files)8081| File | Line(s) | Change |82|------|---------|--------|83| `src/tunacode/ui/renderers/tools/__init__.py` | 29, 69 | Remove `render_research_codebase` import and `__all__` export |84| `src/tunacode/ui/renderers/panels.py` | 504, 518 | Remove research renderer from registry |8586### Tests (2 files)8788| File | Line(s) | Change |89|------|---------|--------|90| `tests/integration/tools/test_tool_dispatcher_coverage.py` | 30, 62-65, 236 | Remove `RESEARCH_TOOL_NAME` constant and test |91| `tests/integration/core/test_tool_call_lifecycle.py` | 75 | Remove research from filter logic |9293### Scripts (1 file)9495| File | Line(s) | Change |96|------|---------|--------|97| `scripts/preview_tool_panels.py` | 211, 264, 390-396 | Remove research preview builder |9899### Documentation (5 files)100101| File | Section | Change |102|------|---------|--------|103| `docs/codebase-map/modules/core-agents.md` | 102-154 | Remove delegation/research section |104| `docs/codebase-map/modules/core-prompting.md` | 34, 61 | Remove `RESEARCH_TEMPLATE` documentation |105| `docs/codebase-map/modules/ui-overview.md` | 90 | Remove research renderer reference |106| `docs/codebase-map/structure/02-core-directory.md` | 30, 60-64 | Remove research_agent.py mentions |107| `docs/codebase-map/structure/tree-structure.txt` | 63, 160 | Remove research files from tree |108109---110111## Key Patterns / Solutions Found112113### Architecture Layers Affected114115```116┌─────────────────────────────────────────────────┐117│ PROMPTS research/sections/ (4 XML) │ DELETE118├─────────────────────────────────────────────────┤119│ TEMPLATES RESEARCH_TEMPLATE │ REMOVE120├─────────────────────────────────────────────────┤121│ AGENTS delegation_tools.py │ DELETE122│ research_agent.py │ DELETE123├─────────────────────────────────────────────────┤124│ CONSTANTS ToolName.RESEARCH_CODEBASE │ REMOVE125│ READ_ONLY_TOOLS │ REMOVE126├─────────────────────────────────────────────────┤127│ DISPATCHER RESEARCH_TOOL_NAME │ REMOVE128├─────────────────────────────────────────────────┤129│ UI research.py (renderer) │ DELETE130│ panels.py (registry) │ MODIFY131├─────────────────────────────────────────────────┤132│ TESTS dispatcher_coverage.py │ MODIFY133│ tool_call_lifecycle.py │ MODIFY134└─────────────────────────────────────────────────┘135```136137### Comparison to Planning Feature Deletion138139| Layer | Planning (completed) | Research (this task) |140|-------|---------------------|----------------------|141| Tool | `present_plan.py` | `delegation_tools.py` + `research_agent.py` |142| UI | `plan_approval.py` | `research.py` (renderer) |143| Prompts | `present_plan_prompt.xml` | `prompts/research/sections/` (4 files) |144| Constants | `EXIT_PLAN_MODE_SENTINEL` | `RESEARCH_TOOL_NAME`, `MAX_RESEARCH_FILES` |145| Types | `PlanApprovalCallback` | `ResearchResult`, `ResearchCodeExample` |146| Status | Was active | Already disabled |147148---149150## Knowledge Gaps1511521. **Circular import handling**: `research_agent.py:194` has lazy import from `agent_config.py` - verify no other modules depend on this pattern1532. **Test coverage**: Need to verify no additional tests import from `delegation_tools.py` or `research_agent.py`1543. **Script dependencies**: `preview_tool_panels.py` may have additional research references beyond line 390155156---157158## Deletion Strategy (5 Phases)159160### Phase 1: Delete Standalone Files161- Delete prompt sections directory162- Delete research renderer163164### Phase 2: Remove Agent Files165- Delete `delegation_tools.py`166- Delete `research_agent.py`167168### Phase 3: Remove Constants & Config169- Remove from `ToolName` enum170- Remove from `READ_ONLY_TOOLS`171- Remove from settings172- Remove from dispatcher constants173174### Phase 4: Remove Prompting Template175- Remove `RESEARCH_TEMPLATE` definition176- Remove exports from `__init__.py`177178### Phase 5: Update Tests & Docs179- Update test files180- Update documentation181- Update preview script182183---184185## References186187- `src/tunacode/core/agents/delegation_tools.py` - Main tool factory188- `src/tunacode/core/agents/research_agent.py` - Agent creation189- `src/tunacode/ui/renderers/tools/research.py` - UI renderer190- `memory-bank/research/2026-01-25_limited-read-file-parameter-mismatch.md` - Bug that disabled feature191- `memory-bank/research/2026-01-26_planning-feature-deletion.md` - Similar deletion pattern