Skip to content

The agent that grows with you

fix(cli): /reasoning reaches the gateway agent (the reasoning mutation carries its generation)

Teknium689f297f98fb
diff --git a/hermes_cli/gateway_agent.py b/hermes_cli/gateway_agent.py
index 37776119208..1a545274459 100644
--- a/hermes_cli/gateway_agent.py
+++ b/hermes_cli/gateway_agent.py
@@ -197,8 +197,10 @@ class GatewayAgent:
return
try:
snapshot = self.connection.call("session.resume", session_id=self.session_id)
+ # A policy mutation is generation-fenced: the owner refuses it without the generation.
self.connection.call("session.mutate", session_id=self.session_id, request_id=uuid.uuid4().hex,
- expected_revision=snapshot["revision"], operation="reasoning",
+ expected_revision=snapshot["revision"],
+ expected_generation=snapshot["execution_generation"], operation="reasoning",
payload={"effort": effort})
info["reasoning_effort"] = effort
except (GatewayClientError, KeyError, TypeError) as exc:
diff --git a/tests/hermes_cli/test_gateway_agent.py b/tests/hermes_cli/test_gateway_agent.py
index 41bc97fa163..b4252784677 100644
--- a/tests/hermes_cli/test_gateway_agent.py
+++ b/tests/hermes_cli/test_gateway_agent.py
@@ -405,6 +405,8 @@ def test_reasoning_level_change_is_the_session_reasoning_mutation(make_agent):
agent, client = make_agent([], reasoning_config={"enabled": True, "effort": "high"})
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).
+ assert mut[0]["expected_generation"] == 7
agent.reasoning_config = {"enabled": False}
mut = [p for m, p in client.calls if m == "session.mutate"]
assert mut[-1]["payload"] == {"effort": "none"}