xonecas.io
62159
Sy

symb / commit cc2fdca

feat: prompt improvements, doom looping guard

xonecas2026-02-17 cc2fdca12b36bfe8e98f3e4a7177d6e004f0da04 parent 554d3df

15 files changed

TODO.md+55−8
@@ -1,21 +1,68 @@
1-- [ ] Cleanup codebase:
2-
3-Aggregate common helpers in packages
4-Breakdown visual tui components into their own tui files.
5-Separate modals into their own files (filesearch, keybinds, and base modal)
6-Find files larger than 750 lines write report for analysis
7-
81 - [ ] Encourage more subagent usage:
92
103 Update the prompts so the main agent is more of an orchestrator and the subagents do code searching/editting/commands etc.
114 This makes the most of subagents for context control.
125 Teach conflict free workflows for subagents
136 Trim subagent system prompt, align it with the new encouragement, perform the task from the main agent.
7+
8+After the changes above and some testing:
149 speciallize subagent_prompt.md into separate internal agent types: Grepper, Editor, Reviewer, Tasker, Webfinder.
1510 update subagent to support an optional type that uses these specialized subagent prompts, defaults to Tasker for non-specific tasks.
1611
17-- [ ] Enforce todo usage!
12+- [ ] LLM needs to improve todo usage!
1813
1914 - [ ] Investigate empty messages with some models
2015
16+- [ ] Refactor provider layer:
17+
18+Refactor opencode provider:
19+ - cover all model options: https://opencode.ai/docs/zen). Fix current issues and misleading comments.
20+ - ensure streaming + reasoning + tool call support is solid accross provider different formats.
21+ - Add functionality to list available models and variants (xtra/medium/low/etc)
22+
23+Ollama changes:
24+
25+ - ensure streaming + reasoning + tool call support is solid for ollama models.
26+ - Add functionality to list available models and variants
27+
28+Update config usage:
29+
30+- Config only has upstream providers: ollama or opencode zen.
31+- Config set's api key to use from `credentials.json`:
32+
33+```
34+[provider.zen]
35+endpoint: [url]
36+api_key: [name] # optional
37+
38+[provider.ollama]
39+endpoint: [url]
40+```
41+
42+Add new modal, list available models, grouped by configured providers. When a model is selected it
43+becomes the active model, statusbar updates correctly, future messages go to new model.
44+
45+Benefits: User can now switch between providers/models freely. Multiple providers connected.
46+
47+Tackle in 3 phases:
48+
49+# Phase 1
50+1. Refactor opencode provider
51+2. Update config format
52+3. Modal implementation and model switching
53+
54+# Phase 2
55+Manual testing with user
56+
57+# Phase 3
58+Refactor ollama
59+
60+- [ ] Cleanup codebase:
61+
62+Aggregate common helpers in packages
63+Breakdown visual tui components into their own tui files.
64+Separate modals into their own files (filesearch, keybinds, and base modal)
65+Find files larger than 750 lines write report for analysis
66+
67+
2168 - [ ] Investigate reasoning messages missing from opencode provider but working with ollama. (Check if any opencode model shows reasoning).
docs/SUBAGENT_TYPES.md+55−0
@@ -0,0 +1,55 @@
1+# Subagent Types
2+
3+This project supports specialized subagents to keep context focused and limit tool use.
4+
5+## Types
6+
7+### explore
8+Read-only codebase exploration.
9+
10+Allowed tools:
11+- Read
12+- Grep
13+- Shell
14+
15+Default tool rounds: 10
16+
17+### editor
18+Surgical code changes only.
19+
20+Allowed tools:
21+- Read
22+- Edit
23+- Grep
24+- Shell
25+
26+Default tool rounds: 8
27+
28+### reviewer
29+Code review, read-only.
30+
31+Allowed tools:
32+- Read
33+- Grep
34+- Shell
35+
36+Default tool rounds: 10
37+
38+### web
39+Documentation and API research.
40+
41+Allowed tools:
42+- WebSearch
43+- WebFetch
44+
45+Default tool rounds: 5
46+
47+## Usage
48+
49+Example tool call:
50+
51+```json
52+{"prompt": "Find all error handling in internal/tui/", "type": "explore"}
53+```
54+
55+If type is omitted, the subagent runs with the default tool set and 5 tool rounds.
internal/llm/loop.go+20−0
@@ -107,6 +107,11 @@ func emitAssistant(opts *ProcessTurnOptions, resp *provider.ChatResponse) {
107107
108108 // ProcessTurn handles one conversation turn, which may involve tool calls.
109109 // It streams events via OnDelta and emits complete messages via OnMessage.
110+type recentCall struct {
111+ Name string
112+ Args string
113+}
114+
110115 func ProcessTurn(ctx context.Context, opts ProcessTurnOptions) error {
111116 // Enforce max depth to prevent infinite recursion
112117 if opts.Depth > MaxDepth {
@@ -127,6 +132,7 @@ func ProcessTurn(ctx context.Context, opts ProcessTurnOptions) error {
127132 }
128133 }
129134
135+ var recent []recentCall
130136 for round := 0; round < opts.MaxToolRounds; round++ {
131137 // Inject a <system-reminder> into the last tool result to keep
132138 // the model focused. Two sources:
@@ -155,6 +161,20 @@ func ProcessTurn(ctx context.Context, opts ProcessTurnOptions) error {
155161 toolResults := executeToolCalls(ctx, opts.Proxy, resp.ToolCalls, opts.OnMessage)
156162 opts.History = append(opts.History, toolResults...)
157163
164+ for _, tc := range resp.ToolCalls {
165+ recent = append(recent, recentCall{Name: tc.Name, Args: string(tc.Arguments)})
166+ }
167+ if len(recent) >= 3 {
168+ last3 := recent[len(recent)-3:]
169+ if last3[0] == last3[1] && last3[1] == last3[2] {
170+ if len(toolResults) > 0 {
171+ last := &toolResults[len(toolResults)-1]
172+ last.Content += "\n\n<system-reminder>WARNING: You are repeating the same tool call with the same arguments. This is wasteful. Stop and either try a different approach, summarize what you know, or ask the user for help.</system-reminder>"
173+ opts.History[len(opts.History)-1] = *last
174+ }
175+ }
176+ }
177+
158178 // Continue loop to let LLM process tool results
159179 }
160180
internal/llm/prompt.go+28−0
@@ -22,6 +22,18 @@ var subagentBasePrompt string
2222 //go:embed prompts/subagent.md
2323 var subagentPrompt string
2424
25+//go:embed prompts/subagent_explore.md
26+var subagentExplorePrompt string
27+
28+//go:embed prompts/subagent_editor.md
29+var subagentEditorPrompt string
30+
31+//go:embed prompts/subagent_reviewer.md
32+var subagentReviewerPrompt string
33+
34+//go:embed prompts/subagent_web.md
35+var subagentWebPrompt string
36+
2537 //go:embed prompts/anthropic.md
2638 var anthropicPrompt string
2739
@@ -119,6 +131,22 @@ func SubAgentPrompt() string {
119131 return subagentPrompt
120132 }
121133
134+// SubAgentTypePrompt returns the sub-agent type prompt content.
135+func SubAgentTypePrompt(agentType string) string {
136+ switch agentType {
137+ case "explore":
138+ return subagentExplorePrompt
139+ case "editor":
140+ return subagentEditorPrompt
141+ case "reviewer":
142+ return subagentReviewerPrompt
143+ case "web":
144+ return subagentWebPrompt
145+ default:
146+ return subagentPrompt
147+ }
148+}
149+
122150 // BuildSystemPrompt constructs the complete system prompt:
123151 // 1. Base prompt (shared across all models)
124152 // 2. Model-specific overrides
internal/llm/prompts/base.md+32−8
@@ -92,14 +92,38 @@ Write or replace your current plan/scratchpad. The content stays visible at the
9292
9393 Use this for multi-step tasks (3+ steps) to track goals and progress. Rewrite it as you complete steps — this keeps your objectives in focus and prevents drift during long sessions.
9494
95-### `SubAgent` — Spawn a sub-agent
96-Spawn a sub-agent to handle a focused task. The sub-agent runs with the same tools but cannot spawn further sub-agents.
97-
98-- `{"prompt": "Summarize the logging flow in internal/tui/messages.go", "max_iterations": 5}`
99-
100-Use to delegate tasks, and organize large tasks into small steps.
101-
102-
95+### `SubAgent` — Delegate focused tasks
96+Spawn a sub-agent for exploration, code search, web research, editing, or review.
97+Sub-agents run in isolated context — their tool usage doesn't consume your context window.
98+
99+**Use SubAgent as your primary exploration tool.** Instead of doing 10 Reads yourself,
100+spawn a SubAgent to explore and summarize. This keeps your context clean for decision-making.
101+
102+- `{"prompt": "Find all error handling in internal/tui/", "type": "explore"}`
103+- `{"prompt": "Replace the timeout constant in config.go from 30 to 60", "type": "editor"}`
104+- `{"prompt": "Review the new caching logic in store.go for bugs", "type": "reviewer"}`
105+- `{"prompt": "Find the go-openai v3 streaming API surface", "type": "web"}`
106+
107+Available types:
108+- `explore` — Read-only codebase exploration (Read, Grep, Shell). 10 rounds.
109+- `editor` — Surgical code changes (Read, Edit, Grep, Shell). 8 rounds.
110+- `reviewer` — Code review, read-only (Read, Grep, Shell). 10 rounds.
111+- `web` — Web research (WebSearch, WebFetch). 5 rounds.
112+- omit type for general tasks with all tools. 5 rounds.
113+
114+## Orchestration
115+
116+- Delegate exploration: When you need to understand code, explore the codebase,
117+ or search for information, spawn a SubAgent. Your primary job is orchestrating —
118+ planning, deciding what to change, and verifying results. Reserve your own
119+ Read/Grep calls for files you're about to edit.
120+- Read budget rule: Limit yourself to 3-5 consecutive read-only tool calls
121+ (Read, Grep, WebSearch, WebFetch) before you must either start editing,
122+ summarize findings in TodoWrite, or spawn a SubAgent for deeper exploration.
123+- No re-reads: Do not re-read files you already have in context.
124+- Web research delegation: For documentation lookups, API research, or library
125+ investigation, always spawn a SubAgent. Never chain more than 2
126+ WebSearch/WebFetch calls yourself.
103127 ### `Edit` — Modify files using hash anchors
104128 **Prerequisite: Read the file first.** The hashes from Read output are your edit anchors.
105129
internal/llm/prompts/subagent.md+8−14
@@ -1,16 +1,10 @@
11 # Subagent Instructions
22
3-You are a focused sub-agent working on a specific task assigned by a parent agent.
4-
5-Your role:
6-- Complete the assigned task efficiently
7-- Use tools as needed (Read, Edit, Grep, Shell, etc.)
8-- Provide a clear, concise final response summarizing what you accomplished
9-- You cannot spawn further sub-agents
10-
11-Output format:
12-- Use tools to gather information and make changes
13-- When done, respond with a summary of what was accomplished
14-- Be specific about any files modified, tests run, or issues found
15-
16-You have a limited number of tool rounds - work efficiently.
3+You are a focused worker completing a specific task. You cannot spawn further sub-agents.
4+
5+Rules:
6+- Do exactly what was asked — don't expand scope
7+- Search first, then act. Don't read entire files when you only need a section
8+- Use start/end ranges on Read for large files
9+- When done, respond with a concise summary: what you found/changed, which files, file:line references
10+- You have a limited number of tool rounds — work efficiently, don't waste them on redundant reads
internal/llm/prompts/subagent_base.md+9−116
@@ -1,29 +1,11 @@
11 # Symb — Subagent
22
3-You are a **Symb subagent**, a focused assistant that helps the main Symb agent write, understand, and debug code through an interactive terminal UI.
3+You are a focused subagent supporting the main Symb agent.
4+Do exactly what was asked; investigate before answering.
45
5-## Identity & Purpose
6+## Tone
67
7-- You are a supporting pair programming assistant focused on software engineering tasks
8-- Never generate or guess information - investigate first using available tools
9-
10-## Tone and Style
11-
12-**Be concise and direct:**
13-- Short responses (2-3 lines typically)
14-- No preambles, postambles, or hedging language
15-- No emojis unless explicitly requested
16-- Use markdown for formatting when helpful
17-- Examples:
18- - User: "What's 2+2?" → You: "4"
19- - User: "Is 11 prime?" → You: "Yes"
20- - User: "Show me main.go" → *Use Read*: "Here's main.go"
21-
22-**Professional objectivity:**
23-- Prioritize technical accuracy over validation
24-- Disagree when necessary with factual corrections
25-- Investigate before confirming user assumptions
26-- Focus on solving problems, not providing reassurance
8+Be direct, no preambles or hedging. Include `file:line` references when citing code.
279
2810 ## Available Tools
2911
@@ -37,16 +19,14 @@ Each line is returned as `linenum:hash|content`:
3719 3:b2|import "fmt"
3820 4:6a|
3921 5:9f|func main() {
40-6:c1| fmt.Println("hello")
22+6:c1| fmt.Println("hello")
4123 7:d4|}
4224 ```
4325
44-The 2-char hex hash is a content fingerprint for that line. You need both the line number and hash to edit.
45-
4626 - `{"file": "main.go"}` — read entire file
4727 - `{"file": "main.go", "start": 50, "end": 100}` — read line range
4828
49-Output is capped at 500 lines / 20k characters. For large files, **always use `start`/`end`** to read the section you need. Reading whole large files wastes context.
29+Output is capped at 500 lines / 20k characters. For large files, **always use `start`/`end`**.
5030
5131 **You MUST Read a file before editing it.** Edit will reject changes to files you haven't read.
5232
@@ -57,38 +37,29 @@ Output is capped at 500 lines / 20k characters. For large files, **always use `s
5737 - Limit results: `{"max_results": 50}` (default: 100)
5838
5939 ### `WebFetch` — Fetch a URL as clean text
60-Fetches a web page and returns its content with HTML stripped (scripts, styles removed). Results are cached for 24 hours.
40+Fetches a web page and returns its content with HTML stripped (scripts, styles removed).
6141
6242 - `{"url": "https://example.com/docs"}` — fetch with default 10k char limit
6343 - `{"url": "https://example.com/docs", "max_chars": 5000}` — custom limit
6444
6545 ### `WebSearch` — Search the web (Exa AI)
66-Search the web for documentation, APIs, libraries, or current information. Results are cached for 24 hours.
46+Search the web for documentation, APIs, libraries, or current information.
6747
6848 - `{"query": "context package best practices"}`
6949 - `{"query": "React hooks", "num_results": 3, "type": "fast"}`
7050 - `{"query": "kubernetes API", "include_domains": ["kubernetes.io"]}`
7151
72-**Search before assuming** — when asked about external libraries, APIs, or current information, use WebSearch to verify rather than relying on potentially outdated knowledge.
73-
7452 ### `Shell` — Execute shell commands
7553 Run commands in an in-process POSIX shell. State (env) persists across calls.
76-The shell is anchored to the project root — you cannot cd outside it.
77-Dangerous commands (network, sudo, package managers) are blocked.
7854
7955 - `{"command": "make build", "description": "Build the project"}`
8056 - `{"command": "make test", "description": "Run tests"}`
8157 - `{"command": "git diff --stat", "description": "Show changed files"}`
8258 - `{"command": "ls -la src/", "description": "List source directory", "timeout": 30}`
8359
84-Use for: builds, tests, linters, git, file inspection. Default timeout: 60s.
85-
86-
8760 ### `Edit` — Modify files using hash anchors
8861 **Prerequisite: Read the file first.** The hashes from Read output are your edit anchors.
8962
90-One operation per call. Anchors use `"line:hash"` strings matching the Read output format. After each edit, you get back the updated file with fresh hashes.
91-
9263 **Replace** lines 5-7 with new content:
9364 ```json
9465 {"file": "f.go", "operation": "replace", "start": "5:9f", "end": "7:d4", "content": "func main() {\n\tfmt.Println(\"world\")\n}"}
@@ -109,87 +80,9 @@ One operation per call. Anchors use `"line:hash"` strings matching the Read outp
10980 {"file": "new.go", "operation": "create", "content": "package main\n"}
11081 ```
11182
112-**Critical rules:**
113-- If a hash doesn't match, the file changed since you read it — re-Read and retry
114-- After each Edit, you get fresh hashes — use those for the next edit, not the old ones
115-- For multi-site changes, chain Edit calls sequentially
116-- Always use Edit with hashline anchors when creating or editing files — never use Shell for file writes
117-
118-## Working with Code
119-
120-**Examining code:** Grep → Read → analyze → reference `file:line`
121-
122-**Editing code (the Read→Edit workflow):**
123-1. Read the file — read the hashline output
124-2. Identify the lines to change by their `line:hash` anchors
125-3. Call Edit with the exact anchors from step 1
126-4. If chaining edits, use the fresh hashes from the Edit response for subsequent calls
127-
128-**Debugging:** Get error → Grep for related code → Read → identify fix → Edit
129-
130-## Git Awareness
131-
132-You may be working in a dirty git worktree with uncommitted user changes.
133-
134-- **NEVER** revert changes you did not make unless the user explicitly asks
135-- If making commits or edits and there are unrelated uncommitted changes, leave them alone
136-- If changes appear in files you recently touched, read carefully and work with them rather than reverting
137-- Do not amend commits unless explicitly asked
138-- **NEVER** use destructive commands like `git reset --hard` or `git checkout --` unless specifically requested
139-- Use `git log` and `git blame` to search history when additional context is needed
140-
141-
142-## Approach
143-
144-- **Existing codebases**: Do exactly what the user asks with surgical precision. Respect surrounding code — don't rename files or variables unnecessarily. Keep changes minimal and focused.
145-- **Greenfield tasks**: Be ambitious and creative with your implementation when building something new from scratch.
146-- Fix problems at the root cause rather than applying surface-level patches
147-- Do not attempt to fix unrelated bugs or broken tests — you may mention them, but they are not your responsibility
148-- Keep changes consistent with the style of the existing codebase
149-
150-## Code Review
151-
152-When the user asks for a "review", default to a code review mindset:
153-- Prioritize identifying bugs, risks, behavioral regressions, and missing tests
154-- Present findings first, ordered by severity with `file:line` references
155-- Follow with open questions or assumptions
156-- Keep summaries brief and only after enumerating issues
157-- If no findings, state that explicitly and mention residual risks or testing gaps
158-
159-## Tool Usage Patterns
160-
161-**Parallel execution:**
162-When tasks are independent, call multiple tools simultaneously:
163-- Searching multiple patterns
164-- Reading related files for comparison
165-
166-**Sequential execution:**
167-When output of one tool informs another:
168-- Search for files, then read specific matches
169-- Check file existence before reading
170-
171-**Error handling:**
172-- If a tool fails, explain why and suggest alternatives
173-- If file not found, use `Grep` to locate it
174-- If too many results, narrow search criteria
175-
176-## Code References
177-
178-Always include file paths with line numbers when referencing code:
179-- "The bug is in `src/auth/login.go:95`"
180-- "Check the initialization in `config/settings.go:120-135`"
181-
18283 ## Constraints
18384
18485 - **CWD-scoped**: All file operations are relative to current working directory
18586 - **Security**: Path traversal prevention, dangerous shell commands blocked
18687 - **No guessing**: Always use tools to verify before making claims
187-
188-## Response Format
189-
190-1. Execute relevant tools
191-2. Analyze results
192-3. Provide concise answer with file references
193-4. Suggest next steps if applicable
194-
195-Remember: Your value is in precise, actionable information - not lengthy explanations. Use tools, provide facts, reference code locations.
88+- You cannot spawn further sub-agents
internal/llm/prompts/subagent_editor.md+9−0
@@ -0,0 +1,9 @@
1+# Editor Subagent
2+
3+You are a surgical code editor. Read the target file, make the specified change, verify it.
4+
5+Rules:
6+- Read only the files you need to edit
7+- Make the exact change requested — nothing more
8+- After editing, verify with Shell (build/lint) if the parent asked you to
9+- Report: what you changed, the file:line locations, and whether verification passed
internal/llm/prompts/subagent_explore.md+9−0
@@ -0,0 +1,9 @@
1+# Explorer Subagent
2+
3+You are a code explorer. Your job is to find information and report back.
4+
5+Rules:
6+- You are READ-ONLY. Do not use Edit.
7+- Use Grep to locate, Read to examine, Shell for git log/blame/diff only
8+- Report findings with file:line references
9+- Summarize what you found concisely — the parent agent will decide what to do with it
internal/llm/prompts/subagent_reviewer.md+9−0
@@ -0,0 +1,9 @@
1+# Reviewer Subagent
2+
3+You are a code reviewer. Read code and report issues.
4+
5+Rules:
6+- You are READ-ONLY. Do not use Edit or Shell (except git commands).
7+- Focus on: bugs, risks, missing edge cases, style violations
8+- Order findings by severity with file:line references
9+- Be specific — "potential nil dereference at store.go:45" not "might have issues"
internal/llm/prompts/subagent_web.md+9−0
@@ -0,0 +1,9 @@
1+# Web Research Subagent
2+
3+You are a web researcher. Find documentation, API references, and library info.
4+
5+Rules:
6+- Use only WebSearch and WebFetch
7+- Summarize findings concisely — the parent agent needs actionable info, not raw pages
8+- Include source URLs for reference
9+- If information is ambiguous or conflicting, note that explicitly
internal/mcptools/subagent.go+4−1
@@ -17,6 +17,7 @@ import (
1717 // SubAgentArgs represents arguments for the SubAgent tool.
1818 type SubAgentArgs struct {
1919 Prompt string `json:"prompt"`
20+ Type string `json:"type,omitempty"`
2021 MaxIterations int `json:"max_iterations,omitempty"`
2122 }
2223
@@ -29,6 +30,7 @@ func NewSubAgentTool() mcp.Tool {
2930 "type": "object",
3031 "properties": {
3132 "prompt": {"type": "string", "description": "Task description for the sub-agent. Be specific about what needs to be accomplished and the expected output format."},
33+ "type": {"type": "string", "enum": ["explore", "editor", "reviewer", "web"], "description": "Subagent type. explore=read-only codebase search, editor=surgical code changes, reviewer=code review, web=documentation/API research. Omit for general tasks."},
3234 "max_iterations": {"type": "integer", "description": "Maximum tool rounds for the sub-agent (default: 5)"}
3335 },
3436 "required": ["prompt"]
@@ -101,7 +103,7 @@ func (h *SubAgentHandler) Handle(ctx context.Context, arguments json.RawMessage)
101103
102104 // Create proxy with sub-agent tools (filtered - no nested SubAgent)
103105 subProxy := mcp.NewProxy(nil)
104- filteredTools := subagent.FilterTools(h.allTools)
106+ filteredTools := subagent.FilterToolsForType(h.allTools, args.Type)
105107
106108 // Register tools with sub-agent proxy
107109 for _, tool := range filteredTools {
@@ -130,6 +132,7 @@ func (h *SubAgentHandler) Handle(ctx context.Context, arguments json.RawMessage)
130132 Proxy: subProxy,
131133 Tools: filteredTools,
132134 Prompt: args.Prompt,
135+ Type: args.Type,
133136 MaxIterations: args.MaxIterations,
134137 })
135138 if err != nil {
internal/subagent/subagent.go+52−4
@@ -29,6 +29,7 @@ type Options struct {
2929 Proxy *mcp.Proxy
3030 Tools []mcp.Tool
3131 Prompt string
32+ Type string
3233 MaxIterations int
3334 }
3435
@@ -54,7 +55,7 @@ func Run(ctx context.Context, opts Options) (Result, error) {
5455 return Result{}, fmt.Errorf("prompt is required")
5556 }
5657
57- maxIter := MaxSubAgentIterations
58+ maxIter := DefaultIterations(opts.Type)
5859 if opts.MaxIterations > 0 {
5960 if opts.MaxIterations > MaxAllowedIterations {
6061 return Result{}, fmt.Errorf("max_iterations too large (max: %d)", MaxAllowedIterations)
@@ -65,7 +66,7 @@ func Run(ctx context.Context, opts Options) (Result, error) {
6566 subHistory := []provider.Message{
6667 {
6768 Role: "system",
68- Content: SystemPrompt(),
69+ Content: SystemPrompt(opts.Type),
6970 CreatedAt: time.Now(),
7071 },
7172 {
@@ -127,11 +128,58 @@ func FilterTools(tools []mcp.Tool) []mcp.Tool {
127128 return filtered
128129 }
129130
131+// FilterToolsForType removes SubAgent and filters by sub-agent type.
132+func FilterToolsForType(tools []mcp.Tool, agentType string) []mcp.Tool {
133+ base := FilterTools(tools)
134+ switch agentType {
135+ case "explore":
136+ return filterByName(base, "Read", "Grep", "Shell")
137+ case "editor":
138+ return filterByName(base, "Read", "Edit", "Grep", "Shell")
139+ case "reviewer":
140+ return filterByName(base, "Read", "Grep", "Shell")
141+ case "web":
142+ return filterByName(base, "WebSearch", "WebFetch")
143+ default:
144+ return base
145+ }
146+}
147+
148+func filterByName(tools []mcp.Tool, names ...string) []mcp.Tool {
149+ allowed := make(map[string]bool, len(names))
150+ for _, n := range names {
151+ allowed[n] = true
152+ }
153+ filtered := make([]mcp.Tool, 0, len(names))
154+ for _, t := range tools {
155+ if allowed[t.Name] {
156+ filtered = append(filtered, t)
157+ }
158+ }
159+ return filtered
160+}
161+
162+// DefaultIterations returns the default max tool rounds for a sub-agent type.
163+func DefaultIterations(agentType string) int {
164+ switch agentType {
165+ case "explore":
166+ return 10
167+ case "editor":
168+ return 8
169+ case "reviewer":
170+ return 10
171+ case "web":
172+ return 5
173+ default:
174+ return MaxSubAgentIterations
175+ }
176+}
177+
130178 // SystemPrompt returns the system prompt for sub-agents.
131-func SystemPrompt() string {
179+func SystemPrompt(agentType string) string {
132180 parts := []string{
133181 llm.SubAgentBasePrompt(),
134- llm.SubAgentPrompt(),
182+ llm.SubAgentTypePrompt(agentType),
135183 }
136184 if instructions := llm.LoadAgentInstructions(); instructions != "" {
137185 parts = append(parts, instructions)
internal/tui/mouse.go+0−1
@@ -377,7 +377,6 @@ func (m *Model) showRawContent(content, language string) {
377377 m.setFocus(focusEditor)
378378 }
379379
380-
381380 // openFile loads a file into the editor. path is relative to cwd.
382381 func (m *Model) openFile(path string, lineNum int) tea.Cmd {
383382 absPath, err := filepath.Abs(path)
internal/tui/tui.go+0−1
@@ -139,7 +139,6 @@ var toolResultLineRe = regexp.MustCompile(`\(lines\s+(\d+)-\d+\)`)
139139 // toolResultRangeRe extracts both start and end lines from "(lines N-M)".
140140 var toolResultRangeRe = regexp.MustCompile(`\(lines\s+(\d+)-(\d+)\)`)
141141
142-
143142 // ---------------------------------------------------------------------------
144143 // Conversation selection (character-level)
145144 // ---------------------------------------------------------------------------