You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Treat Codex Responses status=incomplete / incomplete_details.reason=max_output_tokens as a resumable Codex incomplete turn instead of the generic chat-completions length failure path.
Add a pre-API request pressure check during every tool-loop iteration so long tool-heavy turns compact before they consume the entire context window and leave no output budget.
Add regressions for both the max-output continuation path and mid-turn compaction after large tool results.
Thanks for the focused fix. I verified the premise against current main and did not find a blocking correctness issue in the patch.
Suggested changes
If this is salvaged, keep both behaviors: the PR's Codex max-output reroute in agent/conversation_loop.py and the current-main final-answer safeguards in agent/codex_responses_adapter.py:1257-1260. They cover different Responses states: max-output incomplete turns vs completed final_answer items on a top-level incomplete response.
Consider tying the new pre-API pressure gate's attempt cap to the existing max_compression_attempts local (agent/conversation_loop.py:875) instead of adding a second literal 3, so future changes to the compression retry budget stay in one place.
Current main still maps Codex status=incomplete / incomplete_details.reason=max_output_tokens to finish_reason="length" at agent/conversation_loop.py:1359-1360, and that generic length path can return Response truncated due to output length limit at agent/conversation_loop.py:1708-1723. The Codex continuation path only runs for finish_reason == "incomplete" at agent/conversation_loop.py:3615, so the PR is aimed at a real branch distinction.
Merged via #58155 — your commit was cherry-picked with authorship preserved (author eliteworkstation94-ai on 1f430e1a on main).
Both fixes landed:
The Codex status=incomplete / max_output_tokens reroute to finish_reason="incomplete" (routes into the existing Codex continuation path instead of the generic "Response truncated due to output length limit" rollback).
The per-iteration pre-API context-pressure compaction.
Two follow-up commits on top (ours): the mid-turn compaction now re-baselines the flush cursor via conversation_history_after_compression() so it doesn't double-persist under the default in-place compaction, and the trigger is gated through the turn-prologue preflight guard chain (should_defer_preflight_to_real_usage → compression-failure cooldown → should_compress) so it reuses the canonical threshold_tokens and honors the anti-thrash / cooldown / defer guards.
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
comp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointP2Medium — degraded but workaround existstype/bugSomething isn't working
4 participants
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.
Summary
status=incomplete/incomplete_details.reason=max_output_tokensas a resumable Codex incomplete turn instead of the generic chat-completions length failure path.Test plan
python -m pytest tests/run_agent/test_run_agent.py tests/run_agent/test_run_agent_codex_responses.py -q -o 'addopts='python -m py_compile agent/conversation_loop.py tests/run_agent/test_run_agent.py tests/run_agent/test_run_agent_codex_responses.pygit diff --check -- agent/conversation_loop.py tests/run_agent/test_run_agent_codex_responses.py