Repository navigation
Recover rejected Codex follow-ups and preserve retry ownership (T2) - #244
Merged
Merged
Conversation
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.
Closes #242
Sage task T2 (the Codex task namespace)
A native follow-up can fail while Codex restores an evicted child at its thread limit. Sage now records that exact rejected attempt, releases its reservation, and permits a fresh prepared retry on the original child. The failed attempt and completed predecessor remain in history.
The reader accepts only the captured Codex 0.160.0 result
collab tool failed: agent thread limit reached. It verifies sender, owner epoch, call, turn, recipient, predecessor, message hash, and argument hash. Delivered messages, successful callbacks, and bindings block failure recovery. Core atomically excludes binding and failure for the same attempt. Both predecessor guards permit retry only after a verified continuation failure; initial-spawn failure remains separate.The child's first tool can arrive before its parent's successful result. A deterministic test reproduced immediate refusal. The policy now waits only for an exact pending parent call plus verified recipient delivery, and requires both proofs before binding or evaluating the tool. It makes at most 40 delayed reads, 25 ms apart. Timeout, mode changes, interruption, conflicting evidence, or a lost claim refuse. Off-mode waiting retains the original assignment, checked before publication.
Validation
Every test command used fake ps, pgrep, and kill first on PATH, with NODE_TEST_CONTEXT removed from the launching environment. Attack inputs went to parsers only.
npm run build: built 306 files.npm run check: all checks pass.node --test scripts/fixtures/codex-native/fresh-control.test.mjs: 1 passed, including six invalid-output controls.node --test scripts/fixtures/codex-native/policy-diagnostic.test.mjs: 2 passed, including symlink and size limits.node scripts/probe-codex-lifecycle.mjs --sage-followup-capacity-recoveryon 0d49693: actual CLI 0.160.0, simulated model responses, verified true and cleanup true. Native capacity one and Sage capacity two produced one rejection and a successful same-child retry after the other child completed. Final evidence: 4 reservations, 1 failure, 3 bindings, 3 completions, 0 reports. The failed attempt never bound. The fresh child's first tool returned exactly {"resources":[]}. Actual counts: 18 root requests, 7 child requests, 26 response requests; zero unexpected/failure counters.npm test -- --test-concurrency=1: 1,392 tests passed; zero failures, cancellations, skips, or todos. Process exited 0.Focused selector:
T2 |continuation failure core|native failed dispatch|native follow-up dispatch consumes|native capacityon scripts/codex-server.test.mjs and scripts/providers.test.mjs. Main selector:T2 |continuation failure core.Diagnostics and limits
Baseline capture 74966ae retained the rejected reservation. An early recovery probe denied the fresh child's first tool. Both failed and passing diagnostic captures show the child call before parent success publication. Terminal replay did not identify the erased exception; the deterministic pending-parent test independently established the ordering defect. The failed capture remains a failed check.
The fixture now requires the first tool's successful output before completing the child. It stores bounded diagnostics only inside its disposable profile. Profiles and proof worktrees were removed. No production policy is disabled for the probe.
This does not accept arbitrary errors, mark tasks or runs successful, transfer sessions, restart active children, or enable installed Sage/autopilot. Real-model behavior and installed-session activation remain unverified. Claude-owned task/state operations are unchanged. Two independent code, security, and QA review cycles are clean on 0d49693. CI run 38794102681 passed on this exact head: 1,392 tests passed, zero failed.