Repository navigation
refactor(agents): canonicalize subagent execution state - #117267
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 5:16 AM ET / 09:16 UTC. ClawSweeper reviewWhat this changesThis PR makes nested Merge readinessKeep this PR open for maintainer review. Current Priority: P1 Review scores
Verification
How this fits togetherSubagent lifecycle handlers record run progress and terminal outcomes, which are then persisted to SQLite and projected into recovery, delivery, cron follow-up, and session-status surfaces. The PR changes the canonical state source used across those downstream consumers. flowchart LR
A[Subagent lifecycle events] --> B[Run execution state]
B --> C[Registry and lifecycle handlers]
C --> D[SQLite run records]
C --> E[Recovery and cleanup]
C --> F[Delivery and requester wake]
C --> G[Session and cron projections]
Decision needed
Why: Both PRs modify the same recovery, delivery, and persisted subagent-state neighborhood; choosing their integration order and accepting the stored-state migration risk requires maintainer intent. Before merge
Agent review detailsSecurityNone. Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep Do we have a high-confidence way to reproduce the issue? Yes — source-reproducible on current main: the record type and interrupted-recovery lifecycle path retain root terminal fields alongside nested execution fields, allowing the two representations to diverge. This read-only review did not run a failing harness. Is this the best way to solve the issue? Unclear — making AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f216d3cc868e. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
f929435 to
4bf6538
Compare
4bf6538 to
6c2260e
Compare
6c2260e to
df70360
Compare
|
Merged via squash.
|
* origin/main: fix(test/ui): prevent shared history pollution (openclaw#117348) fix(openrouter): apply image request transport policy (openclaw#117336) perf(gateway): skip clean transcript workers (openclaw#117342) test(testing): assert relay smoke readiness fix(testing): activate relay live smoke transport feat(channels): record account lifecycle facts and retire inferred health vocabularies (openclaw#117300) fix(canvas): remove unsupported snapshot delay hint (openclaw#117326) refactor(agents): fold cache TTL pruning into prompt projection (openclaw#117313) fix(canvas): honor paired-node invocation deadlines (openclaw#117316) fix(system-agent): make exit-and-run-a-terminal guidance surface-correct (openclaw#114633) fix(ai): assistant text blocks are run together on replay (openclaw#115743) refactor(agents): canonicalize subagent execution state (openclaw#117267)
* origin/main: fix(test/ui): prevent shared history pollution (openclaw#117348) fix(openrouter): apply image request transport policy (openclaw#117336) perf(gateway): skip clean transcript workers (openclaw#117342) test(testing): assert relay smoke readiness fix(testing): activate relay live smoke transport feat(channels): record account lifecycle facts and retire inferred health vocabularies (openclaw#117300) fix(canvas): remove unsupported snapshot delay hint (openclaw#117326) refactor(agents): fold cache TTL pruning into prompt projection (openclaw#117313) fix(canvas): honor paired-node invocation deadlines (openclaw#117316) fix(system-agent): make exit-and-run-a-terminal guidance surface-correct (openclaw#114633) fix(ai): assistant text blocks are run together on replay (openclaw#115743) refactor(agents): canonicalize subagent execution state (openclaw#117267)
What Problem This Solves
Subagent terminal timing and outcomes were duplicated at the run-record root and under
execution. Lifecycle paths could update one copy without the other, leaving status, cleanup, requester wake, and SQLite projections to disagree after pause, kill, restart, or recovery.Why
executionthe sole owner of per-runstartedAt,endedAt, andoutcome.NO_REPLYcompletions.User Impact
Subagent status and completion output remain consistent across yields, kills, restarts, recovery, session listings, cron follow-up, and requester-settle wakes. Existing shipped rows are repaired on schema ensure without a schema-version bump.
Evidence
df703605205bd0b9632b88a33526823caca5ab274bf6538da01: https://github.com/openclaw/openclaw/actions/runs/30689892396patch is correct, confidence 0.94)+410/-413(net-3)Migration tests cover
sessions_yield, provisional kill, newer nested-terminal precedence, missing start timing, malformed JSON, idempotence, typed-column preservation, and thev2026.7.2-beta.6downgrade-reader projection.Legacy Payload Provenance
Root-only SQLite payloads are not a shipped state and are intentionally outside this backfill. Nested execution normalization predates SQLite: commit
d73f3ac85d5madenormalizeSubagentRunStatecreate execution when absent and merge it when present (subagent-delivery-state.ts:34-77). Its JSON reader and writer both normalized records (subagent-registry.store.ts:152-185).SQLite arrived later in
5374c7a8a20. Every SQLite write normalizes before serializing (subagent-registry.store.sqlite.ts:184-185), and the one-time JSON import first uses the normalizing JSON loader before that writer (subagent-registry.store.sqlite.ts:279-297). Therefore no production writer or importer can create a root-only SQLite row.The shipped defect is narrower: for pause/kill rows with an existing nested
execution: {status:"running"}, the old merge order let that nested status win over root terminal facts. Those are the exact observed canonical mismatches repaired and covered here. Adding support for a manually inserted root-only SQLite payload would preserve an unshipped hypothetical state, contrary to the repository's migration/compatibility doctrine; the typed-column downgrade contract remains covered by the actualv2026.7.2-beta.6reader proof below.Real Behavior Proof
Exact proof head:
df703605205bd0b9632b88a33526823caca5ab27after the single refresh onto currentmain.A temporary proof test drove the production pause and kill owners (
markSubagentRunPausedAfterYieldandmarkSubagentRunTerminated), the real SQLite writer, a shared-database close/reopen, additive schema ensure twice, and the current SQLite loader. It was removed after the run. Observed projections:paused-livepauseReason=sessions_yield;execution={status:terminal,startedAt:100,endedAt:200}killed-liveendedReason=subagent-killed; terminalexecution.outcome.status=error; reconciliationkilledAtequals execution endThe post-migration SQLite index columns retained the seeded timestamps (
500/600and700/800) and outcome. A second close/reopen produced an identical map, proving idempotence.Downgrade compatibility was then exercised with the actual shipped reader from tag
v2026.7.2-beta.6at4d6bdbdbf33fe3ece3c53853fab9931882ff3f3cagainst that same upgraded database. It loaded all four rows with the same timing/outcome projections expected by the old runtime: paused100/200, killed300/<owner end>with error outcome, legacy paused500/600, and legacy killed700/800with error outcome. This proves current readers consume canonical nested execution, while shipped downgrade readers continue to receive the preserved typed-column projections.