Skip to content

fix: stop native completion retirement from retrying forever - #200947

Open
shannon0430 wants to merge 2 commits into
openclaw:mainfrom
shannon0430:fix/codex-native-retirement-retry-cap
Open

shannon0430 wants to merge 2 commits into
openclaw:mainfrom
shannon0430:fix/codex-native-retirement-retry-cap

Conversation

@shannon0430

@shannon0430 shannon0430 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Closes #200892.

When a completed native Codex child can no longer retire its persisted assignment, the monitor currently retries the retirement write every 15 seconds forever. This bounds the retirement phase with the existing retry budget, then stops the in-memory monitor while preserving the unresolved assignment for Doctor repair.

User impact

  • persistent retirement-write failures stop producing an unbounded retry/log loop
  • the completion result is still delivered at most once
  • unresolved persisted assignment state remains available for diagnosis and repair
  • transient retirement failures continue to retry and can still complete cleanup

Implementation

The shared detached-completion owner applies the retry budget to failed retirement writes. When the budget is exhausted, the Codex adapter unregisters the in-memory child and leaves the unresolved assignment in storage for repair.

Evidence

Gateway runtime proof for the core retirement owner at e8d40e11089f657ff9e909a091c3b8d6752d6879

An isolated Gateway built from this revision ran a native Codex parent and child against a loopback model. The parent completed and the child produced its final response. A test fixture returned a blocked delivery, refused the retirement write, and shortened the elapsed timer waits. The production core owner selected the intervals and invoked the Codex exhaustion callback. Immediately after the in-memory unregister, an independent read-only SQLite connection found the same child's unresolved assignment.

parent=ok  native_child_spawns=1  child_finals=1
completion_delivery_attempts=1  retirement_writes_refused=7
core_retry_delays_ms=5000,15000,30000,60000,120000,300000
in_memory_unregister=1  matching_persisted_assignment_after_unregister=true

Focused oxlint on the five changed files completed with zero warnings and zero errors. The run used isolated state and had external delivery disabled.

Earlier evidence at 17a80c2183d2

  • Regression first failed on base 8f321bcc7e14569939ee9648a9663f3927816f2c because a retry timer remained after the bounded window.
  • 63 focused assertions passed across native-subagent-inventory.test.ts, native-subagent-completion-delivery.contention.test.ts, and native-subagent-monitor.completion-delivery.test.ts.
  • Extension source and extension-test typechecks passed.
  • Focused oxlint passed for both changed files.
  • Plugin boundary report, formatting, and diff checks passed.
  • Independent local P0-P2 autoreview reported no actionable findings (confidence 0.9).

The broader changed-lane wrapper completed its selected guards and Doctor tests, then exceeded the local 10-minute wrapper budget at the plugin-boundary phase; that boundary command passed separately. No live Gateway or live Slack configuration was changed for this proof.

Codex contract check

I inspected codex-rs/app-server-protocol/src/protocol/common.rs, codex-rs/app-server-protocol/src/protocol/v2/turn.rs, and codex-rs/app-server-protocol/src/protocol/event_mapping.rs. They expose thread/turn completion receipts and collaboration state, but no host assignment-retirement acknowledgement. The bounded retirement lifecycle therefore remains owned by the OpenClaw monitor.

Scope

This does not delete unresolved assignment state, change delivery routing, resend completion output, or alter live authentication/channel configuration.

Isolated runtime evidence at 17a80c2183d2

An isolated packaged Gateway ran this head with a real native Codex child and loopback model. The parent completed and one child produced its final response. A test-only adapter returned a blocked delivery result and simulated a read-only store at retirement. The packaged retry code selected its normal backoffs (5, 15, 30, 60, 120, 300 seconds); the harness compressed elapsed timer waits. Observed counters: 1 completion delivery attempt, 7 refused writes including the initial attempt, 6 scheduled retries, then exhaustion. The assignment store still contained the matching child at exhaustion. No second delivery attempt or further retry was observed during the observation window. This exercises the Gateway lifecycle with an injected write failure; the original live cause and real wall-clock waits were not reproduced.

Captured Gateway output at 17a80c2183d2

The retained projection of the Gateway run above was:

{
  "parentStatus": "ok",
  "spawnCalls": 1,
  "childFinals": 1,
  "retirementWarnings": 7,
  "durabilityWarnings": 7
}

The storage adapter recorded these events in order. Delay values are the selected budgets in milliseconds. The trace ends after the retained-assignment readback; it contains one delivery attempt.

loaded
delivery-attempt
write-refused
delay-5000
write-refused
delay-15000
write-refused
delay-30000
write-refused
delay-60000
write-refused
delay-120000
write-refused
delay-300000
write-refused
retained

@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@shannon0430
shannon0430 marked this pull request as ready for review November 18, 2026 02:53
@openclaw-barnacle openclaw-barnacle Bot added extensions: codex size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Nov 18, 2026
@shannon0430

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The external-PR evidence heading is now corrected and the replacement PR context/evidence run passed. Please review exact head 17a80c2183d20765634d94b33eda7782ac1fc090.

@clawsweeper

clawsweeper Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR bounds failed native completion-retirement writes and releases the in-memory child while retaining its unresolved assignment.

Example: A native child finishes, delivery is blocked, and every assignment-retirement write fails.

  • Before: The monitor keeps retrying retirement indefinitely.
  • After: Seven failed writes exhaust the budget, unregister the child from memory, and preserve its assignment in storage.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, focused repair with direct Gateway evidence and complementary core-callback and persisted-assignment regressions; required CI remains awaiting approval.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The updated exact-head Gateway output exercises the adapted production core lifecycle with injected retirement-write failures, records exhaustion and Codex unregister, and independently confirms the unresolved assignment remains in SQLite, satisfying the previous review request.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A permanently failing native assignment retirement can keep emitting warnings and retaining monitor resources indefinitely.
Reason: The reported failure is concrete, the repair is bounded, and the feature-history owner explicitly requested carrying this fix into the new core lifecycle.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR: it fixes a remaining retry loop, follows the maintainer-approved core-owner direction, and has no actionable correctness findings.

Reviewed head: e8d40e11089f657ff9e909a091c3b8d6752d6879

Before merge

  • Await maintainer action - A maintainer must approve the pending GitHub Actions runs for this PR so required CI can execute.

Findings

None.

Agent review details

How this fits together

The Codex adapter reports native child completion to the core completion lifecycle, which coordinates delivery, retirement retries, and release of plugin-owned resources.

flowchart TD
  Child[Native child completion] --> Adapter[Codex adapter]
  Adapter --> Core[Core completion lifecycle]
  Core --> Delivery[Parent delivery]
  Core --> Store[Assignment retirement]
  Store --> Core
  Core --> Release[In-memory child release]
Loading

Technical review

Best possible solution:

Land the bounded retirement budget in the existing core lifecycle once the enforced CI approval and checks complete.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes the unbounded retirement retry path, and the report documents repeated failures on official OpenClaw 2026.11.1; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is a focused repair using the existing retry schedule and core owner, with a small Codex callback that preserves unresolved storage for recovery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against aab0aaac5911.

Provenance checked

  • Native retirement persistence retries changes intended behavior with a stated reason (275c611: Retire terminal assignments durably and retry rejected or lost bookkeeping replies without resending completion output or resurrecting retired results.)
  • Core ownership of detached completion lifecycle keeps the original intent (a9569e9: Remove the competing plugin completion lifecycle while preserving native routing, receipts, retries, and persisted binding format.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still lacks retirement exhaustion: Current main schedules another retry after retirement failure without advancing a retirement-specific budget; the pinned introduced diff adds that budget and its exhaustion callback. (src/agents/subagents/announce/subagent-announce-obligation-lifecycle.ts:201, aab0aaac5911)
  • Maintainer direction preserves this distinct fix: Vincent Koc explicitly confirmed that merged refactor(codex): centralize native completion delivery #206447 preserves bookkeeping retries and does not supersede this bounded-retirement fix, requesting adaptation to core instead.
  • Updated Gateway proof addresses the previous review: The current PR body records an isolated Gateway at the reviewed head exercising the production core owner: one native child, one delivery attempt, seven refused retirement writes, the six expected backoffs, one unregister, and independent SQLite readback of the retained assignment. (e8d40e11089f)
  • Exhaustion preserves persisted recovery state: The new callback invokes only unregisterChild; its cleanup releases custody and monitor resources, while assignment settlement preserves an undelivered child with a pending completion. (extensions/codex/src/app-server/native-subagent-completion-delivery.ts:221, e8d40e11089f)
  • Required CI has not executed: The exact-head CI run is action_required with zero jobs, explaining the failed openclaw/ci-gate status without establishing a diff-caused test failure; GitHub reports mergeable=true. (e8d40e11089f)
  • Feature history and original durability intent: The retirement path in commit 275c611 retries failed bookkeeping to prevent completion resurrection; a9569e9 subsequently moved that lifecycle into core. Following older history encountered unavailable objects, so no earlier introduction is asserted. (extensions/codex/src/app-server/native-subagent-completion-delivery.ts, 275c611ead7a)

Likely related people:

  • Vincent Koc: Raw commit a9569e9 adds extensions/codex/src/app-server/native-subagent-completion-delivery.ts:215 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a9569e99ea71; files: extensions/codex/src/app-server/native-subagent-completion-delivery.ts)
  • Peter Steinberger: Raw commit 275c611 adds extensions/codex/src/app-server/native-subagent-inventory.test.ts:599 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 275c611ead7a; files: extensions/codex/src/app-server/native-subagent-inventory.test.ts)

PR surface

Source +20, Tests +68. Total +88 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 22 2 +20
Tests 2 68 0 +68
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 90 2 +88

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: ⏳ waiting on maintainer.

Label justifications:

  • merge-risk: 🚨 compatibility: The completion registration gains an optional exhaustion callback and a bounded retirement policy; the narrow repair follows recorded maintainer direction and preserves existing parameter compatibility.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-11-18T03:03:41.266Z sha 17a80c2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-21T13:35:39.310Z sha 17a80c2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-21T13:47:48.868Z sha 17a80c2 :: blocked before merge. :: none
  • reviewed 2026-11-28T02:52:42.471Z sha e8d40e1 :: needs real behavior proof before merge. :: none

Reviewed November 28, 2026, 8:37 AM ET / 13:37 UTC (Revision 5).

@shannon0430

Copy link
Copy Markdown
Contributor Author

Added the exact-head isolated runtime evidence to the PR body (17a80c2). @clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Nov 20, 2026
@shannon0430

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@shannon0430

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 21, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Thanks @shannon0430. The completion-owner cutover in #206447 has landed, relocating retry ownership to core. Your bounded-retirement fix remains distinct: the cutover preserves bookkeeping retries and does not add retirement-budget exhaustion. This PR needs adapting to the new core lifecycle rather than closing as superseded; your regression and credit should carry forward.

@shannon0430

shannon0430 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Adapted this PR to the core completion lifecycle introduced by #206447 at exact head e8d40e11089f657ff9e909a091c3b8d6752d6879.

What changed:

  • moved the bounded retirement-write budget into the shared detached-completion owner;
  • added an optional exhaustion callback so Codex releases only its in-memory child after seven failed retirement writes while preserving the unresolved assignment for repair;
  • retained the existing Codex regression and added a core lifecycle regression proving one delivery, seven retirement attempts, one exhaustion callback, and no further timer.

Verification on Node 24.22.1:

  • src/plugin-sdk/agent-harness-completion.test.ts: 23 passed
  • targeted stops retrying retirement after persistent write failures: 1 passed (40 skipped)
  • oxfmt --check on the five touched files: passed
  • git diff --check: passed

oxlint itself could not start in the isolated filtered dependency install because the repo config's eslint-plugin-solid was not present; this was an environment-preparation limitation, not a reported lint finding.

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Nov 28, 2026
@clawsweeper

clawsweeper Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. labels Nov 28, 2026
@shannon0430

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Codex native completion retirement retries every 15 s indefinitely when the parent's captured session authority is no longer current (2026.11.1)

2 participants