🤖 refactor: strengthen exec sub-agent prompt guidance#2061
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Strengthens the Exec sub-agent-only prompt to encourage Explore-first indexing/discovery (to preserve context window) and to more strongly remind sub-agents to call
agent_reportexactly once.Implementation
subagent.append_promptinsrc/node/builtinAgents/exec.mdto explicitly frame Explore as the code indexer and to add a strongeragent_reportreminder.docs/agents/index.mdxin sync with the updatedexec.mdcontent.Validation
make static-check📋 Implementation Plan
Plan: Strengthen Exec sub-agent prompt (Explore-first + agent_report)
Context / Why
The built-in Exec agent prompt should be updated only when Exec is launched as a sub-agent (child workspace) to:
agent_reportexactly once when the tool is available, to avoid the system fallback message:Your stream ended without calling agent_report. Call agent_report exactly once now with your final report.Evidence
src/node/builtinAgents/exec.mdsubagent.append_promptblock (only appended for sub-agent workspaces).exploretasks and callingagent_report, but can be made more explicit about indexing/discovery/planning and preserving context window.src/node/services/aiService.tsconst isSubagentWorkspace = Boolean(metadata.parentWorkspaceId);subagent.append_promptonly whenisSubagentWorkspaceis true.docs/agents/index.mdxexec.mdcontent; should be kept consistent after edits.src/node/services/agentDefinitions/builtInAgentDefinitions.test.tsappend_promptcontains specific substrings; our change should preserve them.Implementation details
1) Update Exec sub-agent-only prompt (recommended)
File:
src/node/builtinAgents/exec.mdEdit the YAML frontmatter
subagent.append_prompt(the|block) to add a short, explicit directive that:exploretasks as the sub-agent’s code indexer (paths/symbols/callsites/tests/patterns).exploretasks for discovery + mini-planning before editing.agent_reportis called.Suggested shape (exact wording can be tweaked, but keep it short):
subagent: append_prompt: | You are running as a sub-agent in a child workspace. - Take a single narrowly scoped task and complete it end-to-end. Do not expand scope. - Preserve your context window: use `explore` tasks as your code indexer for code indexing + discovery. If you need repo context, spawn 1–N `explore` tasks (read-only) to locate paths/symbols/callsites/tests and confirm patterns, then sketch a short internal "mini-plan" before editing. If starting points + acceptance are already clear, skip the initial explore pass and only explore when blocked. Prefer 1–3 narrow explore tasks (possibly in parallel) and prefer outputs with paths + symbols + minimal excerpts. - **Before your stream ends, you MUST call `agent_report` exactly once.** (If you forget, the parent will inject a follow-up message and you’ll waste tokens.) - When you have a final answer, call agent_report exactly once with: ...Notes:
subagent.append_promptis appended only in child workspaces.agent_reportis only available in sub-agent workspaces; keep the strengthened reminder insidesubagent.append_promptto avoid confusing top-level Exec runs.2) Keep docs in sync
File:
docs/agents/index.mdxUpdate the inline
exec.mdsnippet under the “### Exec” accordion to match the updatedsubagent.append_prompttext.Verification
bun test src/node/services/agentDefinitions/builtInAgentDefinitions.test.tsNet LoC estimate (product code)
src/node/builtinAgents/exec.md: ~+6–12 LoC (text only)docs/agents/index.mdx: ~+6–12 LoC (text only)No TypeScript/runtime logic changes expected.
Generated with
mux• Model: openai:gpt-5.2 • Thinking: xhigh • Cost:$1.53