The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): the authority publishes the idle session.info after message.complete
Tekniuma25787653539
diff --git a/apps/desktop/src/lib/execution-authority.frames.json b/apps/desktop/src/lib/execution-authority.frames.jsonindex 1a9b7e3f15a..cf1580c84dc 100644--- a/apps/desktop/src/lib/execution-authority.frames.json+++ b/apps/desktop/src/lib/execution-authority.frames.json@@ -13,7 +13,7 @@"stored_session_id": "shared","pending": [{- "admission_id": "98fa1799e63d47f5bb880c2a2f23577a",+ "admission_id": "ca34f607de944aa89307c78b5e8ad417","ref": {"profile_id": "p","session_id": "shared"@@ -32,7 +32,7 @@"execution_generation": 0,"revision": 0},- "replay_epoch": "79542b8f038a48c99e95fff17bb10feb",+ "replay_epoch": "6c1b60170eff42c0a449ad6dea5f865c","seq": 1}},@@ -42,11 +42,11 @@"params": {"authority_epoch": 1,"execution_generation": 1,- "admission_id": "98fa1799e63d47f5bb880c2a2f23577a",+ "admission_id": "ca34f607de944aa89307c78b5e8ad417","type": "message.start","session_id": "shared","payload": {},- "replay_epoch": "79542b8f038a48c99e95fff17bb10feb",+ "replay_epoch": "6c1b60170eff42c0a449ad6dea5f865c","seq": 2}},@@ -56,14 +56,14 @@"params": {"authority_epoch": 1,"execution_generation": 1,- "admission_id": "98fa1799e63d47f5bb880c2a2f23577a",+ "admission_id": "ca34f607de944aa89307c78b5e8ad417","type": "session.info","session_id": "shared","payload": {"stored_session_id": "shared","pending": [{- "admission_id": "98fa1799e63d47f5bb880c2a2f23577a",+ "admission_id": "ca34f607de944aa89307c78b5e8ad417","ref": {"profile_id": "p","session_id": "shared"@@ -82,7 +82,7 @@"execution_generation": 1,"revision": 0},- "replay_epoch": "79542b8f038a48c99e95fff17bb10feb",+ "replay_epoch": "6c1b60170eff42c0a449ad6dea5f865c","seq": 3}},@@ -92,18 +92,17 @@"params": {"authority_epoch": 1,"execution_generation": 1,- "admission_id": "98fa1799e63d47f5bb880c2a2f23577a",- "type": "session.info",+ "admission_id": "ca34f607de944aa89307c78b5e8ad417",+ "type": "message.complete","session_id": "shared","payload": {- "stored_session_id": "shared",- "pending": [],- "desktop_protocol": "hermes-gateway-v1",- "running": false,- "execution_generation": 1,- "revision": 1+ "text": "answer:epoch1",+ "content": "answer:epoch1",+ "admission_id": "ca34f607de944aa89307c78b5e8ad417",+ "outcome": "completed",+ "status": "complete"},- "replay_epoch": "79542b8f038a48c99e95fff17bb10feb",+ "replay_epoch": "6c1b60170eff42c0a449ad6dea5f865c","seq": 4}},@@ -113,16 +112,18 @@"params": {"authority_epoch": 1,"execution_generation": 1,- "admission_id": "98fa1799e63d47f5bb880c2a2f23577a",- "type": "message.complete",+ "admission_id": "ca34f607de944aa89307c78b5e8ad417",+ "type": "session.info","session_id": "shared","payload": {- "text": "answer:epoch1",- "content": "answer:epoch1",- "admission_id": "98fa1799e63d47f5bb880c2a2f23577a",- "outcome": "completed"+ "stored_session_id": "shared",+ "pending": [],+ "desktop_protocol": "hermes-gateway-v1",+ "running": false,+ "execution_generation": 1,+ "revision": 1},- "replay_epoch": "79542b8f038a48c99e95fff17bb10feb",+ "replay_epoch": "6c1b60170eff42c0a449ad6dea5f865c","seq": 5}}@@ -141,7 +142,7 @@"stored_session_id": "shared","pending": [{- "admission_id": "cc80b8fbc2954b678b9fa765e2cdd60e",+ "admission_id": "206dc02f7ede4393aa847ac53c805d9f","ref": {"profile_id": "p","session_id": "shared"@@ -160,7 +161,7 @@"execution_generation": 1,"revision": 1},- "replay_epoch": "a52a19f124b642389b2e3b48b45f2f42",+ "replay_epoch": "2565ef4c47d34fe18f78c74af26e5c7c","seq": 1}},@@ -170,11 +171,11 @@"params": {"authority_epoch": 2,"execution_generation": 2,- "admission_id": "cc80b8fbc2954b678b9fa765e2cdd60e",+ "admission_id": "206dc02f7ede4393aa847ac53c805d9f","type": "message.start","session_id": "shared","payload": {},- "replay_epoch": "a52a19f124b642389b2e3b48b45f2f42",+ "replay_epoch": "2565ef4c47d34fe18f78c74af26e5c7c","seq": 2}},@@ -184,14 +185,14 @@"params": {"authority_epoch": 2,"execution_generation": 2,- "admission_id": "cc80b8fbc2954b678b9fa765e2cdd60e",+ "admission_id": "206dc02f7ede4393aa847ac53c805d9f","type": "session.info","session_id": "shared","payload": {"stored_session_id": "shared","pending": [{- "admission_id": "cc80b8fbc2954b678b9fa765e2cdd60e",+ "admission_id": "206dc02f7ede4393aa847ac53c805d9f","ref": {"profile_id": "p","session_id": "shared"@@ -210,7 +211,7 @@"execution_generation": 2,"revision": 1},- "replay_epoch": "a52a19f124b642389b2e3b48b45f2f42",+ "replay_epoch": "2565ef4c47d34fe18f78c74af26e5c7c","seq": 3}},@@ -220,18 +221,17 @@"params": {"authority_epoch": 2,"execution_generation": 2,- "admission_id": "cc80b8fbc2954b678b9fa765e2cdd60e",- "type": "session.info",+ "admission_id": "206dc02f7ede4393aa847ac53c805d9f",+ "type": "message.complete","session_id": "shared","payload": {- "stored_session_id": "shared",- "pending": [],- "desktop_protocol": "hermes-gateway-v1",- "running": false,- "execution_generation": 2,- "revision": 2+ "text": "answer:epoch2",+ "content": "answer:epoch2",+ "admission_id": "206dc02f7ede4393aa847ac53c805d9f",+ "outcome": "completed",+ "status": "complete"},- "replay_epoch": "a52a19f124b642389b2e3b48b45f2f42",+ "replay_epoch": "2565ef4c47d34fe18f78c74af26e5c7c","seq": 4}},@@ -241,16 +241,18 @@"params": {"authority_epoch": 2,"execution_generation": 2,- "admission_id": "cc80b8fbc2954b678b9fa765e2cdd60e",- "type": "message.complete",+ "admission_id": "206dc02f7ede4393aa847ac53c805d9f",+ "type": "session.info","session_id": "shared","payload": {- "text": "answer:epoch2",- "content": "answer:epoch2",- "admission_id": "cc80b8fbc2954b678b9fa765e2cdd60e",- "outcome": "completed"+ "stored_session_id": "shared",+ "pending": [],+ "desktop_protocol": "hermes-gateway-v1",+ "running": false,+ "execution_generation": 2,+ "revision": 2},- "replay_epoch": "a52a19f124b642389b2e3b48b45f2f42",+ "replay_epoch": "2565ef4c47d34fe18f78c74af26e5c7c","seq": 5}}@@ -268,7 +270,7 @@"operation": "rename","title": "Renamed while idle"},- "replay_epoch": "a52a19f124b642389b2e3b48b45f2f42",+ "replay_epoch": "2565ef4c47d34fe18f78c74af26e5c7c","seq": 6}}diff --git a/gateway/session_authority.py b/gateway/session_authority.pyindex 7c26f33336b..47e6ba0c4d6 100644--- a/gateway/session_authority.py+++ b/gateway/session_authority.py@@ -530,7 +530,6 @@ class SessionAuthority:live.controls.snapshot(ref.session_id, None)from gateway.session_ingress_media import release_admission_mediarelease_admission_media(self.db, admission_id)- self._publish_pending(ref)# ``status`` is the message.complete contract's TurnStatus: the Desktop# extends a Stopped bubble to the persisted partial only on 'interrupted'.complete = {@@ -540,9 +539,18 @@ class SessionAuthority:settled['outcome'], 'error')}# Only the agent's reuse site sets this (never inferred from equal text): the# final repeats a reply the viewer already painted, so it settles in place.- if response and ((captured or {}).get('result') or {}).get('response_reused'):+ captured_result = (captured or {}).get('result') or {}+ if response and captured_result.get('response_reused'):complete['response_reused'] = True+ # The committed row addresses of the turn: a viewer binds the streamed reply to+ # its stored row, so a transcript read racing this frame never paints it twice.+ if isinstance(captured_result.get('persisted_turn'), dict):+ complete['persisted_turn'] = captured_result['persisted_turn']live.event_stream.publish(ref.session_id, complete)+ # The idle snapshot (running=false) follows the completion, as on every other+ # host: a viewer that read running=false first settled the reply as a turn whose+ # terminal frame was lost and raced its own transcript read against the real one.+ self._publish_pending(ref)except Exception:# The settle fence lost (a reset/compression moved runtime_generation under# the turn). The row stays `started` for recovery -> `unknown`; re-settlingdiff --git a/tests/gateway/fixtures/execution_frames_capture.py b/tests/gateway/fixtures/execution_frames_capture.pyindex e92e9e451bd..9ec0f34ef20 100644--- a/tests/gateway/fixtures/execution_frames_capture.py+++ b/tests/gateway/fixtures/execution_frames_capture.py@@ -62,7 +62,9 @@ async def capture(tmp):await conn.resume(ref, {})await authority.submit(conn.actor, Submission(label, ref, {'text': label}, 'queue'))await authority.sessions['shared'].task- owners[label] = {'authority_epoch': authority.epoch, 'frames': peer.drain('message.complete')}+ # The turn ends with its completion, then the owner's idle snapshot (running=false).+ frames = peer.drain('message.complete') + peer.drain('session.info')+ owners[label] = {'authority_epoch': authority.epoch, 'frames': frames}if label == 'epoch2':revision = db.get_session('shared')['runtime_revision']response = await conn.dispatch({'id': 1, 'method': 'session.mutate', 'params': {diff --git a/tests/gateway/test_session_events_execution_stamp.py b/tests/gateway/test_session_events_execution_stamp.pyindex bac2b141d18..c03b271e9b6 100644--- a/tests/gateway/test_session_events_execution_stamp.py+++ b/tests/gateway/test_session_events_execution_stamp.py@@ -24,7 +24,8 @@ async def test_settled_execution_stops_stamping_idle_mutations_and_desktop_fixtu'queued pending was stamped before any claim'claimed = frames[1:]assert [f['params']['type'] for f in claimed][:1] == ['message.start']- assert claimed[-1]['params']['type'] == 'message.complete'+ assert [(f['params']['type'], f['params']['payload'].get('running')) for f in claimed[-2:]] == [+ ('message.complete', None), ('session.info', False)], 'the idle snapshot preceded the completion'assert all(f['params']['authority_epoch'] == epoch for f in claimed)assert len({f['params']['execution_generation'] for f in claimed}) == 1idle = captured['epoch2']['idle_mutation_frames']