Skip to content

fix(gateway): remove hidden incomplete reasoning from replay recovery - #67786

Closed
KKamJi98 wants to merge 1 commit into
NousResearch:mainfrom
KKamJi98:pr/replay-recovery-hardening
Closed

fix(gateway): remove hidden incomplete reasoning from replay recovery#67786
KKamJi98 wants to merge 1 commit into
NousResearch:mainfrom
KKamJi98:pr/replay-recovery-hardening

Conversation

@KKamJi98

Copy link
Copy Markdown

Summary

  • strip only trailing hidden/incomplete reasoning turns from replayed live history during the FTS-lag recovery path
  • preserve visible assistant content, tool calls, and genuine corruption recovery
  • guard Codex incomplete-reasoning nudge prefix drift

Validation

  • replay cleanup + recovery + adjacent suites: 84 passed
  • adversarial review: blocking 0
  • ruff and diff checks: pass

Scope is limited to the FTS-lag recovery path; normal replay behavior is unchanged.

…ive history

A retry-exhausted Codex turn ends as an assistant message with
finish_reason=incomplete, hidden reasoning only, and no visible answer or
tool call. The gateway keeps that turn out of the persisted transcript, but
the cached agent still holds it in live _session_messages. When the FTS
write-corruption guard (#50502) resurrects the live transcript because disk
persistence lagged, the poisoned tail is replayed to the provider and seeds
another incomplete continuation loop.

Add agent/replay_cleanup.strip_incomplete_reasoning_tail to drop that tail
(plus interleaved _CODEX_INCOMPLETE_NUDGE user messages) and apply it in the
gateway's FTS-lag reconciliation path before the stale-confirmation expiry.
Visible partial answers, completed turns, and tool-call turns are never
stripped, so genuine FTS-corruption recovery is preserved. The nudge is
matched by prefix to avoid a conversation_loop import cycle; a regression
test guards against drift.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery provider/openai OpenAI / Codex Responses API codex sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 20, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related to merged #65062: that change suppresses the incomplete gateway result, while this patch removes the lingering hidden-reasoning tail only when FTS-lag recovery resurrects cached live history.

@KKamJi98 KKamJi98 closed this Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint 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 sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants