Repository navigation
Conversation
An inline '/new <message>' request creates the session binding before the gateway is contacted. When the buffered turn then fails (gateway unavailable or submit error), the response carried no X-Hermes-Session-Id, so the caller never learned the chat id, the retained reset binding became unreachable, and headerless retries forked into fresh :general sessions instead of the reset one. Set the session header once for the whole turn (success and failure paths alike) so a failed /new returns a usable session token and a retry with that header reaches the same reset session. Closes OpenBMB#502.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An inline
/new <message>request creates the session binding (api_server:chat=<chatId>:s_<uuid>) inApiServerSessionMapper.resolve()before the gateway is contacted. When the buffered turn then fails, the response carried noX-Hermes-Session-Idheader:bufferedTurnpreflight gateway-unavailable → 503 without the headersubmitTurnthrowing mid-turn → 500 without the headerstreamTurnpreflight gateway-unavailable → 503 without the headerThe caller never learns the generated chat id, the retained reset binding becomes unreachable, and headerless retries resolve to fresh
:generalsessions — silently forking the conversation history. Retries that supply the returned token do reach the reset session, so exposing the token is the "return a usable session token" recovery path from #502.Closes #502.
Change
Set
X-Hermes-Session-Idonce inhandleChatCompletionsright after the turn is admitted, so every response for the turn carries the session id — success and failure paths alike. This also removes the two redundant per-pathsetHeadercalls (buffered success, streaming pre-flight) without changing their observable behavior.Scope note: the bare
/newack path (no trailing message) returns before this point and is intentionally untouched — it is covered by #679.Tests
New
tests/adapters/channel/api-server-session-header.spec.ts(in-memoryhandleRequestfixtures, deterministic mapper UUID):buffered inline /new failure exposes the session id and retries reach the reset session— 500 response carries the header; a retry that echoes it hits the same:s_session instead of:general.buffered gateway-unavailable inline /new exposes the session id— 503 carries the header, binding retained.streaming preflight gateway-unavailable inline /new exposes the session id— 503 carries the header, binding retained.buffered success still exposes the session id— control.Validation (Windows, Node v24.15.0,
node --import tsx --test):1732d07, tests only): 4 tests, 1 pass / 3 fail — the three failure-path tests fail against the old code, reproducing the issue.pnpm exec tsc -p tsconfig.json --noEmit: clean.