Skip to content

feat(agents): expand subagent delegation guidance in AGENTS.md seed#656

Merged
Aaronontheweb merged 3 commits into
devfrom
feat/expand-subagent-delegation-guidance
Apr 14, 2026
Merged

feat(agents): expand subagent delegation guidance in AGENTS.md seed#656
Aaronontheweb merged 3 commits into
devfrom
feat/expand-subagent-delegation-guidance

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Collaborator

Summary

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 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:

  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, and Phase 0.2 smoke testing showed it's the real problem (Qwen burned ~15k tokens reading GitHub HTML into its own context when research-assistant would have returned a 1KB cited summary).
  2. A new "Per-call specialization" paragraph introducing the optional context argument 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, but AGENTS.md was still telling the model to call spawn_agent with only agent + task.

Expanded "When to delegate" list

  • Research requiring 2+ sources or multiple searches (was: "deep research requiring multiple searches and synthesis")
  • Parallelizable tasks (multiple independent queries can run concurrently)
  • Any work that would otherwise pull large files or web pages into this session's context — the subagent reads them, you get the synthesis (new)
  • 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

Expanded "When NOT to delegate" list

  • Simple single searches (use web_search directly)
  • Tasks requiring MCP tools
  • Interactive browser tasks
  • Tasks where coordination overhead outweighs parallelization benefits (new)

Per-call specialization paragraph (new)

Teaches the model that spawn_agent takes an optional context argument 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

Test plan

  • dotnet build src/Netclaw.Cli/Netclaw.Cli.csproj — clean
  • dotnet slopwatch analyze — 0 issues
  • Reviewed the rendered raw-string output by reading the file back at lines 205-239 — indentation matches surrounding block, markdown renders correctly
  • Live delegation retest post-merge — rerun the Phase 0.2 smoke prompt against a fresh install with the new seed and see whether Qwen now reaches for spawn_agent organically (this is follow-up validation, not a blocker for merge)

Related issues

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
@Aaronontheweb Aaronontheweb added enhancement New feature or request sessions LLM session actor, turn lifecycle, pipelines labels Apr 14, 2026
@Aaronontheweb Aaronontheweb enabled auto-merge (squash) April 14, 2026 03:20
@Aaronontheweb Aaronontheweb added the subagents spawn_agent, SubAgentActor, definition loader, discovery context layer, and related features label Apr 14, 2026
@Aaronontheweb Aaronontheweb merged commit a57c26b into dev Apr 14, 2026
4 checks passed
@Aaronontheweb Aaronontheweb deleted the feat/expand-subagent-delegation-guidance branch April 14, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request sessions LLM session actor, turn lifecycle, pipelines subagents spawn_agent, SubAgentActor, definition loader, discovery context layer, and related features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand subagent delegation guidance

1 participant