The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): a session_busy pause does not start a new notice episode
Tekniumf8eb2f057bd3
diff --git a/gateway/session_authority.py b/gateway/session_authority.pyindex 936c4caaddc..a9a683420e5 100644--- a/gateway/session_authority.py+++ b/gateway/session_authority.py@@ -547,12 +547,14 @@ class SessionAuthority:returnif row is False:continue+ if row is None and first is not None:+ # A live worker (or a claim this drain does not own) blocks the head: the same+ # pause episode, so its notice is not repeated for every message queued behind it.+ self._pause(ref, 'session_busy')+ return# The FIFO is moving again (or empty): the next pause is a new episode.live.pause_notified = Falseif row is None:- if first is not None:- self._pause(ref, 'session_busy')- returnfrom gateway.session_acp_lifecycle import end_idle_acp_sessionend_idle_acp_session(self, ref.session_id)returndiff --git a/tests/gateway/test_local_authority_transitions.py b/tests/gateway/test_local_authority_transitions.pyindex d19839e6f28..3a33c62036e 100644--- a/tests/gateway/test_local_authority_transitions.py+++ b/tests/gateway/test_local_authority_transitions.py@@ -151,3 +151,24 @@ async def test_branch_route_uses_store_clock_and_deleted_policy_is_retired(tmp_pfinally:await connection.close()owner.db.close()+++async def test_session_busy_pause_keeps_the_notice_episode(tmp_path, monkeypatch):+ """A head blocked behind running work is the same pause episode: the "saved, will be answered"+ notice is not repeated for every message queued behind it."""+ from hermes_state_runtime import admit_session_input, claim_session_input+ owner, connection, ref = await local_session(tmp_path, monkeypatch)+ live = owner.sessions[ref.session_id]+ try:+ for request_id in ('running', 'queued'):+ admit_session_input(owner.db, epoch=owner.epoch, principal_id=connection.actor.subject,+ session_id=ref.session_id, request_id=request_id, payload={'text': request_id})+ if request_id == 'running':+ assert claim_session_input(owner.db, epoch=owner.epoch, session_id=ref.session_id) is not None+ live.pause_notified = True # the user was already told about this busy episode+ await owner._drain(ref)+ assert live.pause_notified is True, 'session_busy pause reset the notice episode'+ finally:+ await connection.close()+ owner.db.close()