The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): the status bar after /retry anchors on the turn's reply, as main's does
Tekniumad821b3179e7
diff --git a/hermes_cli/gateway_agent.py b/hermes_cli/gateway_agent.pyindex b71da3c5080..63b5369232a 100644--- a/hermes_cli/gateway_agent.py+++ b/hermes_cli/gateway_agent.py@@ -733,7 +733,11 @@ class GatewayAgent:# its ask is estimated delta too.last_user = next((i for i in range(len(messages) - 1, -1, -1) if messages[i].get("role") == "user"),len(messages) - 1)- base = last_user + 1 if self.session_api_calls > self._turn_calls_base else last_user+ # The gateway rebuilds its agent after a rewind (/undo, /retry bump the runtime generation), so+ # its cumulative counter can restart below this viewer's turn base: a lower count is a new agent+ # that made calls this turn, never "no call".+ calls = self.session_api_calls+ base = last_user + 1 if calls > self._turn_calls_base or 0 < calls < self._turn_calls_base else last_userif base <= 0:self._turn_base_usage_anchor = Nonereturndiff --git a/tests/hermes_cli/test_gateway_agent.py b/tests/hermes_cli/test_gateway_agent.pyindex 3a062f7ebcb..733574f6732 100644--- a/tests/hermes_cli/test_gateway_agent.py+++ b/tests/hermes_cli/test_gateway_agent.py@@ -458,3 +458,24 @@ def test_agent_follows_mains_session_id_switch(make_agent):assert ("session.resume", {"session_id": "local-other"}) in client.callsagent.connection.state("local-other").apply_usage({"api_calls": 3, "input_tokens": 9})assert agent.session_api_calls == 3+++def test_turn_after_a_rewind_anchors_on_its_first_response(make_agent):+ """/undo and /retry bump the session's runtime generation, so the gateway rebuilds its agent and the+ cumulative counters restart below this viewer's turn base. The turn still completed an API call:+ the bar anchors on its reply (no `~`), as main's does after /retry."""+ usage = dict(SESSION_USAGE, context_tokens=120, api_calls=1)+ agent, client = make_agent([frame("message.complete", {"text": "done", "outcome": "completed"})],+ result={"final_response": "done", "api_calls": 1})+ original = client.rpc++ async def rpc(method, *, _timeout=None, **params):+ if method == "session.stats":+ return usage+ return await original(method, _timeout=_timeout, **params)+ client.rpc = rpc+ agent.session_api_calls = 4 # the previous agent's cumulative count+ agent.run_conversation("again", conversation_history=[{"role": "user", "content": "a"},+ {"role": "assistant", "content": "b"}])+ msgs = agent._session_messages+ assert agent._turn_base_usage_anchor["base_count"] == len(msgs) - 1 # through the ask; reply follows