Skip to content

fix(delegate): save parent tool names before child construction mutates global - #2083

Merged
teknium1 merged 1 commit into
NousResearch:mainfrom
ygd58:fix/delegate-save-parent-tool-names-before-child-build
Mar 20, 2026
Merged

fix(delegate): save parent tool names before child construction mutates global#2083
teknium1 merged 1 commit into
NousResearch:mainfrom
ygd58:fix/delegate-save-parent-tool-names-before-child-build

Conversation

@ygd58

@ygd58 ygd58 commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #2079

Root Cause

The previous fix (#1804/#1894) moved _saved_tool_names into _run_single_child() to fix the NameError, but the save still captured the wrong value. _build_child_agent() calls AIAgent() which calls get_tool_definitions(), which overwrites model_tools._last_resolved_tool_names with the child's toolset. By the time _run_single_child() saves the global, it's already the child's tools — not the parent's.

Fix

  1. Save parent tool names before any child construction in delegate_task() at the top of the build loop
  2. Set correct value on each child via child._delegate_saved_tool_names = _parent_tool_names
  3. Authoritative restore after all children are built: _model_tools._last_resolved_tool_names = _parent_tool_names
  4. _run_single_child now reads from child._delegate_saved_tool_names (correct parent value)

Fixes Both Cases

  • Single task: Parent tools correctly restored after delegation
  • Batch mode: No race condition — each thread reads from its own child object, authoritative restore happens on main thread

@ygd58
ygd58 force-pushed the fix/delegate-save-parent-tool-names-before-child-build branch from ef927ae to 816d134 Compare March 19, 2026 19:27
@teknium1
teknium1 merged commit 493bf8d into NousResearch:main Mar 20, 2026
1 check passed
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…ent-tool-names-before-child-build

fix(delegate): save parent tool names before child construction mutates global
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…ent-tool-names-before-child-build

fix(delegate): save parent tool names before child construction mutates global
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…ent-tool-names-before-child-build

fix(delegate): save parent tool names before child construction mutates global
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…ent-tool-names-before-child-build

fix(delegate): save parent tool names before child construction mutates global
melon-xf added a commit to melon-xf/hermes-agent that referenced this pull request Sep 3, 2026
…ent-tool-names-before-child-build

fix(delegate): save parent tool names before child construction mutates global
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

delegate_task saves child's tool names instead of parent's (post-mutation timing bug)

2 participants