fix(delegation): stop mixed platform bundles from re-exposing blocked tools to leaf children - #66817
Merged
Merged
Conversation
… tools to leaf children A leaf subagent is meant to be denied delegate_task, execute_code, memory, clarify, cronjob, and send_message. _strip_blocked_tools() only drops a toolset when EVERY tool in it is blocked, so mixed platform bundles (hermes-cli, hermes-telegram, and every other gateway bundle) survived stripping and re-exposed the blocked tools after composite expansion. A leaf child spawned from any gateway platform could recursively delegate, run code, and write memory. Pass exact one-tool deny toolsets into the child's disabled_toolsets so model_tools subtracts the blocked names AFTER composite expansion, and the restriction survives later registry/MCP refreshes. Orchestrators regain only delegate_task. Salvaged from #66036 by Mason Tanguay (@DictatorBacon); scoped to the authority fix + its regressions (docs/interrupt changes dropped). Co-authored-by: Teknium <127238744+teknium1@users.noreply.github.com>
Collaborator
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
A
leafsubagent can no longer inherit the six blocked tools (delegate_task,execute_code,memory,clarify,cronjob,send_message) when the parent's toolset is a mixed platform bundle. This closes a live authority escape on the entire gateway surface.Salvages the authority-fix portion of @DictatorBacon's #66036 (scoped to the security fix + its regressions; the doc/schema edits are dropped as redundant with #66576, and the interrupt-detachment change is left for a separate follow-up).
Root cause
_strip_blocked_tools()operates at toolset granularity — it only drops a toolset when every tool in it is blocked. Every gateway platform bundle (hermes-cli,hermes-telegram,hermes-discord, +20 more) is mixed: it carries the blocked tools alongsideterminal/web/read_file/etc. So when a gateway parent'senabled_toolsetsis a bundle name, the bundle survives stripping, the child inherits it, andmodel_toolsexpands it back into the blocked tools. A leaf child spawned from any gateway platform could recursively delegate, run code, and write memory.Fix
_blocked_toolsets_for_role()returns exact one-tool deny toolsets, threaded into the child'sdisabled_toolsetssomodel_toolssubtracts the blocked names after composite expansion — and the restriction survives later registry/MCP refreshes. Orchestrators regain onlydelegate_task.Validation
Live E2E (real
get_tool_definitions()on a child built from["hermes-telegram"]):delegate_task, execute_code, memory, clarifyleakeddelegate_taskscripts/run_tests.sh tests/tools/test_delegate.py→ 158/158 pass, including two new regressions (test_mixed_composite_is_subtracted_at_child_assembly,test_orchestrator_composite_regains_only_delegate_task).Infographic