[codex] fix native subagent completion retry cap#97715
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed June 29, 2026, 3:58 AM ET / 07:58 UTC. Summary PR surface: Source +32, Tests +122. Total +154 across 2 files. Reproducibility: yes. Current main is source-reproducible: non-durable delivery calls scheduleCompletionDeliveryRetry, and that scheduler only clamps the delay index without a maximum attempt or deadline. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land one canonical Codex native monitor retry cap that uses the existing retry schedule as the single policy, preserves success-after-retry behavior, records failed terminal delivery on give-up, and includes redacted real runtime proof. Do we have a high-confidence way to reproduce the issue? Yes. Current main is source-reproducible: non-durable delivery calls scheduleCompletionDeliveryRetry, and that scheduler only clamps the delay index without a maximum attempt or deadline. Is this the best way to solve the issue? Mostly yes. The Codex native monitor is the right owner boundary and using the existing delay schedule avoids new config surface, but the branch still needs real behavior proof and canonical selection among sibling retry-cap PRs. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 96c8338d5bfa. Label changesLabel justifications:
Evidence reviewedPR surface: Source +32, Tests +122. Total +154 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
What Problem This Solves
Fixes #97593.
Codex native subagent completion delivery could retry forever when the parent handoff was permanently non-durable. The monitor marked the completion pending, called
deliverAgentHarnessTaskCompletion, and on every non-durable result scheduled another retry. The retry counter only selected a delay with a clamped array index, so once it reached the final configured delay it re-fired every 300 seconds indefinitely, waking and re-running the parent agent forever.Why This Change Was Made
The fix keeps ownership inside the Codex plugin monitor and does not add public config or SDK surface.
completionDeliveryRetryDelaysMsremains the single retry policy: each configured delay is consumed exactly once, and once the schedule is exhausted the pending completion is cleared and its task delivery status is markedfailedwith a diagnostic error.This intentionally avoids the two sharp edges from the open candidate PRs:
The failed terminal state mirrors the existing task delivery vocabulary and gives maintainers/logs a visible end state instead of leaving the child completion pending forever.
User Impact
Users running Codex native multi-agent sessions will no longer get an unbounded parent wake/re-run loop when a subagent completion cannot durably reach the parent. Transient failures still retry through the configured schedule and can still become delivered. Permanently non-durable failures settle as failed after the schedule is exhausted, preventing repeated parent reruns every five minutes.
Evidence
Commands run on this branch:
Observed results:
Regression coverage added:
failedwith a retry-schedule-exhausted error, and does not invoke the parent delivery again after more timer advancement.Dependency/Codex contract checked:
src/plugin-sdk/agent-harness-task-runtime.tsdurable-delivery predicate returns false fordelivered: falseand true only for durable direct/steered delivery.../codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadItem.ts,../codex/codex-rs/protocol/src/protocol.rs,../codex/codex-rs/core/src/tools/handlers/multi_agents_v2/spawn.rs.Screenshot evidence: The attached terminal screenshot shows

node scripts/run-vitest.mjs extensions/codex/src/app-server/native-subagent-monitor.test.ts --reporter=verbosepassing with the new retry-exhaustion and final-retry delivery regressions included in the 35-test Codex native subagent monitor suite.Screenshot evidence shows a real OpenClaw Gateway + Codex app-server run on d31cb1b using the local Codex OAuth bootstrap: an aborted-parent Codex native subagent completion stayed pending through the configured retry schedule and then reached deliveryStatus: failed with retry schedule exhausted, rather than retrying indefinitely.
