Skip to content

fix(codex): keep same-run retries working after accepted steering - #10

Merged
tomorrowflow merged 1 commit into
mainfrom
fix/codex-steer-retry-history
Oct 2, 2026
Merged

tomorrowflow merged 1 commit into
mainfrom
fix/codex-steer-retry-history

Conversation

@tomorrowflow

Copy link
Copy Markdown
Owner

Problem

Long Codex turns that were steered mid-run failed with Current-turn transcript admission identity changed: <entryId> (SessionTranscriptReadFenceError). The work was done, but no reply was delivered. On the live Gateway this happened twice on 2026-10-02, after a 103-minute turn and a 10-minute turn in the same Control UI session.

Sequence, from the journal and the transcript rows:

  1. A user steers the running turn. reply-run-registry.message-injection.ts calls confirmSteerTargetRunIdForPersistence, which rewrites the steer row and rotates the transcript generation.
  2. The turn ends with tool results but no final text. Settled-turn capture fails (byte_limit / provenance_rejected).
  3. transient same-model retry 1/8 … reason=overloaded reruns the Codex attempt with the same run and the original recorder.
  4. prepareCodexAttemptContext → readFencedHistory rereads through the original, now-stale admission, and the fence throws.

Fix

The fenced read ends before the admission and excludes this run's own results, so the first attempt's snapshot is exactly what a reread would return. Retain it per recorder (a WeakMap, lifetime of one logical run) and reuse it for a retry with the same scope: run, admission entry, agent, session id/key/file, store path and context budget. Any other scope rereads and still fails closed on a stale admission. This mirrors upstream's Agents API fix (openclaw#161444). Upstream has no equivalent for Codex yet. The core producer fixes (openclaw#161315, openclaw#160908) are unmerged drafts.

Known gaps, both left alone on purpose:

  • With a context engine active, bootstrap and assembly still read through the receipt and still fail closed. Their effects are engine-owned and not cacheable here. The core receipt refresh in fix: keep Agents API retries working after steering openclaw/openclaw#161315 is the right fix for that path.
  • If earlier history is rewritten between attempts of the same run (compaction), the retry sees the pre-rewrite snapshot. That data is the same session and bounded by the budget, which matches upstream's Agents API behavior.

Evidence

  • A regression test in run-attempt.steering-settlement.test.ts drives a real recorder, an accepted native steer, the registry's confirmSteerTargetRunIdForPersistence, a failed turn, then a same-run rerun. Without the fix it fails with the exact production error at run-attempt-context.ts readFencedHistory. With the fix it passes, and the retry reaches turn/start and completes.
  • Test cost: the new case takes about 1.5–2.0 s inside the existing suite (no new suite setup). Whole file: 3 tests, about 18 s wall with pnpm exec vitest run … --maxWorkers=1.
  • Siblings: the steering, steering-media, steering-authority, steering-settlement, plugin-refresh, context-engine, context-engine-overflow, fork-provenance and continuity-media suites pass, 70/70.
  • pnpm tsgo:extensions and pnpm tsgo:extensions:test are clean, oxlint is clean, and git diff --check is clean.
  • An independent review found no blocking issues. The two gaps above came out of it.

🤖 Generated with Claude Code

Accepting a steer stamps its target run on the steer row, which rotates the
transcript generation. A transient same-model retry then reran the Codex
attempt with the original recorder, and its fenced history reread failed with
"Current-turn transcript admission identity changed", dropping the reply.

The fenced read ends before the admission, so the first attempt's snapshot is
what a reread would return. Retain it per recorder and reuse it for a
same-scope retry, mirroring the Agents API fix (openclaw#161444 upstream).
Context-engine bootstrap/assembly still fail closed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@tomorrowflow
tomorrowflow merged commit 014085c into main Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant