The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(api_server): a streaming store:false response keeps no snapshot or conversation pointer
Teknium9fa23598eb7f
diff --git a/gateway/platforms/api_server_openai_routes.py b/gateway/platforms/api_server_openai_routes.pyindex 81665ffaa05..05dd355bb94 100644--- a/gateway/platforms/api_server_openai_routes.py+++ b/gateway/platforms/api_server_openai_routes.py@@ -689,8 +689,10 @@ class _ResponsesStream:def _commit_terminal(self, env, full_history, session_id, record):"""The terminal snapshot plus, when keyed, the replay record and its read-back: one store- unit, so no other observer of the same key interleaves between them. -> stored record."""- self._persist_snapshot(env, full_history, session_id)+ unit, so no other observer of the same key interleaves between them. -> stored record.+ ``store: false`` skips only the snapshot; the keyed replay record is idempotency state."""+ if self.store:+ self._persist_snapshot(env, full_history, session_id)if not self.durable_key:return Noneif record is not None:diff --git a/tests/gateway/test_api_responses_store_off_loop.py b/tests/gateway/test_api_responses_store_off_loop.pyindex ab7a8db2e62..6a0df376b1f 100644--- a/tests/gateway/test_api_responses_store_off_loop.py+++ b/tests/gateway/test_api_responses_store_off_loop.py@@ -57,3 +57,34 @@ async def test_response_store_writes_leave_the_loop_and_read_back_at_once(api, oassert (await fetched.json())['status'] == 'completed'assert put_threads, 'nothing was persisted'assert loop_thread not in put_threads, 'ResponseStore.put ran on the event loop thread'++[email protected]('stream', [False, True])+async def test_store_false_keeps_no_snapshot_and_no_conversation_pointer(api, owner, stream):+ from gateway.session_results import execution_result++ async def handle(event):+ execution_result.get()['result'] = {'final_response': 'ok', 'messages': []}+ return 'ok'++ owner.runner._handle_message = handle+ api._api_key = _API_KEY+ app = web.Application()+ app.router.add_post('/v1/responses', api._handle_responses)+ app.router.add_get('/v1/responses/{response_id}', api._handle_get_response)+ async with TestClient(TestServer(app)) as client:+ body = {'input': 'private question', 'conversation': 'ephemeral', 'stream': stream, 'store': False}+ posted = await client.post('/v1/responses', json=body, headers=_AUTH)+ text = await posted.text()+ assert posted.status == 200, text+ if stream:+ done = [json.loads(line[6:]) for line in text.splitlines()+ if line.startswith('data: ') and '"response.completed"' in line]+ response_id = done[-1]['response']['id']+ else:+ response_id = json.loads(text)['id']+ fetched = await client.get('/v1/responses/' + response_id, headers=_AUTH)+ assert fetched.status == 404, 'store:false response was retained'+ assert api._response_store.get_conversation('ephemeral') is None+