Skip to content

feat(durable): record subagent child runs - #97476

Closed
mjnkao wants to merge 4 commits into
openclaw:mainfrom
mjnkao:codex/openclaw-x-durable-pr4-subagents
Closed

mjnkao wants to merge 4 commits into
openclaw:mainfrom
mjnkao:codex/openclaw-x-durable-pr4-subagents

Conversation

@mjnkao

@mjnkao mjnkao commented Jun 28, 2026

Copy link
Copy Markdown

Summary

This draft PR adds the first durable subagent coordination slice on top of the durable core stack:

  • records subagent work as durable child workflow runs
  • links child runs back to the parent workflow run and parent step
  • records terminal child outcomes durably
  • reconciles the parent fan-in step with a continue-on-child-failure policy
  • keeps the implementation OpenClaw-native and avoids TaskFlow/Workboard coupling

Stack dependency

This PR depends on the earlier durable core draft PRs:

Because this is a stacked contribution from a fork, GitHub may show cumulative diff until the earlier PRs merge or maintainers review the stack in order.

Why

The durable core foundation is useful, but subagent fan-in is the first concrete value slice for the silent/stuck coordinator problem. Parent agents should not depend only on transient coordinator memory to notice that child work succeeded, failed, overflowed, was cancelled, or was lost.

Non-goals

  • No TaskFlow adapter in this PR
  • No Workboard adapter in this PR
  • No AICOS-specific terms or domain semantics
  • No profile, persona, prompt, or skill behavior changes

Validation

The branch was split from the durable core stack and previously validated with the durable test suite and core type/build checks on the full stack.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. size: XL labels Jun 28, 2026
@clawsweeper

clawsweeper Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 28, 2026, 6:58 AM ET / 10:58 UTC.

Summary
The branch adds durable workflow storage/runtime primitives, gateway and CLI inspection/control surfaces, and subagent child-run/fan-in recording for durable subagent coordination.

PR surface: Source +5077, Tests +1242, Docs +2390, Other +3. Total +8712 across 36 files.

Reproducibility: yes. for the review findings: PR-head source shows the durable read RPC opens the store without checking the feature flag, and subagent registration persists raw task text in durable metadata. No live gateway path was run because this is a read-only review.

Review metrics: 3 noteworthy metrics.

  • Env/config surfaces: 5 added. The feature flag, DB path, recovery interval, stale threshold, and heartbeat interval create operator-facing setup and upgrade expectations.
  • Persistent store surface: 1 dedicated SQLite DB, 7 tables. A new durable workflow database needs schema, migration, backup, and doctor lifecycle review before merge.
  • Operator durable controls: 1 RPC, 1 CLI group with 5 write actions. The new read API plus cancel/retry/resume/signal/mark-unknown commands change how operators inspect and mutate workflow state.

Stored data model
Persistent data-model change detected: serialized state: src/cli/program/register.durable.ts, serialized state: src/commands/durable.ts, vector/embedding metadata: src/durable/coordination-projection.test.ts, vector/embedding metadata: src/durable/executor.ts, vector/embedding metadata: src/durable/recovery.test.ts, vector/embedding metadata: src/durable/recovery.ts, and 7 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Fix or obtain maintainer approval for the canonical-state versus dedicated durable DB lifecycle.
  • Remove raw subagent task text from persisted durable metadata and keep only bounded IDs, hashes, titles, or refs.
  • [P1] Add redacted real behavior proof for enabled gateway lifecycle recording, durable.coordination.get, openclaw durable, and subagent child fan-in.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body lists prior validation but includes no redacted terminal output, logs, recording, linked artifact, or copied live output from an enabled durable gateway/CLI/subagent path. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The PR adds a new sidecar SQLite runtime database and durable workflow schema outside the current shared state DB, backup, doctor, and migration lifecycle.
  • [P1] The branch adds durable env/config surfaces, gateway startup/recovery hooks, an operator RPC, CLI write actions, and subagent lifecycle writes, so fresh-install and upgrade behavior need maintainer-visible proof.
  • [P1] The new subagent durable metadata can persist raw subagent task text in a durable database and CLI JSON output, broadening sensitive prompt retention beyond the hashed agent-turn pattern.
  • [P1] The branch is cumulative with open draft prerequisite PRs, so stack ordering and true incremental review are unresolved.
  • [P1] The external PR body lists validation but no redacted real gateway/CLI/subagent output from an enabled durable workflow path.

Maintainer options:

  1. Fix durable contracts before merge (recommended)
    Keep the PR draft until durable state storage, disabled-by-default reads, raw task retention, and enabled-path proof are addressed with focused tests and maintainer-visible rationale.
  2. Pause for stack-order review
    Wait for the prerequisite durable PRs to land or be replaced so this PR can be reviewed as a clean incremental subagent fan-in slice.
  3. Accept as maintainer-owned experiment
    Maintainers could deliberately accept the sidecar DB and new operator surfaces only with explicit ownership of upgrade, backup, privacy, and recovery limitations.

Next step before merge

  • [P1] Manual review is needed because architecture/storage ownership, privacy policy, stack sequencing, and contributor proof are not a narrow automated repair.

Security
Needs attention: The diff has a concrete privacy-sensitive state concern: durable subagent metadata persists raw task prompt text in the new workflow database.

Review findings

  • [P1] Use the canonical durable state database — src/durable/config.ts:16
  • [P1] Stop persisting raw subagent task text — src/durable/subagent.ts:89
  • [P2] Gate durable store reads behind the feature flag — src/gateway/server-methods/durable.ts:26
Review details

Best possible solution:

Resolve the durable stack in order, decide the canonical durable-state lifecycle, gate disabled paths, avoid raw prompt persistence, and add enabled gateway/CLI/subagent proof before merge.

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

Yes for the review findings: PR-head source shows the durable read RPC opens the store without checking the feature flag, and subagent registration persists raw task text in durable metadata. No live gateway path was run because this is a read-only review.

Is this the best way to solve the issue?

No; durable child-run recording is a plausible direction, but this is not the best merge shape until storage ownership, disabled-by-default behavior, sensitive metadata handling, stack order, and real proof are settled.

Full review comments:

  • [P1] Use the canonical durable state database — src/durable/config.ts:16
    resolveDurableWorkflowSqlitePath puts workflow runs, steps, links, timers, signals, and recovery state in a new state/durable/workflows.sqlite sidecar. That bypasses the current shared state DB lifecycle for backups, doctor checks, schema versioning, and migrations, so this needs to move into the canonical state DB or come with an approved dedicated-DB lifecycle and upgrade proof.
    Confidence: 0.87
  • [P1] Stop persisting raw subagent task text — src/durable/subagent.ts:89
    task is copied into durable metadata that is persisted on child runs, steps, links, and events, then exposed through durable inspection paths. The adjacent agent-turn path stores only a hash/ref pattern, so keep the subagent record to IDs, hashes, bounded titles, or external refs instead of retaining full prompt text.
    Confidence: 0.86
  • [P2] Gate durable store reads behind the feature flag — src/gateway/server-methods/durable.ts:26
    The lifecycle writers no-op unless OPENCLAW_DURABLE_WORKFLOWS is enabled, but this RPC opens the durable store unconditionally. Because opening the store creates the state directory and schema, a read against a default disabled install mutates persistent state and makes the prototype look active.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8d168c836af3.

Label changes

Label justifications:

  • P2: This is a substantial draft core feature with meaningful durable runtime and session-state risk, but it is not an urgent shipped regression.
  • merge-risk: 🚨 compatibility: The PR adds env flags, a new persistent state path, a gateway RPC, and CLI commands that can affect operator setup and upgrades.
  • merge-risk: 🚨 session-state: The PR records and reconciles agent/subagent run, child link, fan-in, and terminal state that can change how session work is interpreted after failures or restarts.
  • merge-risk: 🚨 security-boundary: The PR persists raw subagent task text in durable metadata while also exposing durable state through operator inspection paths.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body lists prior validation but includes no redacted terminal output, logs, recording, linked artifact, or copied live output from an enabled durable gateway/CLI/subagent path. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +5077, Tests +1242, Docs +2390, Other +3. Total +8712 across 36 files.

View PR surface stats
Area Files Added Removed Net
Source 22 5079 2 +5077
Tests 7 1242 0 +1242
Docs 6 2390 0 +2390
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 1 +3
Total 36 8715 3 +8712

Security concerns:

  • [medium] Raw subagent prompts persisted in durable metadata — src/durable/subagent.ts:89
    task is copied into durable run/event metadata for subagent records, which can retain sensitive prompt content outside the transcript path and expose it through CLI or operator JSON inspection.
    Confidence: 0.86

What I checked:

  • Repository policy read: Root AGENTS.md and scoped docs/scripts/agents/gateway guides were read; their storage, config, gateway hot-path, and PR review rules affected this review. (AGENTS.md:1, 8d168c836af3)
  • Current main lacks durable core surface: Current main has no src/durable tree or durable command/RPC files, so this PR adds a new core feature rather than updating an existing shipped durable surface. (src/durable, 8d168c836af3)
  • Shared-state contract: The database-first docs define state/openclaw.sqlite as the global control-plane database for shared gateway state, task and flow ledgers, plugin state, scheduler state, backup metadata, and migration state. Public docs: docs/refactor/database-first.md. (docs/refactor/database-first.md:17, 8d168c836af3)
  • Sidecar durable database: The PR resolves durable workflow state to state/durable/workflows.sqlite, creating a dedicated persistent runtime DB outside the current shared state DB lifecycle. (src/durable/config.ts:16, f75a7edef9fa)
  • Store open creates state: Opening the durable store creates the parent directory and initializes seven durable workflow tables, so any unguarded read path can mutate persistent state. (src/durable/sqlite-store.ts:522, f75a7edef9fa)
  • Ungated read RPC: durable.coordination.get opens the durable store without checking OPENCLAW_DURABLE_WORKFLOWS, so a read RPC can create durable state on a default-disabled install. (src/gateway/server-methods/durable.ts:26, f75a7edef9fa)

Likely related people:

  • steipete: GitHub history ties this handle to the shared SQLite state database, database-first migration work, and multiple subagent registry/task attribution changes that overlap this PR's storage and child-run surfaces. (role: feature-history and adjacent state/subagent contributor; confidence: high; commits: bc848b367f0b, f91de52f0d23, 5d81c29cc4f4; files: src/state/openclaw-state-db.ts, docs/refactor/database-first.md, src/agents/subagent-registry-run-manager.ts)
  • vincentkoc: Recent history shows SQLite lifecycle hardening and gateway/session changes near the storage and operator-facing surfaces touched by this PR. (role: recent adjacent SQLite/gateway contributor; confidence: medium; commits: 858fd2c5a296, b470316fc0af, 5571c786d3df; files: src/state/openclaw-state-db.ts, src/gateway/server-methods/agent.ts, src/gateway/server-methods.ts)
  • Feelw00: The current subagent registration path creates background task/TaskFlow records before the new durable mirror; prior task persistence work is directly relevant to avoiding split durable state. (role: adjacent task persistence contributor; confidence: medium; commits: 01193dea2637; files: src/agents/subagent-registry-run-manager.ts, src/tasks/detached-task-runtime.ts)
  • giodl73-repo: Current shallow blame for several touched gateway, agent, and CLI registry files passes through the recent external plugin catalog refactor, so this is a useful routing signal for current file shape but not durable-domain ownership. (role: recent adjacent current-main contributor; confidence: low; commits: 4010b81a77f4; files: src/gateway/server-methods.ts, src/gateway/server-methods/agent.ts, src/cli/gateway-cli/run-loop.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jun 28, 2026

mjnkao commented Jun 28, 2026

Copy link
Copy Markdown
Author

Superseded by #97508. The replacement implementation PR removes raw subagent task persistence and stores bounded ids/labels plus taskHash for coordination metadata.

@mjnkao mjnkao closed this Jun 28, 2026
@mjnkao
mjnkao deleted the codex/openclaw-x-durable-pr4-subagents branch June 30, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant