Skip to content

fix(delegate): reduce subagent system prompt bloat - #42822

Closed
Morad37 wants to merge 1 commit into
NousResearch:mainfrom
Morad37:fix/42809-subagent-prompt-bloat
Closed

fix(delegate): reduce subagent system prompt bloat#42822
Morad37 wants to merge 1 commit into
NousResearch:mainfrom
Morad37:fix/42809-subagent-prompt-bloat

Conversation

@Morad37

@Morad37 Morad37 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #42809

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Clean, well-scoped fix that reduces system prompt bloat for subagents by:

  • Skipping TASK_COMPLETION_GUIDANCE and tool-specific guidance (memory, session_search, skill_manage) when _delegate_depth > 0
  • Adding skills to the blocked toolsets list for delegated tasks

Looks Good

  • Clear variable name (is_subagent) with inline comment explaining the intent
  • Guard is placed at the right level — avoids redundant checks once is_subagent is set
  • No test changes needed; behavior is additive (subagents receive less prompting, main agent unchanged)

Minor Note

  • PR title could be fix(delegate): reduce subagent system prompt bloat to match the fix(scope): description convention used elsewhere in the repo

Reviewed by Hermes Agent

@alt-glitch alt-glitch added type/perf Performance improvement or optimization P3 Low — cosmetic, nice to have comp/tools Tool registry, model_tools, toolsets tool/delegate Subagent delegation labels Jun 9, 2026
@kyssta-exe

Copy link
Copy Markdown
Contributor

Thanks for the PR! A few observations:

Overlap with #42831: This PR and #42831 both add "skills" to _strip_blocked_tools() in delegate_tool.py to fix #42809. #42831 was opened first and is narrower in scope (delegate_tool.py change only). This PR goes further by also skipping TASK_COMPLETION_GUIDANCE, MEMORY_GUIDANCE, SESSION_SEARCH_GUIDANCE, and SKILLS_GUIDANCE for subagents in system_prompt.py. The system_prompt.py changes are a good addition — subagents don't need per-tool behavioral guidance that's only relevant to the top-level agent.

Worth coordinating with the #42831 author to avoid merge conflicts if both land. Since this PR is a superset, it might make sense to close #42831 in favor of this one if the system_prompt.py changes are wanted.

The is_subagent check via _delegate_depth > 0 is clean and consistent with how the codebase already tracks delegation depth.

@Morad37

Morad37 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing. Noted on #42831 — my PR extends the fix further (system prompt guidance), so the narrower delegate_tool.py change from #42831 can land independently and mine builds on top. No conflict.

@Nullstate-Studio

Nullstate-Studio commented Jun 11, 2026

Copy link
Copy Markdown

We've closed #42831 in favour of this PR it supersedes ours with the broader fix. Thanks for picking it up!

@alt-glitch alt-glitch added the comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint label Jun 27, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: #42809 (the issue), #42831 (narrower delegate_tool-only fix, now closed in favour of this), #42823 (earlier closed twin of #42831), #48454 (sub-agent context-injection, different mechanism). This PR is the broader fix: it both strips the skills toolset from leaf subagents (the #42831 change) and gates the task-completion + per-tool guidance blocks behind is_subagent in agent/system_prompt.py. Canonical for #42809.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for addressing the real delegated-prompt bloat; current main still inherits the parent skills toolset into children (tools/delegate_tool.py:1113-1137) and renders the skill index whenever skill tools are present (agent/system_prompt.py:292-322).

Problems

  • The delegate_tool.py hunk is stale: _strip_blocked_tools() now derives exclusions from DELEGATE_BLOCKED_TOOLS and _COMPOSITE_BLOCKED_TOOLSETS (tools/delegate_tool.py:766-783), and GitHub reports this PR as non-mergeable after feat(delegate): remove model-facing toolsets arg — subagents inherit parent's #56386.
  • The proposed TASK_COMPLETION_GUIDANCE gate removes a deliberately universal anti-stub/anti-fabrication block from all children. Current main documents that intent at agent/system_prompt.py:199-206 (introduced in a4d8f0f62).
  • The PR has no regression tests for either prompt behavior or skills stripping.

Suggested changes

  • Rework the skills exclusion against the current derived filter and test it in tests/tools/test_delegate.py.
  • Keep task-completion guidance unless a child-specific reproduction demonstrates it is unnecessary; add a depth-positive prompt test for the retained behavior.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 14, 2026
@alt-glitch alt-glitch removed the sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades label Jul 14, 2026
@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Thanks @Morad37 for flagging the subagent prompt-bloat problem — great catch on issue #42809. The core fix (blocking skills tools from leaf subagents) has been salvaged into #76081 with regression tests and per-tool blocking, and you're credited as the original contributor there. Closing this in favor of that implementation; the broader system-prompt gating was intentionally left out of the salvage's scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/tools Tool registry, model_tools, toolsets P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform tool/delegate Subagent delegation type/perf Performance improvement or optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

delegate_task: subagent system prompt includes unnecessary bloat causing false context-overflow errors

7 participants