Skip to content

Conversation

@aibrahim-oai
Copy link
Collaborator

@aibrahim-oai aibrahim-oai commented Jan 16, 2026

  • capture the header from SSE/WS handshakes, store it per ModelClientSession using Oncelock, echo it on turn-scoped requests, and add SSE+WS integration tests for within-turn persistence + cross-turn reset.

  • keep x-codex-turn-state sticky within a user turn to maintain routing continuity for retries/tool follow-ups.

@aibrahim-oai aibrahim-oai changed the title Scope turn_state per turn with SSE/WS tests Turn-state sticky routing per turn Jan 16, 2026
@aibrahim-oai
Copy link
Collaborator Author

@codex review this

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1773236c50

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 156 to 159
static REQWEST_CLIENT: LazyLock<reqwest::Client> = LazyLock::new(|| {
use reqwest::header::HeaderMap;

let mut headers = HeaderMap::new();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve updated originator/User-Agent headers

Because REQWEST_CLIENT is initialized once from originator() and get_codex_user_agent(), later updates to USER_AGENT_SUFFIX/set_default_originator (e.g., the app-server or MCP initialize handlers) never reach the cached client. AuthManager::new calls create_client before initialize, so requests sent after client info is set will still use the default originator and omit the suffix. Previously each build_reqwest_client() rebuilt headers, so this change prevents per-client identification in any process that sets these values after startup.

Useful? React with 👍 / 👎.

@aibrahim-oai
Copy link
Collaborator Author

@codex review this

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Collaborator

@jif-oai jif-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff

pub session_source: Option<SessionSource>,
pub extra_headers: HeaderMap,
pub compression: Compression,
pub turn_state: Option<Arc<OnceLock<String>>>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That feels strange as a type but actually it works pretty nicely. OOC, was this your idea or Codex idea?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my idea

use tracing::debug;
use tracing::trace;

pub(crate) fn spawn_chat_stream(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 weeks before nuking this endpoint!!!!

@aibrahim-oai aibrahim-oai merged commit ebdd879 into main Jan 16, 2026
58 of 64 checks passed
@aibrahim-oai aibrahim-oai deleted the turn-state branch January 16, 2026 17:30
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants