Revert "[codex] Harden overflow auto-compaction recovery"#22170
Conversation
This reverts commit 15e79f3.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2804e5060f
ℹ️ 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".
| Err(CodexErr::ContextWindowExceeded) => { | ||
| sess.set_total_tokens_full(&turn_context).await; | ||
| if retries >= max_retries { | ||
| return Err(CodexErr::ContextWindowExceeded); | ||
| } | ||
| retries += 1; | ||
| let reset_client_session = match run_auto_compact( | ||
| &sess, | ||
| &turn_context, | ||
| client_session, | ||
| InitialContextInjection::BeforeLastUserMessage, | ||
| CompactionReason::ContextLimit, | ||
| CompactionPhase::MidTurn, | ||
| ) | ||
| .await | ||
| { | ||
| Ok(reset_client_session) => reset_client_session, | ||
| Err(_) => return Err(CodexErr::TurnAborted), | ||
| }; | ||
| if reset_client_session { | ||
| client_session.reset_websocket_session(); | ||
| } | ||
| continue; | ||
| return Err(CodexErr::ContextWindowExceeded); |
There was a problem hiding this comment.
Restore overflow compaction before returning context errors
Returning immediately on ContextWindowExceeded prevents the overflow recovery path from running. If the provider rejects a sampling request for input size before the pre/post token thresholds trigger, long threads now surface an error instead of compacting and retrying, so the next user turn remains stuck over the context window.
Useful? React with 👍 / 👎.
Reverts #22141