The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(api): the Responses identity bound holds from store open
Teknium8edf28ccbbb0
diff --git a/gateway/platforms/api_server_response_store.py b/gateway/platforms/api_server_response_store.pyindex ab65dfb57e6..1408b5cfbc2 100644--- a/gateway/platforms/api_server_response_store.py+++ b/gateway/platforms/api_server_response_store.py@@ -78,7 +78,9 @@ class ResponseStore:# Rows written before settlement was tracked: settled iff their replay record survives.self._mark_settled('1', ())self._settle_terminal_admissions()- self._conn.commit()+ # The identity bound holds from open, not only from the next write (a lowered bound or a+ # store that crashed past it would otherwise keep every settled identity until then).+ self._evict_and_commit()# Conversation history lives here: owner-only perms, once at init (not per commit).self._tighten_file_permissions()diff --git a/tests/gateway/test_responses_identity_bound_on_open.py b/tests/gateway/test_responses_identity_bound_on_open.pynew file mode 100644index 00000000000..786c6bd8bb6--- /dev/null+++ b/tests/gateway/test_responses_identity_bound_on_open.py@@ -0,0 +1,19 @@+"""A reopened Responses store enforces its settled-identity bound before serving a request."""+from gateway.platforms.api_server_response_store import ResponseStore+++def test_reopen_prunes_settled_identities_to_the_bound(tmp_path):+ path = str(tmp_path / 'response_store.db')+ store = ResponseStore(db_path=path, max_size=10, max_identities=10)+ for index in range(4):+ key = f'idem:scope:k{index}'+ assert store.bind_request_key(key, 'fp')+ store.put(key, {'fingerprint': 'fp', 'response': {'id': f'resp_{index}'}})+ assert store._conn.execute('SELECT COUNT(*) FROM response_keys WHERE settled_at IS NOT NULL').fetchone()[0] == 4+ store.close()+ reopened = ResponseStore(db_path=path, max_size=10, max_identities=1)+ try:+ kept = [row[0] for row in reopened._conn.execute('SELECT request_key FROM response_keys')]+ assert kept == ['idem:scope:k3'], kept+ finally:+ reopened.close()