fix: validate delegated sub-agent tool lists resolve to >=1 tool (Closes #1387) - #1421
Closed
Lexus2016 wants to merge 1 commit into
Closed
fix: validate delegated sub-agent tool lists resolve to >=1 tool (Closes #1387)#1421Lexus2016 wants to merge 1 commit into
Lexus2016 wants to merge 1 commit into
Conversation
#1387) After toolset resolution and _strip_blocked_tools, if child_toolsets is empty the sub-agent would have no tools and spiral on every tool call. Added a guard in _build_child_agent that raises ValueError with a structured error message. The caller in delegate_task catches the ValueError and returns a per-task error result instead of launching the toolless sub-agent. Co-Authored-By: Hermes Evolution <evolution@hermes.ai>
This was referenced Jul 28, 2026
Owner
Author
|
Blocked by code-review: CI failing — the validation guard in _build_child_agent causes IndexError at delegate_tool.py:3240, breaking 8 tests in test_delegate_shallow_retry.py. The guard raises ValueError which is caught per-task, but the return-path change at line 3240 accesses an index that no longer exists in the modified control flow. Needs: fix the IndexError so existing shallow-retry tests pass, or restructure the guard to not alter the function's return-path shape. |
This was referenced Jul 28, 2026
Lexus2016
added a commit
that referenced
this pull request
Jul 28, 2026
) When a delegated sub-agent resolves to zero tools (requested toolsets don't intersect with parent's, or inherited toolsets are all stripped), append a structured error entry to results with status='error' and skip launching that child. Preserves the {'results': [...]} contract without raising ValueError (broke PR #1421) or returning {'error':...} (broke PR #1419). Closes #1387 Co-authored-by: Hermes Evolution <evolution@hermes.ai>
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.
Automated evolution PR for issue #1387.
Problem
When a delegated sub-agent's toolset resolution produced an empty list (requested toolsets don't intersect with parent's, or inherited toolsets are all stripped by _strip_blocked_tools), the sub-agent was launched with zero tools. This caused the sub-agent to spiral on every tool call — the root cause of the 'is not a deferrable tool' pattern observed in introspection (64 failed sessions, 4.14% rate).
Fix
Added a validation guard in
_build_child_agentafter toolset resolution:child_toolsetsis empty AND toolsets were explicitly requested →ValueErrornaming the requested toolsets and parent's available toolsetschild_toolsetsis empty from inherited toolsets →ValueErrorexplaining the parent has no surviving enabled toolsetsdelegate_taskcatches theValueErrorand returns a per-task error result withstatus: "error"instead of launching the toolless sub-agentChanges
tools/delegate_tool.py: Empty-toolset guard in_build_child_agent(raisesValueError); try/except indelegate_taskbatch loop catches it and returns structured error resulttests/tools/test_delegate_toolset_scope.py: AddedTestEmptyToolsetValidationwith 3 tests covering explicit-request-empty, inherited-empty, and valid-toolsets-no-raiseValidation
tests/tools/test_delegate_toolset_scope.py)Co-Authored-By: Hermes Evolution evolution@hermes.ai