The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): /reasoning show|hide reaches the gateway agent as the session's show_reasoning flag
Teknium5730fe588ca3
diff --git a/hermes_cli/gateway_agent.py b/hermes_cli/gateway_agent.pyindex 52dbcf3e31a..b7e94588a83 100644--- a/hermes_cli/gateway_agent.py+++ b/hermes_cli/gateway_agent.py@@ -93,7 +93,8 @@ class GatewayAgent:self.service_tier = service_tierself.clarify_callback = clarify_callbackself.connection_callback = connection_callback- self.reasoning_callback = reasoning_callback+ self._reasoning_callback = None+ self._show_reasoning_sent = Noneself.thinking_callback = thinking_callbackself.tool_progress_callback = tool_progress_callbackself.tool_start_callback = tool_start_callback@@ -146,11 +147,34 @@ class GatewayAgent:self._rate_limit_state = Noneself._config_context_length = Noneself._apply_info(self._state().info)+ self.reasoning_callback = reasoning_callbackstate = self._state()state.usage_listeners.append(self.apply_session_usage)if state.usage:self.apply_session_usage(state.usage)+ # -- reasoning display -------------------------------------------------------------------+ @property+ def reasoning_callback(self):+ return self._reasoning_callback++ @reasoning_callback.setter+ def reasoning_callback(self, callback):+ """Main installs a reasoning sink at construction and on ``/reasoning show|hide`` / verbose; the+ sink's presence is what makes the agent ask the provider for reasoning. The gateway agent+ gets the same switch: the session's ``show_reasoning`` display flag, sent on each change."""+ self._reasoning_callback = callback+ wanted = (self.session_id, callback is not None)+ if wanted == self._show_reasoning_sent: # per session: a rotated id gets its own flag+ return+ try:+ self.connection.call("config.set", session_id=self.session_id, key="show_reasoning",+ value="1" if wanted[1] else "0", timeout=10)+ except GatewayClientError as exc:+ logger.debug("config.set show_reasoning failed: %s", exc)+ return+ self._show_reasoning_sent = wanted+# -- snapshot-backed reads ---------------------------------------------------------------def _state(self):return self.connection.state(self.session_id)diff --git a/tests/hermes_cli/test_gateway_agent.py b/tests/hermes_cli/test_gateway_agent.pyindex 245d87851b6..39edd75ae14 100644--- a/tests/hermes_cli/test_gateway_agent.py+++ b/tests/hermes_cli/test_gateway_agent.py@@ -344,3 +344,22 @@ def test_moa_reference_maps_index_and_count_to_mains_kwargs(make_agent):agent.run_conversation("q")assert seen[0][0][:3] == ("moa.reference", "gpt-x", "ref")assert seen[0][1] == {"moa_index": 1, "moa_count": 2}+++def test_reasoning_sink_sets_the_sessions_show_reasoning_flag_on_attach_and_toggle(make_agent):+ """Main: a reasoning sink on the agent (show_reasoning, or verbose) makes the agent request and+ stream reasoning. The gateway session gets the same switch at construction and on every toggle."""+ shown = []+ agent, client = make_agent(+ [frame("reasoning.delta", {"text": "thinking hard"}),+ frame("message.complete", {"text": "ok", "outcome": "completed"})],+ reasoning_callback=shown.append)+ sets = [p for m, p in client.calls if m == "config.set"]+ assert sets == [{"session_id": SID, "key": "show_reasoning", "value": "1"}]+ agent.run_conversation("q")+ assert shown == ["thinking hard"]+ agent.reasoning_callback = None # /reasoning hide+ agent.reasoning_callback = None # unchanged: no second RPC+ agent.reasoning_callback = shown.append # /reasoning show+ values = [p["value"] for m, p in client.calls if m == "config.set" and p.get("key") == "show_reasoning"]+ assert values == ["1", "0", "1"]