Skip to content

fix(gateway): suppress hidden-reasoning-only incomplete Codex turns - #65062

Merged
teknium1 merged 2 commits into
mainfrom
fix/51628-gateway-hidden-incomplete
Jul 15, 2026
Merged

fix(gateway): suppress hidden-reasoning-only incomplete Codex turns#65062
teknium1 merged 2 commits into
mainfrom
fix/51628-gateway-hidden-incomplete

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Retry-exhausted Codex turns that produced only hidden reasoning (no visible answer) are no longer posted into gateway channels — the "Codex response remained incomplete after 3 continuation attempts" sentinel stays out of the conversation, where peer agents were re-ingesting it as a completed assistant turn and waking each other up.

Salvages #51657 (@LeonSGP43, fixes #51628) with authorship preserved, plus one substantive follow-up.

Changes

  • gateway/run.py: _is_gateway_hidden_reasoning_incomplete_turn() detects the exhaustion shape; the sentinel is blanked before delivery, only the user message is persisted to the transcript (mirroring the [Bug] Rate limit (429/timeout) failures silently drop user messages from transcript — #1630 regression #7100 transient-failure rule), and full diagnostics stay in the logs (@LeonSGP43)
  • Follow-up (ours): the original detector never fired on real exhaustion turns. It required final_response to be falsy, but the conversation loop returns the sentinel as BOTH final_response and error — so the sentinel was delivered verbatim, exactly the poisoning vector. The detector now recognizes the sentinel echo, and a genuinely different final text is never suppressed. Also blanks the sentinel at the delivery site (before empty-response normalization), fixes the test fixture to mirror the real loop shape and the has_platform_message_id dedupe mock, and adds two guard tests.

Validation

Turn shape Before After
exhaustion sentinel as final_response (real loop shape) delivered verbatim into channel suppressed; user message persisted; logged
genuine answer + error field set delivered delivered (never suppressed)
interrupted / failed turns own handling own handling (unchanged)
  • scripts/run_tests.sh on the new suite + adjacent gateway persistence suites (test_tool_response_drop_recovery, test_empty_model_recovery): 25/25 passed
  • The salvaged test now exercises the REAL conversation-loop result shape — with the original detector it fails, with the hardened one it passes

Complements #64768 (which makes exhaustion rarer); this is defense-in-depth for when it still happens.

Infographic

gateway-hidden-incomplete-suppression

LeonSGP43 and others added 2 commits July 15, 2026 07:52
… final_response

Follow-up to the salvaged #51657: the conversation loop returns the
retry-exhaustion sentinel as BOTH final_response and error, so the
original detector (which required final_response to be falsy) never
fired on real exhaustion turns — the sentinel text was delivered
verbatim into the channel, exactly the #51628 poisoning vector. Detect
the sentinel echo, blank it before empty-response normalization, and
never suppress a turn whose final_response is genuine model text.
Also: dedupe-guard mock fix in the test fixture (has_platform_message_id
must return False, not a truthy MagicMock) and two guard tests
(real answer never suppressed; interrupted/failed never classified).
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery provider/openai OpenAI / Codex Responses API codex P2 Medium — degraded but workaround exists sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 15, 2026
@teknium1
teknium1 merged commit 09b6d22 into main Jul 15, 2026
59 of 61 checks passed
@teknium1
teknium1 deleted the fix/51628-gateway-hidden-incomplete branch July 15, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists provider/openai OpenAI / Codex Responses API sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex hidden-reasoning-only incomplete turns can poison gateway sessions

3 participants