Rectify Codex Session Result Adaptation — Context Exhaustion and Recovery Paths#3393
Merged
Trecek merged 4 commits intoMay 31, 2026
Conversation
Add structured error_code field to _CodexParseAccumulator, store it on turn.failed events, include in raw dict, and use it in _adapt_agent_result for context exhaustion detection and API error status mapping. - Add error_code: str = "" to _CodexParseAccumulator - Store acc.error_code in turn.failed handler - Include error_code in raw dict from parse_stdout - Populate errors from agent_result.error (was always []) - Map rate_limit_exceeded -> api_error_status=429 - Use CODEX_CONTEXT_EXHAUSTION_MARKER constant for structured detection - Update tests: fix round-trip assertion, add 5 new tests, remove Phase C simulation Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
CanonicalTokenUsage.from_codex_dict requires output_tokens key; the test fixture was missing it, causing KeyError on turn.completed events.
…ops falsy int status codes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ver new field Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
17066c1 to
1fc9fed
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.