mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix: preserve parent agent's tool list after subagent delegation (#1778)
Save and restore the process-global _last_resolved_tool_names in _run_single_child() so the parent's execute_code sandbox generates correct tool imports after delegation completes. The global was already mostly mitigated (run_agent.py passes enabled_tools via self.valid_tool_names), but the global itself remained corrupted — a footgun for any code that reads it directly. Co-authored-by: shane9coy <shane9coy@users.noreply.github.com>
This commit is contained in:
parent
9a1e971126
commit
b5cf0f0aef
3 changed files with 53 additions and 1 deletions
|
|
@ -171,6 +171,11 @@ def _build_child_agent(
|
|||
model on OpenRouter while the parent runs on Nous Portal).
|
||||
"""
|
||||
from run_agent import AIAgent
|
||||
import model_tools
|
||||
|
||||
# Save the parent's resolved tool names before the child agent can
|
||||
# overwrite the process-global via get_tool_definitions().
|
||||
_saved_tool_names = list(model_tools._last_resolved_tool_names)
|
||||
|
||||
# When no explicit toolsets given, inherit from parent's enabled toolsets
|
||||
# so disabled tools (e.g. web) don't leak to subagents.
|
||||
|
|
@ -365,6 +370,10 @@ def _run_single_child(
|
|||
}
|
||||
|
||||
finally:
|
||||
# Restore the parent's tool names so the process-global is correct
|
||||
# for any subsequent execute_code calls or other consumers.
|
||||
model_tools._last_resolved_tool_names = _saved_tool_names
|
||||
|
||||
# Unregister child from interrupt propagation
|
||||
if hasattr(parent_agent, '_active_children'):
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue