Repository navigation
Description
Summary
On a local Hermes Agent 0.6.0 install, /v1/chat/completions did not preserve stable chat session identity by default and provided little protection for accidental duplicate non-streaming requests.
The Hermes CLI control path did not show this issue. The problem was specific to the API-server chat-completions path.
Environment
- Hermes Agent version:
0.6.0 - Local fork head used for investigation:
83dec2b3ec0f6d0ddc5750f9a9e811a6a355a49f - Python:
3.12.10 - Provider config used during reproduction:
- model:
gpt-5.4 - provider:
openai-codex - base_url:
https://chatgpt.com/backend-api/codex
- model:
I only tested this against the provider configuration above. I have not yet reproduced it against a more standard provider setup.
Observed behavior on 0.6.0
In local gateway/platforms/api_server.py, the /v1/chat/completions path still created a fresh session ID per request unless the caller implemented its own workaround.
Practical symptoms:
- no stable session continuity on
/v1/chat/completionsby default - difficult to distinguish intended follow-up calls from accidental duplicate inbound requests
- no broad in-flight rejection for identical non-streaming requests unless the caller already supplied
Idempotency-Key
Related upstream work
Session continuity:
- [Feature]: Persist /v1/chat/completions sessions so Open WebUI chats appear in
hermes sessions list#3438: feature request to persist/v1/chat/completionssessions - feat(api_server): persist /v1/chat/completions sessions via X-Chat-ID header #3439: attempted
X-Chat-ID-based session persistence - feat(api-server): derive stable chat session IDs for chat completions #3622: attempted stable derived chat session IDs
- feat(api-server): add X-Hermes-Session-Id header for session continuity #4333: attempted
X-Hermes-Session-Idcontinuity - feat(api-server): add X-Hermes-Session-Id header for session continuity #4478: merged
X-Hermes-Session-Idcontinuity work
Idempotency / duplicate handling:
- commit
80cc27eb: earlier idempotency-related api-server work - fix(api-server): allow Idempotency-Key in CORS headers (salvage #3384) #3530: allow
Idempotency-Keyin CORS headers
API-server stability around chat completions / streaming:
- fix(api-server): add CORS headers to streaming SSE responses #3573: add CORS headers to streaming SSE responses
- fix(api-server): cancel orphaned agent + true interrupt on SSE disconnect (salvage #3399) #3427: cancel orphaned agent and interrupt on SSE disconnect
From this investigation, 0.6.0 still appears to miss at least some of the later session-continuity improvements that were discussed and/or merged afterward.
Local patch that fixed the issue
A narrow local patch to gateway/platforms/api_server.py fixed the API-session problem by:
- honoring caller-provided session continuity headers:
X-Hermes-Session-IdX-Chat-ID
- deriving a stable fallback session ID when explicit continuity was absent
- rejecting identical in-flight non-streaming requests with
409instead of starting another run
After this patch, the API-server chat-completions path had stable session continuity and behaved consistently with the CLI control path for this issue.
Report drafted with AI writing assistance.
Activity
DavidMetcalfe commentedon Jun 26, 2026
This was fixed by #4478, which merged ~4.5 hours before this issue was filed. The fix shipped in v2026.4.3.
What #4478 delivered:
X-Hermes-Session-Idrequest/response header for opt-in session continuity on/v1/chat/completionsSessionDBon the adapter instance (single SQLite connection reused across requests)The related PRs cited in this issue's body:
The current codebase (v2026.6.19) also has follow-up work:
X-Hermes-Session-Keyfor long-term memory scoping (#20199), session continuation validation and security, andprevious_response_idchain continuity (#10059).This should be closable — the reporter's concerns are addressed on current main.