fix(gateway): apply agent.disabled_toolsets in gateway message loop

Widens the cherry-picked fix from @jatingodnani (#17343) to the
gateway path. On main, user_config.agent.disabled_toolsets was only
honored by _get_platform_tools' name-level subtraction — it did not
catch tools pulled in implicitly by a composite toolset (browser
includes web_search, hermes-* platforms include most tools).

Changes:
- gateway/run.py: resolve disabled_toolsets alongside enabled_toolsets
  and pass to AIAgent at both user-facing construction sites (normal
  message loop + single-turn cron-like path). Hygiene/compression
  agents (fixed enabled_toolsets=[memory]) are intentionally untouched.
- gateway/run.py: add (agent, disabled_toolsets) to
  _CACHE_BUSTING_CONFIG_KEYS so editing the list in config.yaml
  invalidates the cached AIAgent on the next message.
- cli.py: drop unused 'import platform' left over from PR #17343's
  import churn; restore 'import sys' used throughout the file.
- model_tools.py: drop unused 'import os, sys' added by PR #17343;
  fix comment reference from #15291 (unrelated OAuth issue) to #17309.

Co-authored-by: jatin godnani <godnanijatin@gmail.com>
This commit is contained in:
Teknium 2026-04-30 20:23:04 -07:00
parent e3624e00db
commit 9a75743496
3 changed files with 9 additions and 4 deletions

View file

@ -7988,6 +7988,8 @@ class GatewayRunner:
from hermes_cli.tools_config import _get_platform_tools
enabled_toolsets = sorted(_get_platform_tools(user_config, platform_key))
agent_cfg = user_config.get("agent") or {}
disabled_toolsets = agent_cfg.get("disabled_toolsets") or None
pr = self._provider_routing
max_iterations = int(os.getenv("HERMES_MAX_ITERATIONS", "90"))
@ -8004,6 +8006,7 @@ class GatewayRunner:
quiet_mode=True,
verbose_logging=False,
enabled_toolsets=enabled_toolsets,
disabled_toolsets=disabled_toolsets,
reasoning_config=reasoning_config,
service_tier=self._service_tier,
request_overrides=turn_route.get("request_overrides"),
@ -10379,6 +10382,7 @@ class GatewayRunner:
("compression", "threshold"),
("compression", "target_ratio"),
("compression", "protect_last_n"),
("agent", "disabled_toolsets"),
)
@classmethod
@ -11162,6 +11166,8 @@ class GatewayRunner:
from hermes_cli.tools_config import _get_platform_tools
enabled_toolsets = sorted(_get_platform_tools(user_config, platform_key))
agent_cfg_local = user_config.get("agent") or {}
disabled_toolsets = agent_cfg_local.get("disabled_toolsets") or None
display_config = user_config.get("display", {})
if not isinstance(display_config, dict):
@ -11790,6 +11796,7 @@ class GatewayRunner:
quiet_mode=True,
verbose_logging=False,
enabled_toolsets=enabled_toolsets,
disabled_toolsets=disabled_toolsets,
ephemeral_system_prompt=combined_ephemeral or None,
prefill_messages=self._prefill_messages or None,
reasoning_config=reasoning_config,