The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tools): a one-shot resume still honours a configured clarify disable
Teknium8bbf95c85bda
diff --git a/agent/agent_init.py b/agent/agent_init.pyindex 7d19619ee43..525d193413a 100644--- a/agent/agent_init.py+++ b/agent/agent_init.py@@ -1114,8 +1114,8 @@ def _load_tools(agent, enabled_toolsets, disabled_toolsets):import model_toolsfrom agent.oneshot_footprint import agent_is_oneshotfrom toolsets import agent_tool_surface, session_disabled_toolsets- disabled_toolsets = session_disabled_toolsets(- disabled_toolsets, getattr(agent, "platform", None), oneshot=agent_is_oneshot(agent))+ agent._configured_disabled_toolsets, disabled_toolsets = disabled_toolsets, session_disabled_toolsets(+ disabled_toolsets, getattr(agent, "platform", None), oneshot=agent_is_oneshot(agent)) # pin restore reads bothagent.disabled_toolsets = disabled_toolsets # so the tool_search bridge and delegate children drop them tooagent.tools = agent_tool_surface(agent, model_tools.get_tool_definitions(enabled_toolsets=enabled_toolsets, disabled_toolsets=disabled_toolsets, quiet_mode=agent.quiet_mode) or [])diff --git a/tests/agent/test_oneshot_interactive_surface.py b/tests/agent/test_oneshot_interactive_surface.pyindex aac7b9c669c..732573a8193 100644--- a/tests/agent/test_oneshot_interactive_surface.py+++ b/tests/agent/test_oneshot_interactive_surface.py@@ -15,7 +15,7 @@ import pytestLIVE_CONTROL = {"action", "subagent_id", "message"}-def _built_agent(monkeypatch, oneshot: bool):+def _built_agent(monkeypatch, oneshot: bool, disabled=None):from agent.agent_init import _load_toolsif oneshot:@@ -23,7 +23,7 @@ def _built_agent(monkeypatch, oneshot: bool):else:monkeypatch.delenv("HERMES_SINGLE_QUERY_SESSION", raising=False)agent = SimpleNamespace(platform="cli", quiet_mode=True)- _load_tools(agent, ["hermes-cli"], None)+ _load_tools(agent, ["hermes-cli"], disabled)return agent@@ -51,16 +51,19 @@ def test_oneshot_tool_build_drops_clarify_and_delegate_live_control(monkeypatch)assert "steer" not in delegate["description"] and "BETWEEN your turns" not in delegate["description"]-def test_oneshot_resume_keeps_the_pinned_interactive_tool_bytes(monkeypatch):[email protected]("config_disables_clarify", [False, True])+def test_oneshot_resume_keeps_the_pinned_interactive_tool_bytes(monkeypatch, config_disables_clarify):# `hermes -z --resume <interactive session>`: the same-code pin's bytes head every request (prompt cache), so- # neither the one-shot delegate_task variant nor the one-shot clarify gate may rewrite or drop a pinned tool.+ # neither the one-shot delegate_task variant nor the one-shot clarify gate may rewrite or drop a pinned tool;+ # a clarify the user's config disables since the pin still drops, as it would for an interactive resume.from tools.mcp_tool_agent import restore_agent_tool_prefix, tool_pin_versioninteractive = _built_agent(monkeypatch, oneshot=False)- oneshot = _built_agent(monkeypatch, oneshot=True)+ oneshot = _built_agent(monkeypatch, oneshot=True, disabled=["clarify"] if config_disables_clarify else None)restore_agent_tool_prefix(oneshot, {"version": tool_pin_version(), "tools": interactive.tools})- assert oneshot.tools == interactive.tools+ expected = [t for t in interactive.tools if not (config_disables_clarify and t["function"]["name"] == "clarify")]+ assert oneshot.tools == expecteddef test_gateway_oneshot_inventory_drops_clarify(tmp_path, monkeypatch):diff --git a/tools/mcp_tool_agent.py b/tools/mcp_tool_agent.pyindex cfd8a936c18..f62cc381087 100644--- a/tools/mcp_tool_agent.py+++ b/tools/mcp_tool_agent.py@@ -40,6 +40,7 @@ def _resolve_refresh_toolsets(agent, enabled_override, disabled_override):if disabled_override is not None:from agent.oneshot_footprint import agent_is_oneshotfrom toolsets import session_disabled_toolsets+ agent._configured_disabled_toolsets = disabled_overridedisabled = session_disabled_toolsets(disabled_override, getattr(agent, "platform", None), oneshot=agent_is_oneshot(agent))agent.enabled_toolsets, agent.disabled_toolsets = enabled, disabled@@ -210,8 +211,9 @@ def _config_permitted_names(agent) -> set:if enabled is not None:enabled = [*enabled, *CLIENT_SURFACE_TOOLSETS]disabled = getattr(agent, "disabled_toolsets", None)- if disabled and agent_is_oneshot(agent): # the one-shot gate is no config choice either: a pinned clarify stays- disabled = [name for name in disabled if name not in ONESHOT_DISABLED_TOOLSETS]+ if disabled and agent_is_oneshot(agent): # the one-shot gate is no config choice either: a pinned clarify stays,+ configured = set(getattr(agent, "_configured_disabled_toolsets", None) or ()) # unless config disables it+ disabled = [name for name in disabled if name not in ONESHOT_DISABLED_TOOLSETS or name in configured]return _select_tool_names(enabled, disabled, True)