Repository navigation
refactor(subagents): retire finished child rows by one rule instead of two handed-off flags - #205482
Conversation
|
🦞👀 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. What this changesThis PR replaces two deferred-retirement flags with one registry-row fact and centralizes shared delivery-suppression predicates. Example: A yield-paused child named run-1 has pending retirement intent when its settle wake clears.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this maintainer-authored draft open: it makes a coherent retirement-state cutover that current main does not provide, and source review found no definite introduced bug. Reviewed head: Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe subagent registry persists child execution and delivery obligations; cleanup, requester-turn settlement, and restart recovery consume those records to deliver results and retire finished rows. flowchart TD
A[Child execution] --> B[Cleanup bookkeeping]
B --> C[SQLite registry row]
C --> D[Requester settle wake]
C --> E[Requester turn settlement]
D --> F[Shared retirement rule]
E --> F
F --> G[Retain or retire row]
Technical reviewBest possible solution: Keep retirement intent on the existing registry row, preserve the current settlement owners, and qualify the cutover through Gateway recovery and released-state upgrade proof. Do we have a high-confidence way to reproduce the issue? Current-main completeRequesterSettleWakeState clears a yield-paused child's wake without transferring its retirement flag; this establishes the lost-intent path in source, but no shipped-entry-point reproduction was supplied or run. Is this the best way to solve the issue? The row-level fact removes the lossy handoffs using the existing normalization, transaction, and settlement owners; the extracted suppression predicates preserve the callers' existing conditions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3ce6c6c7cb12. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +11, Tests +43. Total +54 across 22 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 25, 2026, 1:06 PM ET / 18:06 UTC. |
|
…irement-rule * origin/main: (172 commits) test(gateway): expect a revoked person's Goal retry to be hidden as not found (#205698) fix: keep browser disabled when only hardening relay authentication (#203137) fix: recover Linux stream automations after command-anchor crashes (#203149) fix(whatsapp): identify voice-note captions as text in delivery receipts (#205381) fix(test): unblock restart-auth plugin and worker publication qualification (#205679) chore(ui): refresh control ui locales (#205691) fix: reduce memory during SQLite usage refresh (#201064) fix(plugins): readmit native captures with a dangling host link chore(i18n): refresh native locales (#205680) fix(update): hash SQLite lock bytes as zeros so Windows exclusion cannot fail verification (#205668) fix(skill-workshop): skip the skill diet for skills with Markdown outside support directories (#204881) fix(plugins): clarify dated SDK migration notices (#200932) fix: keep the resident launcher when reinstalling Gateway (#205655) fix: show the whole reply when you reopen a TUI session (#200455) test(ui): wait for restored speech player authorization (#199502) feat: let agents post approved GitHub comments (#204301) fix(agents): honor imageMaxDimensionPx at the provider and CLI image handoffs (#205663) chore(ui): refresh control ui locales (#205664) fix(google): preserve playback when Google Live splits audio into parts (#205364) fix: show named characters in exported session messages (#205362) ...
…f two handed-off flags (openclaw#205482) * refactor(subagents): one retirement fact and named delivery-suppression rules * test(subagents): prove v2026.11.10 retire intent upgrades through the sqlite store
|
Merged via squash auto-merge.
|
What Problem This Solves
When a sub-agent finishes, its result must reach the agent that started it exactly once, or that agent must see why it did not. That holds across restarts too. The registry tracks this with two outboxes on one row: completion
deliveryand therequesterSettleWake.Cleanup's "retire this row later" intent was kept in two places that handed off to each other:
requesterSettleWake.retireAfterSettleand the row'sretireAfterRequesterTurn. The wake handed off to the row when it completed while the requester turn was still open, and the row handed back to the wake when the requester yielded. A missed handoff in either direction drops the intent or leaves a row behind. Separately, five call sites repeated their own mix of the three delivery-suppression facts.This is the most-fixed area of the registry: 403 of 788 commits in the last six months were fixes, and most of them were about delivery, wake or restart. Each fix added a guard or a handoff and rarely removed one.
User Impact
There is no intended visible change for completed runs. One behavior changes: cleanup's retire intent is no longer lost when the wake goes away without completing. Before, the intent rode on the wake, so any path that cleared the wake directly dropped it, and the row stayed until the retention sweep. Those paths are a yield-paused child's wake clearing, a pause notice consumed without a cohort, a yielded batch whose final was already delivered, and restart custody retiring the obligation. Now the row keeps the intent and retires at its next settle check, which is what cleanup asked for. A regression test covers the yield-paused case.
Why This Change Was Made
retireAfterSettlenow lives only on the row, andisSubagentRetirementSettledchecks it in one place: the row is marked, no settle wake remains, and no open requester turn awaits its result. Wake completion and requester yield both call that rule. Both handoffs are deleted, along with the branch intransitionRequesterSettleWakeStatethat preserved the flag and theRequesterSettleWakeBatchState = Omit<…>alias that hid it from batch transitions.subagent-delivery-stateownsisSubagentDeliveryClosed(an accepted closure, which a kill rollback cannot undo) andisSubagentDeliveryWithheld(closed, or a pending kill asked to withhold delivery). Five sites that matched those definitions exactly now call them. Three other sites have their own definition of "still owed", for example the batch-level rule inrequester-cron-authority. Changing them would change behavior, so they are left as they are.suppressAnnounceReasonstays because it records a reason other code reads, not a suppression flag.normalizeSubagentRunState, which already normalized the old row flag on load, now also foldsrequesterSettleWake.retireAfterSettleandretireAfterRequesterTurnfrom rows written by released builds into the new fact. This needs no Doctor migration. Remove the fold once no supported build can write those shapes.Size against the merge base: production code +84 −73 across 13 files (tests +75 −32 across 9 files). The change adds one rule and two predicates, and removes two flags, both handoffs and one type alias. The point is fewer places that decide retirement, not fewer lines. The larger follow-up merges the settle wake into the delivery obligation, which removes the second outbox and its separate retry policy. It is left out of this PR so this cutover stays reviewable.
Open overlap: the stale draft #140956 builds on the old two-flag shape and will conflict. #199455 sets
requesterSettleWake.retireAfterSettlein one test line and needs a one-line rebase change.Evidence
subagent-delivery-state.test.ts:4ecd1640b0525(the proof test was added in68f5284694cca) (base0b99555d5f7dd):tsgo:coreandtsgo:test:srccleanoxfmt --checkcleansrc/agents/subagentssuite: 2,245 passed, 1 skipped and 1 failed, across 174 files. The failure is insubagent-spawn.production-boundary.test.ts. It does not depend on this change:collector child|preserves routed native Stop authorityfails 3 of 3 runs. Every run failsrefuses to continue a timed-out collector child, and 2 of 3 also failpreserves routed native Stop authority … (consumed-session).completeRequesterSettleWakeStateduring the failing run showed no row carrying the retire fact and no retirement. The new rule never fires there.source-sha256:aed5c70d…, Codex default engine), branch mode0b99555d5f7dd..4ecd1640b0525at P0–P2, with lifecycle-wake, lifecycle-completion, requester-wake-mutation, announce-cleanup and restart-custody as source context:scoped-clean, no findings, confidence 0.88. ClawSweeper local was unavailable, so one hosted review is still to request when this is ready.v2026.11.10, which writes both old shapes:subagent-registry.store.sqlite.test.ts"upgrades v2026.11.10 retire intent from either location to the row fact".requesterSettleWake.retireAfterSettle, the otherretireAfterRequesterTurnwith an open requester turn.retireAfterSettle, the old fields are gone, and the pending delivery payloads are unchanged.0b99555d5f7dd(expected undefined to be true) and passes on68f5284694cca. The whole file passes 16 of 16, andtsgo:test:src, oxfmt and oxlint are clean.a35809cb93393failed onlysrc/gateway/chat-goal-created-authority.e2e.test.ts, which also failed onmain. It was repaired in test(gateway): expect a revoked person's Goal retry to be hidden as not found #205698.932fc2a6fd330merges thatmain(no conflicts). On the merged head:tsgo:coreandtsgo:test:srcare clean, and the requester-cron-authority, registry-queries, delivery-state and SQLite store tests pass (73/73).a35809cb93393adds the// SAFETY:note that the assertion-safety ratchet requires on the legacy-fold cast.