The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): only a user-picked effort is committed to the session; a resume keeps its launch policy
Teknium2d78be519c46
diff --git a/hermes_cli/cli_agent_setup_mixin.py b/hermes_cli/cli_agent_setup_mixin.pyindex 79def48dbb2..002b537875a 100644--- a/hermes_cli/cli_agent_setup_mixin.py+++ b/hermes_cli/cli_agent_setup_mixin.py@@ -685,6 +685,7 @@ class CLIAgentSetupMixin:ephemeral_system_prompt=self.system_prompt if self.system_prompt else None,prefill_messages=self.prefill_messages or None,reasoning_config=self.reasoning_config, service_tier=self.service_tier,+ push_reasoning=getattr(self, "_reasoning_user_set", False),request_overrides=request_overrides, providers_allowed=self._providers_only,providers_ignored=self._providers_ignore, providers_order=self._providers_order,provider_sort=self._provider_sort,diff --git a/hermes_cli/cli_commands_mixin.py b/hermes_cli/cli_commands_mixin.pyindex 480ded44842..831f0c31cc0 100644--- a/hermes_cli/cli_commands_mixin.py+++ b/hermes_cli/cli_commands_mixin.py@@ -2294,6 +2294,7 @@ class CLICommandsMixin(CLICommandsSessionToolsMixin):_dim_line(_t("reasoning.valid_levels")), _dim_line(_t("reasoning.valid_display")),_dim_line(_t("reasoning.valid_scope")))self.reasoning_config = parsed+ self._reasoning_user_set = True # the rebuilt gateway agent commits it to the session_retire_agent(self) # Force agent re-init with new reasoning configsaved = explicit_global and _save("agent.reasoning_effort", arg)if saved:diff --git a/hermes_cli/cli_model_switch_mixin.py b/hermes_cli/cli_model_switch_mixin.pyindex cc74086f109..c424c503f4b 100644--- a/hermes_cli/cli_model_switch_mixin.py+++ b/hermes_cli/cli_model_switch_mixin.py@@ -43,6 +43,7 @@ def _resolve_cli_reasoning(cli) -> None:from hermes_constants import resolve_reasoning_config# getattr: tests drive /new unbound on a SimpleNamespace without ``model`` (blank -> config default).cli.reasoning_config = resolve_reasoning_config(CLI_CONFIG, getattr(cli, "model", None) or "")+ cli._reasoning_user_set = Falsedef stored_session_route(session_meta, *, current_model, current_provider):@@ -239,6 +240,7 @@ def _apply_reasoning_after_switch(cli, effort: str, *, persist_global: bool) ->if parsed is None:returncli.reasoning_config = parsed+ cli._reasoning_user_set = Trueif cli.agent is not None:cli.agent.reasoning_config = parsedsaved = persist_global and save_config_value("agent.reasoning_effort", effort)diff --git a/hermes_cli/gateway_agent.py b/hermes_cli/gateway_agent.pyindex 1a545274459..26b89ace1fe 100644--- a/hermes_cli/gateway_agent.py+++ b/hermes_cli/gateway_agent.py@@ -76,7 +76,8 @@ class GatewayAgent:reasoning_callback=None, thinking_callback=None, tool_progress_callback=None,tool_start_callback=None, tool_complete_callback=None, stream_delta_callback=None,tool_gen_callback=None, notice_callback=None, notice_clear_callback=None,- reaction_callback=None, interim_assistant_callback=None, connection=None, **_ignored):+ reaction_callback=None, interim_assistant_callback=None, connection=None,+ push_reasoning=False, **_ignored):conn = connection or getattr(session_db, "connection", None)if conn is None:raise GatewayClientError("Gateway session unavailable; no local fallback")@@ -153,7 +154,12 @@ class GatewayAgent:self._tool_progress_mode = "all"self.tool_progress_mode = tool_progress_modeself._reasoning_config = None- self.reasoning_config = reasoning_config+ # Only a user-picked effort (/reasoning, a model pick's --reasoning) is committed at build; the+ # config-resolved level must never override the session's frozen launch policy on resume.+ if push_reasoning:+ self.reasoning_config = reasoning_config+ else:+ self._reasoning_config = reasoning_configself._apply_info(self._state().info)self.reasoning_callback = reasoning_callbackself.service_tier = service_tierdiff --git a/tests/hermes_cli/test_gateway_agent.py b/tests/hermes_cli/test_gateway_agent.pyindex b4252784677..e1e34701557 100644--- a/tests/hermes_cli/test_gateway_agent.py+++ b/tests/hermes_cli/test_gateway_agent.py@@ -402,7 +402,7 @@ def test_a_non_default_verbose_mode_is_sent_when_the_agent_is_built(make_agent):def test_reasoning_level_change_is_the_session_reasoning_mutation(make_agent):"""``/reasoning high`` sets ``reasoning_config`` and rebuilds the agent: the rebuilt agent commitsthe effort as ``session.mutate reasoning`` (session scope, as main's), once."""- agent, client = make_agent([], reasoning_config={"enabled": True, "effort": "high"})+ agent, client = make_agent([], reasoning_config={"enabled": True, "effort": "high"}, push_reasoning=True)mut = [p for m, p in client.calls if m == "session.mutate"]assert len(mut) == 1 and mut[0]["operation"] == "reasoning" and mut[0]["payload"] == {"effort": "high"}# A policy mutation without the generation it was read at is refused by the owner (invalid_params).@@ -416,6 +416,14 @@ def test_reasoning_level_change_is_the_session_reasoning_mutation(make_agent):assert agent2.reasoning_config == {"enabled": False}+def test_a_config_resolved_effort_never_overrides_the_sessions_launch_policy(make_agent):+ """Building the agent with the CLI's config-resolved effort (no /reasoning pick) commits nothing:+ a resumed `-q --resume` must keep the session's frozen --reasoning, not the profile default."""+ agent, client = make_agent([], reasoning_config={"enabled": True, "effort": "none"})+ assert [p for m, p in client.calls if m == "session.mutate"] == []+ assert agent.reasoning_config == {"enabled": True, "effort": "none"}++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 andstream reasoning. The gateway session gets the same switch at construction and on every toggle."""