feat(agents): expand subagent delegation guidance in AGENTS.md seed#656
Merged
Conversation
The init wizard seeds an AGENTS.md "Subagent Delegation" section that tells the frontline LLM when to delegate to spawn_agent. The current guidance sets the bar too high — "deep web research requiring multiple searches and synthesis" as the threshold excludes the bulk of research tasks that would benefit from delegation. Live smoke testing earlier in the sub-agent work confirmed this: Qwen performed ~50k tokens of in-process research on a clearly delegable task because the guidance didn't reach the delegation trigger. Rewrite the section end to end, applying the proposal from #522 verbatim with two adjacent additions: 1. A context-window-protection bullet in "When to delegate". Delegation's biggest structural benefit isn't specialization or parallelism — it's keeping raw file/web content out of the main session's context window. The existing guidance never said that out loud. 2. A new "Per-call specialization" paragraph introducing the optional `context` argument that shipped in the single-file format work (#647 / #652). The discovery context layer advertises it, but AGENTS.md was still telling the model to call spawn_agent with only agent + task. The expanded "When to delegate" list lowers the bar to: - Research requiring 2+ sources or multiple searches (was: "deep research") - Parallelizable tasks (multiple independent queries concurrently) - Work that would otherwise pull large content into this session's context - Background prep work that doesn't block immediate response - Code analysis on large files or multiple files - Summarization of long documents or web pages - Preliminary passes on topics before diving deep The expanded "When NOT to delegate" list adds: - Tasks where coordination overhead outweighs parallelization benefits Adds a parallelization tip pointing out that independent topics should be spawned as concurrent subagents, not serialized. Note: this update affects the init-wizard seed template, so new installs pick it up on `netclaw init`. Existing users' AGENTS.md files are not mutated automatically — operators who want the new guidance should copy the new block into their `~/.netclaw/identity/AGENTS.md` manually. Closes #522
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
The init wizard seeds an
AGENTS.md"Subagent Delegation" section that tells the frontline LLM when to delegate tospawn_agent. The current guidance sets the bar too high — "deep web research requiring multiple searches and synthesis" as the threshold excludes the bulk of research tasks that would benefit from delegation. Live smoke testing earlier in the sub-agent work confirmed this: Qwen performed ~50k tokens of in-process research on a clearly delegable task because the guidance never reached the delegation trigger.This PR rewrites the section end to end, applying the proposal from #522 verbatim with two adjacent additions I think close a gap in the original proposal:
research-assistantwould have returned a 1KB cited summary).contextargument that shipped in feat(subagents): single-file markdown format + contextual prompt + project-scoped discovery #647 / feat(subagents): single-file markdown format with contextual prompt #652. The discovery context layer advertises it, butAGENTS.mdwas still telling the model to callspawn_agentwith onlyagent+task.Expanded "When to delegate" list
Expanded "When NOT to delegate" list
web_searchdirectly)Per-call specialization paragraph (new)
Teaches the model that
spawn_agenttakes an optionalcontextargument for per-invocation background — workspace details, the user's broader goal, facts the subagent would otherwise have to rediscover — and explicitly warns against duplicating the agent's built-in instructions in it. The runtime side of this shipped in #647 / #652 but the AGENTS.md text was stale.Scope notes
src/Netclaw.Cli/Tui/Wizard/Steps/IdentityStepViewModel.cs:205-239. New installs pick it up vianetclaw init. Existing users'~/.netclaw/identity/AGENTS.mdfiles are not mutated automatically — operators who want the new guidance should copy the new block into their identity file manually.WorkingContext.csin detail, SubAgentActor: tool file paths don't contribute to parent session WorkingContext #600 was closed asnot planned— the proposed mechanism would misrepresent the parent's actual file awareness (RecentFiles carries an implicit "contents are fresh in my mind" semantic that a subagent-read file doesn't satisfy), and the preservation concern it raised is already handled by the conversation history and the structured findings pipeline (Add structured findings envelopes to SubAgentResult and parent-session acceptance flow #183 / checkpoint heuristics). This PR ships alone.ToolIndexUpdater.UpdateSubAgentDiscovery()was enriched in feat(subagents): single-file markdown format with contextual prompt #652 to include per-agent description, tool lists, and acontext-aware example call, so the runtime-side discovery block and the static AGENTS.md guidance are now consistent.Test plan
dotnet build src/Netclaw.Cli/Netclaw.Cli.csproj— cleandotnet slopwatch analyze— 0 issuesspawn_agentorganically (this is follow-up validation, not a blocker for merge)Related issues