The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(delegation): --now pins only what refresh did not; fresh-agent --now ordering test
Teknium895688f5cd73
diff --git a/agent/delegation_backends.py b/agent/delegation_backends.pyindex b6064d1c244..918991f839e 100644--- a/agent/delegation_backends.py+++ b/agent/delegation_backends.py@@ -125,9 +125,9 @@ def apply_requested_tool_rebuild(agent: Any) -> bool:from hermes_cli.observability.shared_metrics_efficiency import record_cache_breakfrom tools.mcp_tool_agent import persist_agent_tool_names, refresh_agent_mcp_toolsbefore = getattr(agent, "tools", None)- refresh_agent_mcp_tools(agent, quiet_mode=True, content_aware=True) # adopts the saved backend- persist_agent_tool_names(agent) # also when only the backend moved (two backends, one schema)+ refresh_agent_mcp_tools(agent, quiet_mode=True, content_aware=True) # adopts the saved backend, re-pins a changeif agent.tools is before:+ persist_agent_tool_names(agent) # only the backend moved (two backends, one schema): pin itreturn Falserecord_cache_break(agent, "toolset_change")return Truediff --git a/tests/agent/test_delegation_switch_next_session.py b/tests/agent/test_delegation_switch_next_session.pyindex 45f9c296917..ee1786cd130 100644--- a/tests/agent/test_delegation_switch_next_session.py+++ b/tests/agent/test_delegation_switch_next_session.py@@ -81,20 +81,22 @@ def test_a_now_switch_rebuilds_this_sessions_delegate_task_and_routing_for_the_nagent = _agent(srv, home, "chat-now")history = _turn(agent, "hello", [])assert "option" in _sent_task_fields(srv) and _routed_on(agent) == "probe-options"-- set_global_backend("default", session_key="chat-now", apply_now=True)- history = _turn(agent, "and now", history)- assert "option" not in _sent_task_fields(srv) and _routed_on(agent) == "default"agent.close()- # The rebuilt tools and their backend are the session's pin: a fresh agent on it (gateway, --resume) restores- # both, whatever config.yaml says by then.- set_global_backend("probe-options")+ # The gateway's next turn is a fresh agent: it restores the session's pinned tools, then takes the request.+ set_global_backend("default", session_key="chat-now", apply_now=True)fresh = _agent(srv, home, "chat-now")- _turn(fresh, "still here", history)+ history = _turn(fresh, "and now", history)assert "option" not in _sent_task_fields(srv) and _routed_on(fresh) == "default"fresh.close()+ # The rebuilt tools and their backend are the session's pin now, whatever config.yaml says by then.+ set_global_backend("probe-options")+ resumed = _agent(srv, home, "chat-now")+ _turn(resumed, "still here", history)+ assert "option" not in _sent_task_fields(srv) and _routed_on(resumed) == "default"+ resumed.close()+def test_a_plain_switch_changes_nothing_in_this_session_and_new_sessions_take_the_saved_backend(options_backend):import hermes_yaml as yaml