fix(codex): cap native-subagent completion delivery retries (fixes #97593) (AI-assisted)#97594
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed June 29, 2026, 4:17 AM ET / 08:17 UTC. Summary PR surface: Source +36, Tests +58. Total +94 across 2 files. Reproducibility: yes. Current main and v2026.6.10 are source-reproducible: non-durable delivery calls scheduleCompletionDeliveryRetry, and that scheduler only clamps the delay index without a maximum attempt or deadline. Review metrics: 2 noteworthy metrics.
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 findings
Review detailsBest possible solution: Land one canonical Codex native monitor retry cap that uses the intended retry schedule consistently, records failed delivery on give-up, preserves success-after-retry behavior, and includes redacted real runtime proof. Do we have a high-confidence way to reproduce the issue? Yes. Current main and v2026.6.10 are 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? No, not yet. The Codex native monitor is the right owner boundary, but this branch should align code, tests, and PR-body retry-window semantics and provide real behavior proof before it is the best landing path. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 293f0369d03b. Label changesLabel justifications:
Evidence reviewedPR surface: Source +36, Tests +58. Total +94 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
|
The CodexNativeSubagentMonitor's completion delivery retry loop had no maximum attempt count or deadline. A permanently non-durable delivery (e.g. silent parent reply) would reschedule every 5 minutes forever, re-invoking deliverAgentHarnessTaskCompletion on each tick. Add DEFAULT_MAX_COMPLETION_DELIVERY_ATTEMPTS (6, matching the delay array length) and a completionDeliveryMaxAttempts option. When attempts reach the limit, mark the delivery as failed and clear the pending state instead of rescheduling. Fixes openclaw#97593
ce566ee to
601f4cb
Compare
|
Auto-cleanup: freeing PR slots for higher-quality contributions. Feel free to reopen if still relevant. |
What Problem This Solves
When a Codex native subagent (
spawn_agent) completes, theCodexNativeSubagentMonitordelivers the completion to the parent agent viaruntime.deliverAgentHarnessTaskCompletion. If that delivery is permanently non-durable (e.g. the parent's reply is silent for a subagent completion, or the external channel is down), the monitor reschedules the delivery with no maximum attempt count and no overall deadline. It re-fires forever — each retry re-invokesdeliverAgentHarnessTaskCompletion, which wakes and re-runs the parent agent every 5 minutes indefinitely.Why This Change Was Made
The
scheduleCompletionDeliveryRetrymethod clamps the delay usingMath.min(attempt, delays.length - 1)but never compares the attempt count to a maximum. ThecompletionDeliveryAttemptcounter is incremented and used solely as a delay index, never as a termination condition.The equivalent completion-delivery loop on the OpenClaw
sessions_spawnannounce path is bounded (#88523 added a retry cap, #90178 / #95080 added give-up / expiry). The Codex native-subagent monitor is a separate implementation (introduced via #83445) that lacked the same guard.This change adds:
DEFAULT_MAX_COMPLETION_DELIVERY_ATTEMPTSconstant (6, matching the retry delay array length)completionDeliveryMaxAttemptsoption inMonitorOptionsfor test/custom configurationscheduleCompletionDeliveryRetrythat marks delivery as"failed"and clears pending state when the limit is reachedUser Impact
Users running Codex native multi-agent sessions will no longer see unbounded parent agent re-runs when a subagent completion delivery is permanently non-durable. The delivery is marked as failed after 6 attempts (~10.5 minutes total) instead of retrying forever.
Evidence
extensions/codex/src/app-server/native-subagent-monitor.tsat commit4c8470c0(upstream/main), test suite vianode scripts/run-vitest.mjs run extensions/codex/src/app-server/native-subagent-monitor.test.ts.completionDeliveryMaxAttempts: 3and a permanently non-durable delivery mock, the monitor attempts exactly 3 times (1 initial + 2 retries), marks the delivery as"failed"with an "abandoned after" error, and makes no further retry attempts even after advancing time by 1,000,000ms.Real behavior proof
scheduleCompletionDeliveryRetrynever bounds the attempt count, causing permanently non-durable deliveries to retry every 5 minutes forever.CodexNativeSubagentMonitorclass fromextensions/codex/src/app-server/native-subagent-monitor.ts, driven end-to-end with the production runtime seam (deliverAgentHarnessTaskCompletion) returning a permanently non-durable result (delivered: false).completionDeliveryMaxAttempts: 3, registered parent, delivered a terminal native subagent completion, advanced fake timers across 1,000,500ms, and counted invocations and final delivery status.Observed result after fix: Delivery attempted exactly 3 times, then marked
"failed"with error"completion delivery abandoned after 3 attempts". No further retries after give-up.What was not tested: Live channel/provider failure paths. The fix was validated via the test suite with the runtime delivery seam stubbed.
AI-assisted (Hermes Agent)