Skip to content

fix(codex): preserve native subagent results through recovery - #149864

Merged
steipete merged 20 commits into
mainfrom
codex/native-followup-recovery-integrated-20260915
Sep 17, 2026
Merged

steipete merged 20 commits into
mainfrom
codex/native-followup-recovery-integrated-20260915

Conversation

@steipete

@steipete steipete commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Native Codex follow-ups could overwrite an earlier task’s history locator, lose accepted work after a yield or restart, or deliver an old result after a parent reset. A delayed close could also affect a newer assignment. After parent rotation and a restart, an accepted follow-up receipt could remain stored without ever creating its task while the predecessor result was still pending. Live testing exposed another trigger: OpenClaw ignored Codex’s classified completion push, announced the result again, and rotated the parent conversation.

User Impact

Follow-ups reuse the native conversation and create distinct task assignments while preserving earlier results and history locators. Interrupted work keeps its assignment. The current controller can resume a completed child while an older result finishes delivery through its retained owner. Cold receipt replay prepares the authenticated receiver before its first history read, preserving the original native ancestry and the earlier delivery owner. Receipts settle the matching assignment, and cleanup waits for accepted writes and child ownership to settle before releasing the subscription.

Recovery remains within the original session lifecycle and native connection. History inspection can follow physical session rotation within that lifecycle; automatic completion delivery still requires the exact saved requester and current authority. Ordinary user text cannot forge native completion receipts, and resetting a parent prevents old work from entering a replacement session.

Why This Change Was Made

The native monitor owns assignment selection. Its existing history, submission, receipt, completion, and close owners preserve those decisions through asynchronous work. Native ancestry is separate from the current controller. The optional SDK admission callback validates source ownership before new delivery begins; accepted work retains its execution lifecycle. Submission receipts use private metadata in the existing version-1 binding envelope.

V1 submission responses do not distinguish starting a turn from steering one. Unmatched receipts follow the binding lifetime and its existing 1 MiB limit, and cannot create tasks without native-turn evidence. Ambiguous receipts may cause an extra continuation; records without a safe turn boundary remain unresolved. Let pending native work settle before downgrading, because older binding writers can discard recovery receipts.

Evidence

The cold-restart finding is reproduced and fixed on 6b75d070. Two registered-monitor tests use real SQLite task/binding state: a new parent accepts follow-up B on the original parent's child while result A remains pending, the old monitor/host scopes close and the store reopens, then replay receives history identifying the original native parent. Both orderings failed on 96032004 with B absent and its receipt retained. The three-line existing-owner repair preserves A's complete row and recovers B's result, delivery, receipt consumption, original native ancestry and turn-b history locator. All 44 recovery/authority controls and both strengthened cold cases pass; they overlap and are not summed. Fresh P2 review, extension/root compiler checks, lint, formatting and ratchets pass.

Storage-format compatibility passed 44 cases using the exact released v2026.9.4 binding writer/codec with the candidate SQLite adapter, receipt-store controls and scripted legacy task-history reads. Existing settings, version-1 keys, binding rows and receipt absence survive candidate lease/set/patch/reopen. This is binding-format proof; the existing native runtime-fingerprint/reconnect policy and pending-work downgrade limitation remain unchanged.

Earlier validation included four compiler surfaces, 424 native/SDK/task/session/custody cases and 101 MCP/model/process cases, followed by 113 affected cases for active-assignment restoration. A full build and one OpenAI-key three-assignment live run on 4039ebec passed, preserving parent/child identity, prior complete task rows, native history and both shell results. Those are retained historical proofs. The fresh 6b75d070 build passed in 318.2 seconds. Its original single-attempt OpenAI-key three-assignment case passed in 40.6 seconds, preserving parent/child identity, full previous rows, native ancestry/turn locators, history and both shell results. Independent capture verification and process/port/state/key-scan cleanup passed. This warm provider proof is separate from the durable cold-restart regressions above.

The prior 96032004 CI run passed 171 checks. CI fixture repairs retain the original assertions: crash cleanup closes SQLite and joins children; the Doctor fixture models its synthetic diagnostic and verifies both commands; exact-main Labeler inputs remain aligned. The larger native declaration-compiler runner preserves groups, names, worker counts, packing and 120-second deadlines. The SDK compiler's slowest case passed in 10.618 seconds; all 12 cases passed. The previous worker-stop timeout did not reproduce in the 1,201-test Linux baseline; its independent cleanup defect was demonstrated and repaired.

The full change and subsequent corrections received independent P0–P2 reviews. Dallin Romney's broker-safe live-harness contribution from #150475 is preserved. No agent transcript is included.

Current exact-head CI: https://github.com/openclaw/openclaw/actions/runs/35214296835

CI attempt 1 stopped in two unchanged worktree-provisioning fixtures at their existing 10-second process deadline. Instrumentation reproduced ETIMEDOUT locally after clearing the disk-reserve constraint; all 927 eager runtime files are identical between the CI merge and its main base. Upstream #150900 has independently repaired this tooling cost without extending deadlines. The single bounded failed-job rerun passed and exact-head CI is green with zero pending checks; no subagent source change was made for this failure.

Raw provider captures stay private.

Keep completed follow-up assignments and their results separate while reusing the native child thread. Preserve ordered recovery, current parent authority, and receipt matching without rewriting earlier task outcomes.
@steipete steipete self-assigned this Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: codex size: XL maintainer Maintainer-authored PR labels Sep 16, 2026
@steipete
steipete marked this pull request as ready for review September 16, 2026 07:50
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 17, 2026, 10:25 AM ET / 14:25 UTC (Revision 19).

ClawSweeper review

What this changes

Preserves separate Codex subagent results across follow-ups and restarts, adds binding-owned recovery receipts and guarded completion admission, and updates supporting tests and CI routing.

Merge readiness

⛔ Blocked before merge - 2 items remain

This PR remains useful: main does not yet preserve distinct follow-up assignments. The prior cold-recovery finding is resolved, and this review found no additional blocking defect. The documented pending-work downgrade limitation does not require another review cycle.

Priority: P2
Reviewed head: 6b75d070267a81cfc54b15e70da8f9e0a0eb9e41

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent recovery repair with the prior blocker resolved, meaningful boundary coverage, and clearly scoped compatibility evidence.
Proof confidence 🌊 off-meta tidepool Not applicable: The provided maintainer context exempts this PR from the external-contributor proof gate. Its body records an exact-head real-provider three-assignment run; cold recovery and revocation controls were inspected separately, with no unresolved authority violation identified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The provided maintainer context exempts this PR from the external-contributor proof gate. Its body records an exact-head real-provider three-assignment run; cold recovery and revocation controls were inspected separately, with no unresolved authority violation identified.
Evidence reviewed 11 items Current main still needs distinct follow-up assignments: At the fetched main revision, the task mirror derives run identity solely from the child thread and suppresses repeated creation for an already mirrored thread. The candidate adds turn-qualified follow-up assignments instead.
Prior finding resolved: The exact-head commit adds receiver preparation before receipt history reads, restoring validated original ancestry before comparison. It also adds both cold-restart orderings with persistent receipts and unchanged predecessor-row assertions. The captured body reports both cases failing on the previous head and passing after this repair.
Assignment and completion ownership: The monitor retains earlier delivery owners while transferring current observation; completion admission checks the current child, parent, retirement state, exact task identity, and saved requester. Receipt writes revalidate authority inside the existing synchronous binding mutation.
Findings None None.
Security None None.

How this fits together

The Codex plugin observes native child conversations and projects their assignments into OpenClaw’s task registry. Its recovery and delivery owners use native events, history, and saved receipts to return completed results to the original requester.

flowchart TD
  A[Native child events and history] --> B[Codex subagent monitor]
  C[Saved submission receipts] --> B
  B --> D[Select assignment and validate ownership]
  D --> E[Persist task result]
  E --> F[Guard completion admission]
  F --> G[Original requester conversation]
Loading

Before merge

  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
SDK admission contract 1 optional callback; 0 new required parameters The documented callback narrows new completion admission while preserving existing callers and accepted-work lifetimes.

Stored data model

Persistent data-model change detected: unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep assignment identity, durable receipt recovery, and completion admission with their existing owners while preserving completed results and the documented settle-before-downgrade boundary.

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

Yes, source establishes the thread-only task identity on current main, and the recorded regressions exercise follow-up acceptance followed by parent rotation and restart. This read-only review did not execute a reproduction.

Is this the best way to solve the issue?

Yes. The patch extends the existing monitor, binding store, and completion owners, preserves native ancestry separately from the current controller, and uses the existing guarded admission path.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This repairs bounded Codex follow-up result and recovery behavior without evidence of a product-wide emergency.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The provided maintainer context exempts this PR from the external-contributor proof gate. Its body records an exact-head real-provider three-assignment run; cold recovery and revocation controls were inspected separately, with no unresolved authority violation identified.

Evidence

What I checked:

  • Current main still needs distinct follow-up assignments: At the fetched main revision, the task mirror derives run identity solely from the child thread and suppresses repeated creation for an already mirrored thread. The candidate adds turn-qualified follow-up assignments instead. (extensions/codex/src/app-server/native-subagent-task-mirror.ts:314, 1125da02a0c2)
  • Prior finding resolved: The exact-head commit adds receiver preparation before receipt history reads, restoring validated original ancestry before comparison. It also adds both cold-restart orderings with persistent receipts and unchanged predecessor-row assertions. The captured body reports both cases failing on the previous head and passing after this repair. (extensions/codex/src/app-server/native-subagent-submission-owner.ts:506, 6b75d070267a)
  • Assignment and completion ownership: The monitor retains earlier delivery owners while transferring current observation; completion admission checks the current child, parent, retirement state, exact task identity, and saved requester. Receipt writes revalidate authority inside the existing synchronous binding mutation. (extensions/codex/src/app-server/native-subagent-completion-delivery.ts:81, 6b75d070267a)
  • Admission reaches the accepting owner: The optional SDK callback reaches Gateway session admission and guarded message injection. The inspected controls distinguish revocation before injection, source retirement after acceptance, and the continuing effects fence; accepted work retains its own lifecycle. (src/agents/subagents/announce/subagent-announce-delivery.runtime.test.ts:193, 6b75d070267a)
  • Affirmative Codex dependency signal: The changed notification parser consumes Codex’s raw contextual-message classification, and receipt recovery interprets native submission IDs and thread history; these changes depend directly on the Codex runtime contract. (extensions/codex/src/app-server/native-subagent-notification.ts:56, 6b75d070267a)
  • Native contract inspected directly: The sibling source emits subagent notifications with the exact contextual classification consumed by the patch. Its V1 send-input owner returns the native turn ID for a started turn but an opaque fresh ID for steering, supporting the candidate’s refusal to create tasks from unmatched receipts alone. Repository ownership was verified through the cache repository’s upstream remote. (codex-rs/core/src/agent/control.rs:192, 6b9826e3aa83)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (18 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-17T08:31:25.654Z sha 824c309 :: blocked before merge. :: [P2] [P2] Restore durable child lineage before replaying rotated receipts
  • reviewed 2026-09-17T08:54:59.374Z sha 897cdef :: blocked before merge. :: [P2] [P2] Restore durable child lineage before replaying rotated receipts
  • reviewed 2026-09-17T09:27:17.068Z sha 4039ebe :: blocked before merge. :: [P2] [P2] Restore durable child lineage before replaying rotated receipts
  • reviewed 2026-09-17T10:00:19.040Z sha fdb3de5 :: blocked before merge. :: [P2] [P2] Restore durable child lineage before replaying rotated receipts
  • reviewed 2026-09-17T10:18:02.435Z sha 9603200 :: blocked before merge. :: [P2] [P2] Restore durable child lineage before replaying rotated receipts
  • reviewed 2026-09-17T10:49:06.967Z sha 9603200 :: blocked before merge. :: [P2] [P2] Restore durable child lineage before replaying rotated receipts
  • reviewed 2026-09-17T11:25:39.885Z sha 6b75d07 :: blocked before merge. :: none
  • reviewed 2026-09-17T14:06:55.266Z sha 6b75d07 :: blocked before merge. :: none

@steipete
steipete marked this pull request as draft September 16, 2026 09:38
Record the actual requested run and native parent for the reusable-child
Gateway proof, require populated identity, and retain the initial turn locator.
Route the monitor's real SQLite relay tests through the database-worker project.
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 16, 2026
Preserve main's database-worker routing entries alongside the monitor fixture.
The native recovery implementation and diagnostic proof remain unchanged.
@steipete
steipete marked this pull request as ready for review September 16, 2026 11:09
Restore the lifecycle mirror from saved assignments so errors from later turns cannot overwrite delivered predecessor results.
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 16, 2026
@steipete
steipete marked this pull request as draft September 16, 2026 15:05
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Sep 17, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 17, 2026
@steipete
steipete merged commit 41784ac into main Sep 17, 2026
390 of 392 checks passed
@steipete
steipete deleted the codex/native-followup-recovery-integrated-20260915 branch September 17, 2026 14:26
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 18, 2026
…aw#149864)

* fix(codex): preserve reusable native subagent results

Keep completed follow-up assignments and their results separate while reusing the native child thread. Preserve ordered recovery, current parent authority, and receipt matching without rewriting earlier task outcomes.

* test(codex): verify native follow-up parent identity

Record the actual requested run and native parent for the reusable-child
Gateway proof, require populated identity, and retain the initial turn locator.
Route the monitor's real SQLite relay tests through the database-worker project.

* fix(codex): preserve native task results after recovery

Restore the lifecycle mirror from saved assignments so errors from later turns cannot overwrite delivered predecessor results.

* refactor(codex): keep native recovery checks with their owners

* fix(codex): complete native recovery validation cutover

* test(slack): align Socket Mode fixtures with SDK contracts

* test(slack): align fixtures with current main

* fix(codex): recognize classified native completion receipts

* ci: give the hybrid declaration fixture existing compiler capacity

* fix(codex): preserve task ownership when native parents rotate

Restore saved receivers when a new native parent resumes them. Keep earlier assignment results, receipt ownership, accepted writes, and subscription cleanup scoped to their original owners while admitting distinct follow-up work.

* fix(codex): restore saved active subagent assignments

* test: align native landing checks with main

Close the crash fixture database and join its child before cleanup. Model the systemd inspection fallback in the Doctor fixture. Preserve the existing main Labeler concurrency fix and update its exact workflow-test routing expectation.

* ci: preserve compiler fixture capacity and planner ownership

Promote only the existing hybrid SDK declaration fixture job to the established larger runner, preserving its packing, groups, workers, and 120-second test limit. Extend fresh owned planner records directly instead of cloning them.

* chore: align native landing fixtures with main

Adopt the existing main planner clone expression and the Doctor fixture command-sequence assertions to resolve duplicate CI fixes. Preserve native recovery behavior and declaration-compiler capacity selection.

* fix(codex): restore receipt ancestry before cold replay

Prepare the accepted receiver through the existing validated observation owner before asynchronous receipt history reads. Preserve the original pending delivery owner and recover the successor task after parent rotation and restart. Cover both history/delivery orderings with durable receipts and immutable predecessor rows.

---------

Co-authored-by: Dallin Romney <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant