Skip to content

fix(openai): complete Codex state and compact probing - #5687

Open
lyy0709 wants to merge 1 commit into
Wei-Shaw:mainfrom
lyy0709:codex/codex-state-probe-followup
Open

fix(openai): complete Codex state and compact probing#5687
lyy0709 wants to merge 1 commit into
Wei-Shaw:mainfrom
lyy0709:codex/codex-state-probe-followup

Conversation

@lyy0709

@lyy0709 lyy0709 commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #5668, limited to the Codex state-machine, remote-compaction capability probe, and beta/default upgrade gaps that remained after that PR.

  • bind each exact opaque x-codex-turn-state value to the OAuth account that actually delivered it, persist only a scoped digest across instances, and strip only known cross-account echoes
  • record provenance only after the downstream header/body write succeeds; cover native and passthrough, streaming and non-streaming, including already-committed compact keepalives
  • keep OpenAI API-key traffic transparent: relay the header but never create or enforce OAuth provenance
  • make the compact probe follow Codex RemoteCompactionV2 collection semantics: require response.completed, count only response.output_item.done, require exactly one compaction item, permit unrelated done items, and ignore bytes after the first terminal
  • preserve the official compaction_summary serde alias, while removing added-only fallback and compaction deduplication that could hide malformed streams
  • add tri-state, versioned, expiring probe snapshots; bounded response reads; cancellation-detached persistence; monotonic database updates; and a migration that invalidates snapshots created by the old permissive probe
  • normalize beta-feature headers case-insensitively and preserve native-v2/session defaults without changing API-key Responses routing

Official Codex reference audited at 49db349ffdd888f5e3c91abf9b7519d8631e6e9a:

Regression coverage

New and expanded tests cover:

  • exact opaque state values, same-value recommit, API-key/session isolation, cross-instance lookup, cancellation, write failures, keepalive-committed headers, and all four native/passthrough stream modes
  • LF/CRLF/lone-CR SSE, BOM, comments, multi-line data, no-colon fields, EOF dispatch, [DONE], terminal ordering, added-only output, duplicate compaction items, aliases, incomplete/truncated/oversized/read-error bodies, and 2xx/error status matrices
  • supported/unsupported/unknown transitions, protocol version/TTL/skew boundaries, concurrent 24-writer monotonic convergence, unknown diagnostics, duplicate-account cleanup, and migration behavior/idempotence
  • beta token casing, duplicate removal, override preservation, native-v2 forcing, OAuth defaults, API-key transparency, and probe identity parity

Verification

  • cd backend && go test ./... -count=1
  • cd backend && go test -tags=unit ./... -count=1
  • cd backend && go test -tags=integration ./... -count=1
  • targeted go test -race for the changed service/repository paths
  • cd backend && golangci-lint run ./...
  • make test
  • pnpm --dir frontend run test:run (223 files, 1547 tests)
  • pnpm --dir frontend run test:coverage (223 files, 1547 tests)
  • make build

No frontend, dependency, lockfile, or version metadata changes are included.

Copilot AI lite review requested due to automatic review settings August 16, 2026 02:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants