Repository navigation
fix(agents): keep subagent status consistent after restart and large fan-outs - #117141
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 10:12 PM ET / August 1, 2026, 02:12 UTC. ClawSweeper reviewWhat this changesThe branch makes canonical persisted subagent-run payloads authoritative during SQLite recovery and replaces repeated registry-wide scans with indexed child-session reads for large subagent fan-outs. Merge readinessThis PR is still necessary: current main reconstructs subagent delivery and wake state from redundant SQLite columns, while the branch makes the complete persisted payload authoritative after recovery. It should remain open for maintainer review; the protected Priority: P1 Review scores
Verification
How this fits togetherOpenClaw persists subagent lifecycle, completion, and delivery obligations in the shared SQLite state database. Gateway recovery and session-list paths reload those records to resume work, show status, and notify requester sessions. flowchart LR
A[Subagent execution] --> B[Canonical run payload]
B --> C[SQLite state]
C --> D[Gateway recovery]
D --> E[Registry read indexes]
E --> F[Delivery and session display]
Decision needed
Why: The patch spans SQLite recovery, requester wake obligations, pending completion delivery, and high-fan-out registry reads, so an owner should accept the cross-cutting state-boundary change. Before merge
Agent review detailsSecurityNone. PR surfaceSource -537, Tests +57. Total -480 across 12 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk options
Maintainer options:
Technical reviewBest possible solution: Keep the complete run payload as the sole recovery authority and retain derived SQLite fields only for indexed queries and bounded projections; merge after the exact head is green. Do we have a high-confidence way to reproduce the issue? Yes: current main reconstructs lifecycle state from redundant SQLite columns, and the PR supplies an after-fix production SQLite close-and-reopen scenario with a deliberately stale indexed delivery flag. This read-only review did not execute the path locally. Is this the best way to solve the issue? Yes: assigning recovery authority to the complete payload at the SQLite storage owner is better than reconciling stale derived facts separately in delivery, wake, snapshot, and display consumers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 475ea69f2c35. 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 (3 earlier review cycles)
|
|
Merged via squash.
|
* origin/main: refactor(ui): replace duplicated locale bundles with canonical translation memory (openclaw#117157) fix(ui): retire stale Gateway event-log observers (openclaw#117169) fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141) test(voice-call): stress paced audio queue drains fix(voice-call): avoid shifting paced audio queues
* commit '7e78de747b8a64d52f30aee948b697bf4c528691': (359 commits) refactor(ui): replace duplicated locale bundles with canonical translation memory (openclaw#117157) fix(ui): retire stale Gateway event-log observers (openclaw#117169) fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141) refactor(ui): unify filtered session list ownership (openclaw#117158) refactor(agents): consolidate context budgets and compaction recovery (openclaw#117149) fix(net-policy): redact sig and x-* auth params in URLs and bodies (openclaw#116957) refactor(agents): remove duplicate generated-media delivery fallbacks (openclaw#117150) refactor(reply): unify turn lifecycle state ownership (openclaw#117145) fix(ui): preserve emoji agent avatar initials (openclaw#104912) refactor(auto-reply): unify command and directive ownership (openclaw#117143) refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146) fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909) fix(slack): let durable ingress retry transient thread lookups (openclaw#117135) refactor(doctor): consolidate shipped state migration ownership (openclaw#117142) fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966) fix: guard every migrated session accessor path (openclaw#117140) fix(terminal): measure unicode display width consistently (openclaw#117062) fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123) fix(mistral): reject incomplete streamed tool terminals (openclaw#117137) fix(ai): preserve structured chat content and refusals (openclaw#117136) ...
* commit '6938f7dddb63bad59862c014c427d63f0a41a6f4': (368 commits) fix: allow gateway service commands for named profiles (openclaw#116314) fix(plugins): invalidate bundled artifact locations after metadata refresh (openclaw#117041) fix(ollama): honor model requests and pull completion contracts (openclaw#117171) fix(agents): prevent fallback after stale lifecycle abort (openclaw#117168) fix(telegram): confirm polling before long poll (openclaw#116970) fix(tlon): wire autoDiscoverChannels through the settings-store round-trip (openclaw#114949) fix(gateway): yield before post-ready background work (openclaw#117083) fix(ui): keep canvas lease renewals lifecycle-owned and timer-safe (openclaw#117173) fix(teams): restore the official square product icon (openclaw#117170) refactor(ui): replace duplicated locale bundles with canonical translation memory (openclaw#117157) fix(ui): retire stale Gateway event-log observers (openclaw#117169) fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141) refactor(ui): unify filtered session list ownership (openclaw#117158) refactor(agents): consolidate context budgets and compaction recovery (openclaw#117149) fix(net-policy): redact sig and x-* auth params in URLs and bodies (openclaw#116957) refactor(agents): remove duplicate generated-media delivery fallbacks (openclaw#117150) refactor(reply): unify turn lifecycle state ownership (openclaw#117145) fix(ui): preserve emoji agent avatar initials (openclaw#104912) refactor(auto-reply): unify command and directive ownership (openclaw#117143) refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146) ...
…fan-outs (openclaw#117141) * fix(agents): canonicalize subagent recovery and indexed lifecycle reads * fix(agents): retain single-scan subagent read-index contract * fix(agents): preserve canonical pending delivery across sqlite recovery
* commit 'bb6345847b6f1634f4c3aea62f4fbaf34b81cecf': fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141) refactor(ui): unify filtered session list ownership (openclaw#117158)
* commit '5148236bbe050f6c05ee59190986a7215b41ce1c': (359 commits) refactor(ui): replace duplicated locale bundles with canonical translation memory (openclaw#117157) fix(ui): retire stale Gateway event-log observers (openclaw#117169) fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141) refactor(ui): unify filtered session list ownership (openclaw#117158) refactor(agents): consolidate context budgets and compaction recovery (openclaw#117149) fix(net-policy): redact sig and x-* auth params in URLs and bodies (openclaw#116957) refactor(agents): remove duplicate generated-media delivery fallbacks (openclaw#117150) refactor(reply): unify turn lifecycle state ownership (openclaw#117145) fix(ui): preserve emoji agent avatar initials (openclaw#104912) refactor(auto-reply): unify command and directive ownership (openclaw#117143) refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146) fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909) fix(slack): let durable ingress retry transient thread lookups (openclaw#117135) refactor(doctor): consolidate shipped state migration ownership (openclaw#117142) fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966) fix: guard every migrated session accessor path (openclaw#117140) fix(terminal): measure unicode display width consistently (openclaw#117062) fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123) fix(mistral): reject incomplete streamed tool terminals (openclaw#117137) fix(ai): preserve structured chat content and refusals (openclaw#117136) ...
* commit '55215cd9edd2b585cbaee5481d5352aabf7e4399': (368 commits) fix: allow gateway service commands for named profiles (openclaw#116314) fix(plugins): invalidate bundled artifact locations after metadata refresh (openclaw#117041) fix(ollama): honor model requests and pull completion contracts (openclaw#117171) fix(agents): prevent fallback after stale lifecycle abort (openclaw#117168) fix(telegram): confirm polling before long poll (openclaw#116970) fix(tlon): wire autoDiscoverChannels through the settings-store round-trip (openclaw#114949) fix(gateway): yield before post-ready background work (openclaw#117083) fix(ui): keep canvas lease renewals lifecycle-owned and timer-safe (openclaw#117173) fix(teams): restore the official square product icon (openclaw#117170) refactor(ui): replace duplicated locale bundles with canonical translation memory (openclaw#117157) fix(ui): retire stale Gateway event-log observers (openclaw#117169) fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141) refactor(ui): unify filtered session list ownership (openclaw#117158) refactor(agents): consolidate context budgets and compaction recovery (openclaw#117149) fix(net-policy): redact sig and x-* auth params in URLs and bodies (openclaw#116957) refactor(agents): remove duplicate generated-media delivery fallbacks (openclaw#117150) refactor(reply): unify turn lifecycle state ownership (openclaw#117145) fix(ui): preserve emoji agent avatar initials (openclaw#104912) refactor(auto-reply): unify command and directive ownership (openclaw#117143) refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146) ...
* origin/main: refactor(ui): replace duplicated locale bundles with canonical translation memory (openclaw#117157) fix(ui): retire stale Gateway event-log observers (openclaw#117169) fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141) test(voice-call): stress paced audio queue drains fix(voice-call): avoid shifting paced audio queues
What Problem This Solves
Fixes inconsistent subagent completion, delivery, requester-wake, and outcome state after Gateway recovery when redundant derived SQLite columns disagree with the canonical persisted run. Also removes whole-registry scans from high-fanout child-session ownership, steering, cancellation, structured-output, and session-display paths.
Why This Change Was Made
The complete subagent run payload and its indexed SQLite columns are written atomically by one production owner, but reads rebuilt lifecycle state from both representations through independent delivery, wake, snapshot, projection, rollback, and runtime-loader paths. Make the canonical payload authoritative, retain indexed columns and bounded session-list projections, share one typed snapshot lifecycle, reuse existing child-session indexes, and centralize identity-preserving transactional rollback.
This maintainer-requested, AI-assisted cleanup removes 537 handwritten production lines while adding 57 lines of focused regression coverage. It does not change the SQLite schema/version, public plugin SDK, archive/restart contracts, collector authorization, direct completion delivery, or exact-row transaction behavior.
User Impact
Subagent status, completion results, delivery retries, requester wake obligations, and swarm output remain consistent across Gateway restart and SQLite reconnection. Large subagent fan-outs avoid repeated full-registry scans while preserving the existing collector, cancellation, steering, waiting, and session-list behavior.
Evidence
provider=blacksmith-testbox, leasetbx_01kyxg62bc8261r8tqb6zsqd8b.pnpm test src/agents/subagent-delivery-state.test.ts src/agents/subagent-registry.store.sqlite.test.ts src/agents/subagent-registry-state.test.ts src/agents/subagent-registry-memory.test.ts src/agents/subagent-registry-queries.test.ts src/agents/subagent-registry-read-context.test.ts src/agents/subagent-registry-read.scoped.test.tspnpm test src/agents/subagent-registry.test.ts src/agents/subagent-registry-lifecycle.test.ts src/agents/subagent-registry.persistence.test.ts src/agents/subagent-registry.persistence.resume.test.ts src/agents/subagent-registry.steer-restart.test.ts src/agents/subagent-registry.announce-loop-guard.test.ts src/agents/subagent-control.test.ts src/agents/tools/agents-wait-tool.test.ts src/agents/tools/swarm-tools.integration.test.ts src/gateway/session-utils.subagent.test.tsexpects_completion_message=0alongside conflicting derived completion, delivery, wake, and outcome columns, closes the database, reopens it, and proves both full lifecycle hydration and bounded session-list projections retain canonical pending delivery. The opposite-direction regression also verifies a canonicalexpectsCompletionMessage=falsestill preserves the shippednot_requiredrepair even when the indexed flag is stale at1.Map.entries()scan and zeroMap.values()scans across repeated descendant queries.src/agents/agent-bundle-mcp-runtime.test.tsfixture was rerun separately as part of this same Blacksmith command; all 90 MCP runtime tests passed..agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output; clean, no accepted/actionable findings.corepack pnpm check:changed.openclaw/ci-gateare green after rerunning only the independently verified, unrelated MCP fixture timing race, and refreshing against currentmainis intentionally unnecessary unless a merge conflict or material persistence-path overlap appears.Real behavior proof: after-fix SQLite close and reopen
Inspectable, redacted terminal output from the production SQLite persistence owner running against a real shared-state database on Blacksmith Testbox, with no mocked gateway or storage. The command writes a canonical pending completion, corrupts its redundant indexed flag and derived columns through the production Kysely adapter, closes the database, reopens it, and reads both the full lifecycle record and bounded Gateway session projection: