mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(gateway): remove _show_reasoning cache, always resolve per-platform config
Remove GatewayRunner._show_reasoning field that was initialized once at startup using only global display.show_reasoning config. All consumers now resolve show_reasoning per-platform via resolve_display_setting(), ensuring display.platforms.<platform>.show_reasoning overrides work correctly for all platforms (especially WeCom). Changes: - Delete self._show_reasoning initialization in __init__ - Update _handle_reasoning_command to resolve per-platform on each call - Update reasoning_callback wiring to resolve per-platform - Update response prepend logic to resolve per-platform - Remove fallback to cached self._show_reasoning Fixes: WeCom reasoning display respects per-platform config Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
26bd52c1ba
commit
c6ec3e91f3
2 changed files with 13 additions and 10 deletions
|
|
@ -624,7 +624,6 @@ class GatewayRunner:
|
|||
self._ephemeral_system_prompt = self._load_ephemeral_system_prompt()
|
||||
self._reasoning_config = self._load_reasoning_config()
|
||||
self._service_tier = self._load_service_tier()
|
||||
self._show_reasoning = self._load_show_reasoning()
|
||||
self._busy_input_mode = self._load_busy_input_mode()
|
||||
self._restart_drain_timeout = self._load_restart_drain_timeout()
|
||||
self._provider_routing = self._load_provider_routing()
|
||||
|
|
@ -4401,10 +4400,10 @@ class GatewayRunner:
|
|||
_load_gateway_config(),
|
||||
_platform_config_key(source.platform),
|
||||
"show_reasoning",
|
||||
getattr(self, "_show_reasoning", False),
|
||||
False,
|
||||
)
|
||||
except Exception:
|
||||
_show_reasoning_effective = getattr(self, "_show_reasoning", False)
|
||||
_show_reasoning_effective = False
|
||||
if _show_reasoning_effective and response:
|
||||
last_reasoning = agent_result.get("last_reasoning")
|
||||
if last_reasoning:
|
||||
|
|
@ -6597,7 +6596,6 @@ class GatewayRunner:
|
|||
config_path = _hermes_home / "config.yaml"
|
||||
self._reasoning_config = self._load_reasoning_config()
|
||||
_pk = _platform_config_key(event.source.platform)
|
||||
self._show_reasoning = self._load_show_reasoning(_pk)
|
||||
|
||||
def _save_config_key(key_path: str, value):
|
||||
"""Save a dot-separated key to config.yaml."""
|
||||
|
|
@ -6628,7 +6626,17 @@ class GatewayRunner:
|
|||
level = "none (disabled)"
|
||||
else:
|
||||
level = rc.get("effort", "medium")
|
||||
display_state = "on ✓" if self._show_reasoning else "off"
|
||||
try:
|
||||
from gateway.display_config import resolve_display_setting as _rds
|
||||
_show_reasoning = bool(_rds(
|
||||
_load_gateway_config(),
|
||||
_pk,
|
||||
"show_reasoning",
|
||||
False,
|
||||
))
|
||||
except Exception:
|
||||
_show_reasoning = False
|
||||
display_state = "on ✓" if _show_reasoning else "off"
|
||||
return (
|
||||
"🧠 **Reasoning Settings**\n\n"
|
||||
f"**Effort:** `{level}`\n"
|
||||
|
|
@ -6639,7 +6647,6 @@ class GatewayRunner:
|
|||
# Display toggle (per-platform)
|
||||
platform_key = _platform_config_key(event.source.platform)
|
||||
if args in ("show", "on"):
|
||||
self._show_reasoning = True
|
||||
_save_config_key(f"display.platforms.{platform_key}.show_reasoning", True)
|
||||
return (
|
||||
"🧠 ✓ Reasoning display: **ON**\n"
|
||||
|
|
@ -6647,7 +6654,6 @@ class GatewayRunner:
|
|||
)
|
||||
|
||||
if args in ("hide", "off"):
|
||||
self._show_reasoning = False
|
||||
_save_config_key(f"display.platforms.{platform_key}.show_reasoning", False)
|
||||
return f"🧠 ✓ Reasoning display: **OFF** for **{platform_key}**"
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ def _make_runner():
|
|||
runner._ephemeral_system_prompt = ""
|
||||
runner._prefill_messages = []
|
||||
runner._reasoning_config = None
|
||||
runner._show_reasoning = False
|
||||
runner._provider_routing = {}
|
||||
runner._fallback_model = None
|
||||
runner._running_agents = {}
|
||||
|
|
@ -90,14 +89,12 @@ class TestReasoningCommand:
|
|||
|
||||
runner = _make_runner()
|
||||
runner._reasoning_config = {"enabled": True, "effort": "xhigh"}
|
||||
runner._show_reasoning = False
|
||||
|
||||
result = await runner._handle_reasoning_command(_make_event("/reasoning"))
|
||||
|
||||
assert "**Effort:** `none (disabled)`" in result
|
||||
assert "**Display:** on ✓" in result
|
||||
assert runner._reasoning_config == {"enabled": False}
|
||||
assert runner._show_reasoning is True
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_load_show_reasoning_resolves_per_platform(self, tmp_path, monkeypatch):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue