Skip to content

fix(responses): preserve WS upgrade reasoning signal - #7465

Closed
Ingwannu wants to merge 1 commit into
devfrom
fix/ws-upgrade-reasoning-header-7462
Closed

Ingwannu wants to merge 1 commit into
devfrom
fix/ws-upgrade-reasoning-header-7462

Conversation

@Ingwannu

Copy link
Copy Markdown
Owner

Summary

Fixes #7462 for the canonical ChatGPT WS-to-HTTP/SSE response path.

A native upstream can send x-reasoning-included only on its successful 101 upgrade. The session previously discarded it, so the relay committed an SSE response without the actual signal. Capture Bun's optional native handshake event before open, validate the bounded raw-header shape, retain only that connection-level signal and seed each exchange's existing metadata owner before dispatch. Prelude metadata keeps precedence; later frames stay in-band without rewriting committed headers.

Only the actual upstream value is carried. Absent/malformed/ambiguous/oversized observations stay absent; credentials, cookies, request IDs and stale quota snapshots are not retained. Reused exchanges get private snapshots; close/disposal clears the connection value. No retry/fallback, tool execution, token totals, or model capability is added. This does not retrofit an already-committed client WebSocket upgrade or establish the cause of an early-compaction incident.

The mapped contract is documented in a focused structure document and ADR (the existing wire-shape owner was already at its 600-line budget), with a user-facing protocol note. No dependency, workflow or live configuration changes.

Verification

Base: 12025981e5a304cdb6b1b54f525ba8554f623977. Serial Linux execution as ubuntu in disposable HOME/CODEX_HOME/OPENCODEX_HOME, under hard cgroup CPU/RAM/swap/process/time limits.

  • Failure before: the six real-loopback upgrade cases on pristine dev/Bun 1.4.2 produced 2 passed, 4 failed (true/false upgrade-only propagation, late-frame HTTP header preservation, retained connection propagation).
  • Production Bun 1.4.2: bun test tests/responses/ws-upgrade-reasoning-header.test.ts tests/responses/ws-upstream.test.ts tests/responses/ws-upstream-reuse.test.ts tests/responses/ws-pre-output-refusal.test.ts tests/responses/ws-failure-stage.test.ts: 232 passed, 1 intentional older-runtime-only skip, 0 failed. Covers actual sockets/usage, malformed bounds, reuse, cancellation, fallback, refusal and stage accounting.
  • Test Bun 1.4.3: new suite plus tests/test-layout.test.ts, tests/test-layout-tooling.test.ts, tests/ci-workflows/file-size-ratchet.test.ts: 52 passed, 0 failed. Both layout maps updated; no size cap raised.
  • bun scripts/structure-ssot.ts --fix (index generation + validation), bun scripts/privacy-scan.ts, and git diff --cached --check: passed.
  • Frozen matching docs dependencies reused from an isolated workspace. RAYON_NUM_THREADS=2 UV_THREADPOOL_SIZE=2 bun node_modules/astro/bin/astro.mjs build: passed, 585 pages / 83,065 internal links. An initial attempt aborted during Pagefind under the same process cap; limiting worker threads passed without raising resource limits.
  • Five protected real-home configuration files checked unchanged (existence, UID/GID, mode, size and digest); no service, live account, external provider or live config operation performed.

Resource exception / remaining validation: full project typecheck exceeded the local five-minute envelope twice during this same maintenance session on the same dependency graph; do not present that as a pass. Full-suite and import-graph expansion are deferred to the existing hosted CI for this Draft, with the focused and indirect subprocess/relay/layout coverage above executed locally. The exact new PR head still needs its actual hosted typecheck/test execution and independent review. No Codex Security scan was invoked.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.
    • Manual response-header boundary review: only the existing allowlisted reasoning signal, existing byte/count/value budgets, no credentials/cookies, no destination or authentication changes. No Codex Security scan.

Review readiness checklist

  • Required local validation passed; commands, results, and any full-suite exception are documented.
  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • I resolved all correct Codex and CodeRabbit findings.
  • My PR is ready for review.

@coderabbitai

coderabbitai Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@Ingwannu

Copy link
Copy Markdown
Owner Author

Superseded by the earlier contributor PR #7464, which arrived while this independent fix was being prepared. I validated its exact head 4e9212662e3e173ab7e5372b712da6c1fdecd54d: 250 passed / 1 intentional platform-runtime skip / 0 failed on Bun 1.4.2, including my independently written six loopback controls; 64 passed on Bun 1.4.3 with layout/ratchet guards. The manual header-boundary review and results are recorded there. Closing my duplicate to keep one implementation under review; #7462 stays open until verified integration. This branch is retained as an evidence artifact, not merged or released.

@Ingwannu Ingwannu closed this Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant