Scope Responses API conversation names by session key - #47294
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for identifying the Responses API isolation gap. The API premise is confirmed on current main: named conversations are looked up globally at gateway/platforms/api_server.py:3277 and persisted globally at gateway/platforms/api_server.py:3520; the streaming snapshot path has the same behavior at gateway/platforms/api_server.py:2767.
Problems
- The bundled webhook retry cleanup cannot observe real agent-run failures. Its callback watches the task that awaits
handle_message(gateway/platforms/webhook.py:675in this PR), but currenthandle_messageis fire-and-forget (gateway/platforms/base.py:4608-4615). Actual processing failures are reported throughon_processing_complete(gateway/platforms/base.py:5174-5180,5226-5235). The added test mockshandle_messageitself (tests/gateway/test_webhook_adapter.py:642), so it does not exercise that lifecycle.
Suggested changes
- Please split or remove the unrelated webhook commits from this API-scoping PR.
- For a separate webhook fix, clear failed delivery IDs from
on_processing_completebased on its failure outcome and test the real background pipeline.
Automated hermes-sweeper review.
| task = asyncio.create_task(self.handle_message(event)) | ||
| self._background_tasks.add(task) | ||
| task.add_done_callback(self._background_tasks.discard) | ||
| def _forget_failed_delivery(done_task: "asyncio.Task") -> None: |
There was a problem hiding this comment.
handle_message() is fire-and-forget: it schedules _process_message_background and returns, so this task normally succeeds even when the actual agent run later fails. Release this ID from the existing on_processing_complete lifecycle hook using its failure outcome; the current test hides the issue by mocking handle_message itself.
8dbd9cc to
305da95
Compare
Summary
This scopes Responses API
conversationchaining toX-Hermes-Session-Keywhen the header is present. Previously, conversation names were global, so two different clients using the same conversation name could chain into each other's stored response history.Why
X-Hermes-Session-Keyis the long-term memory boundary. If two clients use the same conversation name under different keys, the server should keep those chains isolated instead of reusing the latest response ID from another key.Changes
Tests