fix(agent): dedup codex incomplete interims on visible content - #65063
Merged
Conversation
Two consecutive incomplete assistant interims with identical visible content (content + reasoning) are collapsed even when opaque provider state (encrypted reasoning item ids, message item phases) drifts per continuation — previously that drift defeated dedup and caused message storms (#52711). The latest opaque payload is written onto the existing message in place, so continuation replay still uses fresh provider state. Salvage note: the original PR also made the 3-retry continuation cap cumulative per turn (no reset on progress). That half is intentionally dropped — a legitimate long turn alternating incomplete/progress would hard-fail at 3 cumulative, changing semantics beyond the reported bug.
This was referenced Jul 15, 2026
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.
Summary
Consecutive incomplete Codex interim messages with identical visible content are now deduplicated even when opaque provider state drifts between continuations — ending the duplicate "Working on it..." message storms (#52711).
Salvages the dedup half of #52716 (@liuhao1024) with authorship preserved.
Root cause: the interim dedup compared encrypted reasoning item ids and message item phases alongside visible text. Those opaque payloads legitimately change on every continuation, so the comparison never matched and every retry emitted another identical bubble.
Changes (@liuhao1024)
agent/conversation_loop.py: duplicate detection compares only what the user sees (content + reasoning); when a visible duplicate is found, the latest opaque payload (codex_reasoning_items,codex_message_items) is written onto the existing message in place, so continuation replay still carries fresh provider state without a new visible messageSalvage scope note
The original PR also made the 3-retry continuation cap cumulative per turn (never resetting on progress). That half is intentionally dropped: a legitimate long turn that alternates incomplete/progress several times would hard-fail at 3 cumulative attempts — a semantics change beyond the reported bug that risks breaking healthy long turns. The counter-reset-on-progress behavior on main is unchanged. If the alternating-bypass concern materializes in reports, it can be revisited as its own scoped change.
Validation
scripts/run_tests.sh tests/run_agent/test_run_agent_codex_responses.py: 94/94 passed on current main (post-fix(codex): rescue reasoning-only turns from the 3-attempt continuation death loop #64768 — clean integration with the continuation-nudge block)rs_2state winning in place; progress never dedupedInfographic