The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: omit retired approvals from gateway attach snapshots
Tekniume7ee1d674796
diff --git a/gateway/session_authority.py b/gateway/session_authority.pyindex 350f23eae0b..57e8f35316f 100644--- a/gateway/session_authority.py+++ b/gateway/session_authority.py@@ -90,7 +90,8 @@ class SessionAuthority:if transport is not None:live.event_stream.fanout.attach(transport)handle = self._handle(ref)- prompts = live.controls.snapshot(ref.session_id, handle.execution_generation)+ active_generation = handle.execution_generation if handle.execution_state == "running" else None+ prompts = live.controls.snapshot(ref.session_id, active_generation)epoch, sequence = live.event_stream.watermark()return SubscriptionSnapshot(subscription, handle, epoch,sequence, tuple(self.db.get_messages_as_conversation(ref.session_id)),@@ -254,7 +255,7 @@ class SessionAuthority:outcome = 'failed'settled = settle_session_input(self.db, epoch=self.epoch, admission_id=admission_id,generation=row['generation'], outcome=outcome)- live.controls.snapshot(ref.session_id, row['generation'])+ live.controls.snapshot(ref.session_id, None)live.event_stream.publish(ref.session_id, {'text': response, 'content': response, 'admission_id': admission_id,'outcome': settled['outcome']})diff --git a/tests/gateway/fixtures/control_boundaries.py b/tests/gateway/fixtures/control_boundaries.pyindex e9e57d4e798..ed031814bec 100644--- a/tests/gateway/fixtures/control_boundaries.py+++ b/tests/gateway/fixtures/control_boundaries.py@@ -118,6 +118,7 @@ async def exercise_control_boundaries(tmp_path, monkeypatch):tasks.append(orphan)orphan_prompt = await wait_prompt()settle_session_input(db, epoch=epoch, admission_id=row['admission_id'], generation=row['generation'], outcome='completed')+ assert not (await authority.attach(actor, ref)).prompts, 'snapshot presents retired worker approval'with pytest.raises(RuntimeStoreError) as exc:await authority.respond(actor, ref, row['generation'], orphan_prompt['prompt_id'], {'choice': 'once'})assert exc.value.reason == 'stale_generation'