Skip to content

api-server: /v1/chat/completions on 0.6.0 lacks stable session continuity by default #4507

Closed

Description

@intobigdata

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

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/completions by 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:

Idempotency / duplicate handling:

API-server stability around chat completions / streaming:

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-Id
    • X-Chat-ID
  • deriving a stable fallback session ID when explicit continuity was absent
  • rejecting identical in-flight non-streaming requests with 409 instead 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

  1. added
    type/bugSomething isn't working
    P2Medium — degraded but workaround exists
    comp/gatewayGateway runner, session dispatch, delivery
    on May 1, 2026
  2. DavidMetcalfe commented on Jun 26, 2026

    @DavidMetcalfe

    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-Id request/response header for opt-in session continuity on /v1/chat/completions
    • Lazy-init SessionDB on the adapter instance (single SQLite connection reused across requests)
    • Session ID echoed in both streaming and non-streaming responses
    • Without the header: behavior unchanged (new UUID per request, stateless) — no breaking change

    The related PRs cited in this issue's body:

    The current codebase (v2026.6.19) also has follow-up work: X-Hermes-Session-Key for long-term memory scoping (#20199), session continuation validation and security, and previous_response_id chain continuity (#10059).

    This should be closable — the reporter's concerns are addressed on current main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/gatewayGateway runner, session dispatch, deliverytype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions