Skip to content

Handle context length errors consistently across response transports - #60482

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/56d8c831c2fad2ca1318318a3b4258fcc516d689
Nov 10, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/56d8c831c2fad2ca1318318a3b4258fcc516d689

Conversation

@copyberry

@copyberry copyberry Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Handle context length errors consistently across response transports

Why

HTTP 400 responses with context_length_exceeded need to reach context-window recovery so manual compaction can retry with less history. Streaming context-window failures should end the stream immediately.

What changed

  • Map context_length_exceeded through the shared terminal provider error parser for HTTP 400 responses and events without an HTTP status.
  • Return SSE context-window failures immediately.
  • Preserve retryable handling for WebSocket errors carrying HTTP 503, even when their code is context_length_exceeded.

Testing

Add coverage for WebSocket status handling and immediate SSE termination with retry headers. Update the manual compaction test to verify recovery from an HTTP 400 context-window error by dropping one history item and retrying.

…60482)

## Why

HTTP 400 responses with `context_length_exceeded` need to reach context-window recovery so manual compaction can retry with less history. Streaming context-window failures should end the stream immediately.

## What changed

- Map `context_length_exceeded` through the shared terminal provider error parser for HTTP 400 responses and events without an HTTP status.
- Return SSE context-window failures immediately.
- Preserve retryable handling for WebSocket errors carrying HTTP 503, even when their code is `context_length_exceeded`.

## Testing

Add coverage for WebSocket status handling and immediate SSE termination with retry headers. Update the manual compaction test to verify recovery from an HTTP 400 context-window error by dropping one history item and retrying.

GitOrigin-RevId: 56d8c831c2fad2ca1318318a3b4258fcc516d689
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/56d8c831c2fad2ca1318318a3b4258fcc516d689 branch from 80a05f4 to 1885417 Compare November 10, 2026 00:55
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor
Codex Review Summary: 🔄 Running

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-11-10T00:55:58.175675Z 80a05f4 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@copyberry
copyberry Bot merged commit 1885417 into main Nov 10, 2026
8 of 23 checks passed
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/56d8c831c2fad2ca1318318a3b4258fcc516d689 branch November 10, 2026 00:56
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 10, 2026

This branch was previously deployed

1 inactive deployment
issue-triage — 1885417c Deployed Nov 10, 2026 by Saber-1st via Generate label suggestions #62488
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.

4 participants