From 9a757434967f3834d3925fec057ec6d4e7d7411c Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Thu, 30 Apr 2026 20:23:04 -0700 Subject: [PATCH] fix(gateway): apply agent.disabled_toolsets in gateway message loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- cli.py | 2 +- gateway/run.py | 7 +++++++ model_tools.py | 4 +--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cli.py b/cli.py index 2e50b30a2f..bfe0dcbaa9 100644 --- a/cli.py +++ b/cli.py @@ -15,8 +15,8 @@ Usage: import logging import os -import platform import shutil +import sys import json import re import concurrent.futures diff --git a/gateway/run.py b/gateway/run.py index ea1977c34e..65394935c6 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -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, diff --git a/model_tools.py b/model_tools.py index 1eb84d03f9..2eb31ab0df 100644 --- a/model_tools.py +++ b/model_tools.py @@ -23,8 +23,6 @@ Public API (signatures preserved from the original 2,400-line version): import json import asyncio import logging -import os -import sys import threading import time from typing import Dict, Any, List, Optional, Tuple @@ -367,7 +365,7 @@ def _compute_tool_definitions( # Always apply disabled toolsets as a subtraction step at the end. # This ensures that even if a composite toolset (like hermes-cli) # is enabled, any tools belonging to a disabled toolset are strictly - # stripped out. See issue #15291. + # stripped out. See issue #17309. if disabled_toolsets: for toolset_name in disabled_toolsets: if validate_toolset(toolset_name):