Skip to content

fix(delegate): block skills tools from leaf subagents to reduce prompt bloat - #76081

Closed
kshitijk4poor wants to merge 2 commits into
NousResearch:mainfrom
kshitijk4poor:salvage/42822-subagent-prompt-bloat
Closed

fix(delegate): block skills tools from leaf subagents to reduce prompt bloat#76081
kshitijk4poor wants to merge 2 commits into
NousResearch:mainfrom
kshitijk4poor:salvage/42822-subagent-prompt-bloat

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Summary

Leaf subagents no longer receive the skills toolset, eliminating ~2,800 tokens of skill-index bloat from the child's system prompt that caused context-overflow failures on models with smaller effective context windows.

Root cause: subagents inherited the parent's skills tools (skills_list, skill_view, skill_manage), which triggered the full skill index injection in system_prompt.py. On models like qwen3-coder-next with a lower effective context than configured, the API rejected the payload before the first call (#42809).

Changes

  • tools/delegate_tool.py: Add skills_list, skill_view, skill_manage to DELEGATE_BLOCKED_TOOLS. The derived _strip_blocked_tools() filter auto-strips the skills toolset (all its tools are now blocked), and _blocked_toolsets_for_role() subtracts them from mixed platform bundles. system_prompt.py's existing has_skills_tools gate already prevents the skill index from being injected when the tools are absent — no prompt changes needed.
  • tests/tools/test_delegate.py: 3 regression tests — strip test, constant assertion, _blocked_toolsets_for_role assertion.
  • contributors/emails/: Morad37 attribution.

Design decisions

Validation

Before After
Skills toolset in child Present (~2,800 tokens) Stripped
Skills index in child prompt Injected Not injected
Test suite 60 pass 63 pass
E2E (_strip_blocked_tools, _blocked_toolsets_for_role) Pass
Ruff Clean

Cherry-picked from #42822 by @Morad37. Closes #42809.

Morad37 and others added 2 commits August 1, 2026 15:40
…t bloat

Subagents inherited the parent's skills toolset (skills_list, skill_view,
skill_manage), injecting a ~2,800-token skill index into the child's system
prompt.  On models with smaller effective context windows this caused
context-overflow errors before the subagent made its first API call (NousResearch#42809).

Add the three skills tools to DELEGATE_BLOCKED_TOOLS.  The derived
_strip_blocked_tools() filter then auto-strips the 'skills' toolset (all
its tools are now blocked), and system_prompt.py's has_skills_tools gate
already prevents the skill index from being injected when the tools are
absent from valid_tool_names.

Cherry-picked from PR NousResearch#42822 by @Morad37.  The original PR also proposed
gating TASK_COMPLETION_GUIDANCE behind is_subagent, but that block is a
deliberately universal anti-stub/anti-fabrication directive (a4d8f0f)
and is retained for subagents.  The delegate_tool.py hunk was reworked to
use the derived filter introduced in NousResearch#56386.

Co-authored-by: Morad37 <Morad37@users.noreply.github.com>
For PR NousResearch#42822 salvage — cherry-picked commit authored by
Morad37 <Morad37@users.noreply.github.com>.
@alt-glitch alt-glitch added type/perf Performance improvement or optimization comp/tools Tool registry, model_tools, toolsets tool/delegate Subagent delegation tool/skills Skills system (list, view, manage) P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Aug 1, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #42822: both remove the skills toolset/index from leaf subagents to address #42809. #42822 is the broader open implementation.

@GottZ

GottZ commented Aug 3, 2026

Copy link
Copy Markdown

This was generated by AI during triage.

Summary

Four PRs address #42809. #42823 and #42831 contain the same narrow, now-stale toolset-name filter; #42822 adds broader prompt-guidance removal; and #76081 salvages the root-cause fix against the current derived filtering architecture with regression coverage while retaining universal task-completion guidance.

Related pull requests

Duplicates

#42823 and #42831 are exact duplicates. Their narrow behavior also overlaps with the skills-stripping portion of #42822 and is superseded by the current-architecture implementation in #76081.

Suggested consolidation

Keep #76081 open with a salvage path: preserve its per-tool DELEGATE_BLOCKED_TOOLS change and regression tests, and keep the universal task-completion guidance unchanged. Despite the maintainer-bot keep_open verdict on #42822, #76081 contains the concrete rework that verdict requested, while #42822's stale filter and broader guidance removal should not be revived; #42822, #42823, and #42831 can remain closed as superseded duplicates.

Complex graph

flowchart LR
    classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
    classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
    classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
    classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
    classDef best stroke-width:3px,stroke:#b45309
    classDef target stroke-width:3px,stroke:#4338ca
    I42809(["issue #42809 (open)"])
    subgraph Dup42822 ["PRs duplicating each other"]
        P42822["PR #42822 (closed)"]
        P42823["PR #42823 (closed)"]
        P42831["PR #42831 (closed)"]
        P76081["PR #76081 (open)"]
    end
    P76081 -->|best fix| I42809
    class I42809 open
    class P42822 closed
    class P42823 closed
    class P42831 closed
    class P76081 open
    class P42831 best
    class P76081 best
    class P76081 target
    click I42809 "https://github.com/NousResearch/hermes-agent/issues/42809"
    click P42822 "https://github.com/NousResearch/hermes-agent/pull/42822"
    click P42823 "https://github.com/NousResearch/hermes-agent/pull/42823"
    click P42831 "https://github.com/NousResearch/hermes-agent/pull/42831"
    click P76081 "https://github.com/NousResearch/hermes-agent/pull/76081"
Loading

Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed (state tag in the node label).

Cross-PR triage: Reviewed 4 pull requests and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 10 kB of PR diffs, 7 kB of issue/PR text, 3 kB of discussion (8 comments), 8 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

@kshitijk4poor
kshitijk4poor deleted the salvage/42822-subagent-prompt-bloat branch August 5, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have tool/delegate Subagent delegation tool/skills Skills system (list, view, manage) 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

4 participants