The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(acp): a mode pick refused by a lost turn names that turn
Teknium48ec60eb9a91
diff --git a/acp_adapter/gateway_server.py b/acp_adapter/gateway_server.pyindex 4af042b48bf..dfdfefeb78d 100644--- a/acp_adapter/gateway_server.py+++ b/acp_adapter/gateway_server.py@@ -589,8 +589,11 @@ class GatewayACPAgent(GatewayReplyMixin, acp.Agent):except GatewayClientError as exc:if str(exc) not in {"session_busy", "unknown_execution"}:raise- # A turn is running: named in the transcript (as a deferred model pick is) and the reply.- text = "Mode changes apply when the session is idle; try again after this turn."+ # Named in the transcript (as a deferred model pick is) and the reply: a running turn ends on its+ # own, a lost one (unknown_execution) blocks every control until it is resolved or discarded.+ text = ("Mode changes apply when the session is idle; try again after this turn."+ if str(exc) == "session_busy" else "Mode changes wait for the lost turn: "+ + self._unknown_recovery(session_id, submitted=False).removeprefix("unknown_execution: "))if self._conn:await self._conn.session_update(session_id=self._editor_id(session_id),update=acp.update_agent_message_text(text + "\n"))diff --git a/tests/acp_adapter/test_gateway_session_commands.py b/tests/acp_adapter/test_gateway_session_commands.pyindex 63ccf20a104..eb6cc332194 100644--- a/tests/acp_adapter/test_gateway_session_commands.py+++ b/tests/acp_adapter/test_gateway_session_commands.py@@ -181,6 +181,24 @@ async def test_a_mode_pick_during_a_turn_is_refused_with_the_reason(pick):assert agent._modes['s'] == 'default'+async def test_a_mode_pick_behind_a_lost_turn_says_to_resolve_it_not_to_wait():+ """unknown_execution: no turn is running, so "after this turn" would never come true."""+ from hermes_cli.gateway_client import GatewayRPCError++ async def rpc(method, **params):+ if method == 'session.resume':+ return {'revision': 3, 'execution_generation': 7}+ raise GatewayRPCError('unknown_execution')++ agent = _agent(rpc)+ agent._snapshots['s']['pending'] = [{'admission_id': 'lost-1', 'status': 'unknown'}]+ with pytest.raises(acp.RequestError) as refused:+ await agent.set_session_mode('dont_ask', 's')+ text = str(refused.value.data or refused.value)+ assert 'after this turn' not in text and '/discard lost-1' in text, text++def _context_shown(agent):return [(call.kwargs['update'].size, call.kwargs['update'].used)for call in agent._conn.session_update.await_args_list