Skip to content

[codex] Round-trip model-bound turn state - #27683

Closed
aibrahim-oai wants to merge 1 commit into
mainfrom
codex/model-bound-turn-state
Closed

[codex] Round-trip model-bound turn state#27683
aibrahim-oai wants to merge 1 commit into
mainfrom
codex/model-bound-turn-state

Conversation

@aibrahim-oai

Copy link
Copy Markdown
Contributor

What

  • bind the opaque x-codex-turn-state token to the requested model slug
  • round-trip request-scoped turn state through HTTP, WebSocket response.create.client_metadata, and compact responses
  • explicitly reset WebSocket turn state for a new turn/model while preserving handshake-only servers as a deferred fallback
  • reuse the same model-bound client session across inline compaction

Companion to backend PR: https://github.com/openai/openai/pull/1018026

Why

WebSocket upgrade headers are connection-scoped, so a reused connection cannot carry the correct per-request turn state. Compact responses also previously dropped the response header. A single unqualified OnceLock could retain state from an older requested model during pre-turn compaction.

The client now treats response metadata as authoritative, uses a handshake token only after a response attempt produces no metadata, and replaces the state when the requested slug changes.

Validation

  • cargo check -p codex-core
  • focused codex-core routing/WS/compact suite: 8 passed
  • just test -p codex-api: 123 passed
  • just fix -p codex-api
  • cargo fmt --all

Copy link
Copy Markdown
Contributor Author

Superseded by the smaller stacked PRs #27930#27931#27929. The new stack removes the handshake fallback and keeps HTTP, compact, and WebSocket request metadata reviewable independently.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant