Repository navigation
fix(codex): preserve native subagent results through recovery - #149864
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 17, 2026, 10:25 AM ET / 14:25 UTC (Revision 19). ClawSweeper reviewWhat this changesPreserves 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 Review scores
Verification
How this fits togetherThe 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]
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (18 earlier review cycles; latest 8 shown)
|
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.
Preserve main's database-worker routing entries alongside the monitor fixture. The native recovery implementation and diagnostic proof remain unchanged.
Restore the lifecycle mirror from saved assignments so errors from later turns cannot overwrite delivered predecessor results.
|
Merged via squash.
|
…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]>
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 on96032004with 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 andturn-bhistory 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
4039ebecpassed, preserving parent/child identity, prior complete task rows, native history and both shell results. Those are retained historical proofs. The fresh6b75d070build 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
96032004CI 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
ETIMEDOUTlocally 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.