fix(aibridge): recognize hyphenated session-id header from newer Codex releases - #26346
Conversation
|
I think the before and after shots are like one of those "spot the difference" visual games but in this case you're getting punked. |
@tracyjohnsonux yeah so its def "spot the difference" - under "threads" the latest session has 3 threads from Codex whereas before each new message was its own session. but heard - i'll update the screenshots to something more obvious |
|
Updated the before/after with the same three-prompt conversation on both sides so the difference is unmissable: before splits it into 3 sessions (Threads: 1 each), after groups it into 1 session with Threads: 3, plus a shot clicked into the session detail showing all 3 threads on the timeline. Note on methodology: the "before" was reproduced by replaying the conversation without the session header, which is exactly what the unfixed code path sees (the pre-fix release can't run against the migrated dev database). 🤖 Coder Agents on behalf of @bpmct |
Codex prompts were showing up as one session per request in the AI Sessions list instead of being grouped into a conversation.
Root Cause
AI Gateway extracts the Codex session key from the
session_idrequest header:https://github.com/coder/coder/blob/main/aibridge/session.go#L57-L58
Newer Codex releases renamed the header to
session-id(hyphen) incodex-rs/codex-api/src/requests/headers.rs:Header.Getis case-insensitive but not underscore/hyphen-insensitive, so no session key is extracted and every request falls back to its own session. Reproduced with Codex CLI 0.139.0.Changes
session-idfirst, fall back to the legacysession_idfor older Codex versionsBefore/After
The same three-prompt Codex conversation ("Write a haiku about Pittsburgh" → "Now make it about Coder" → "Translate it to Spanish", via
codex exec+codex exec resume --last) against a local build.Before: each prompt of the conversation lands as its own session, Threads: 1
After: the conversation is a single session with Threads: 3
Clicking into the session shows all three threads on the session timeline:
Linear: AIGOV-437
🤖 Generated with Coder Agents on behalf of @bpmct