Repository navigation
feat(plugins): let plugins recover native subagents they launched - #180274
fuller-stack-dev merged 1 commit into
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. |
1a119c0 to
4189d83
Compare
|
Codex review: needs maintainer review before merge. What this changesThis PR lets plugins rediscover their native subagents through an optional, requester-scoped list method. Example: Plugin test-plugin loses the acceptance receipt for request owned.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR adds useful receipt recovery, the earlier storage compatibility concern is resolved, and no actionable introduced defects were found; required CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe plugin runtime adapts requester-authorized native tools; spawn records ownership in the existing subagent registry, and listing returns bounded child metadata after current authority and policy checks. flowchart TD
A[Eligible plugin invocation] --> B[Requester runtime facade]
B --> C[Current authority and tool policy]
C --> D[Native spawn owner]
D --> E[Existing SQLite registry]
C --> E
E --> F[Scoped child metadata]
F --> A
Technical reviewBest possible solution: Keep host-captured ownership in the existing registry and expose only the bounded, currently authorized recovery projection. Do we have a high-confidence way to reproduce the issue? Source confirms that current main has no plugin-scoped discovery method after an acceptance receipt is lost; the supplied boundary cases exercise that recovery scenario. Is this the best way to solve the issue? The change uses the existing spawn, registry, and requester-policy owners, with necessary ownership metadata and no competing store or lifecycle manager. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8d6cb3d4d4bb. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +261, Tests +540, Docs +27. Total +828 across 21 files. Added test files: 2. View PR surface stats
LabelsLabel changes:
Label justifications:
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 HistoryReview history (1 earlier review cycle)
Reviewed October 22, 2026, 1:03 AM ET / 05:03 UTC (Revision 2). |
4189d83 to
bdbe90c
Compare
Add optional NativeSubagentRuntime.list({ status? }), advertised as native-subagent-list-v1, so a plugin can rediscover requester-owned native children it accepted but did not persist. Ownership is host-captured at spawn, listing reuses the canonical registry and the current tool/sandbox policy, and spawn/list/collect share one callable native reader check.
bdbe90c to
68bc660
Compare
|
@clawsweeper re-review Addressed the data-model compatibility item at Ownership is stored in the existing
Mutation check: a reader that drops stored ownership, or one that rejects rows without it, makes this case fail. The source was restored and its hash verified afterwards. Exact-head local results:
The only failing CI shard so far is the inherited |
|
🦞👀 Re-review progress:
|
|
Merging with The only failing job is That same test fails on |
The command runtime projected `subagents` to spawn and collect so scheduling stays outside that object, which dropped the optional `list` helper added by openclaw#180274 for every command. Forward `list` when the native runtime provides it, and pin the exact helper set through a real command invocation.
#180282) * feat(plugins): let requester commands schedule bounded follow-up turns Authenticated requester commands that opt into `scheduledTurns` can schedule bounded follow-up turns of the same command. Each occurrence restores the original requester under current policy, rechecks the exact parent session and loaded plugin instance, refuses direct model calls, and must route model work through admitted native subagents. - Bounds: deadline at most 7 days, maxRuns 1-100, 4 schedules per invocation and 8 active schedules per loaded plugin instance and parent session. Only enabled schedules of the same instance in the current Gateway process count. - Retirement: the scheduler disables the job and clears its next run in the same transaction that launches the final allowed attempt or finds it expired, exhausted, invalid or from a previous process. A replaced plugin instance retires the schedule on its first refusal. - v1 scope: schedules end when the Gateway restarts or the plugin reloads; plugins re-enroll from a later requester command. - Rows persist under a dedicated `pluginCommand` payload kind so hosts without this feature quarantine them instead of running a model prompt. - `command-scheduled-turns-v1` advertises support. - The session-event route predicates move to `timer-session-route.ts` so a scheduled occurrence can never prepare parent notices or prompt the model. * refactor(plugins): break scheduled command import cycles Move the stored schedule contract and its reserved message into `src/cron/plugin-command-schedule.types.ts`, and the native subagent request source into `src/agents/plugin-native-subagent.types.ts`, so cron types, creation and storage, and the native subagent runtime and scheduled turns no longer import each other. No behavior change. * test(plugins): prove queued scheduled children re-admit their requester A scheduled occurrence queues a native child, settles, and the child launches later through the real Gateway instance runtime. While the requester stays authorized the child passes the agent turn's admission revalidation; after the requester is demoted (committed and published as `users.setRole` does), the next queued child is refused at that admission, before any model runner. * test(plugins): close the agent turn runtime without awaiting a void result * fix(plugins): keep the native child list helper in command runtimes The command runtime projected `subagents` to spawn and collect so scheduling stays outside that object, which dropped the optional `list` helper added by #180274 for every command. Forward `list` when the native runtime provides it, and pin the exact helper set through a real command invocation.
…#180274) Add optional NativeSubagentRuntime.list({ status? }), advertised as native-subagent-list-v1, so a plugin can rediscover requester-owned native children it accepted but did not persist. Ownership is host-captured at spawn, listing reuses the canonical registry and the current tool/sandbox policy, and spawn/list/collect share one callable native reader check.
openclaw#180282) * feat(plugins): let requester commands schedule bounded follow-up turns Authenticated requester commands that opt into `scheduledTurns` can schedule bounded follow-up turns of the same command. Each occurrence restores the original requester under current policy, rechecks the exact parent session and loaded plugin instance, refuses direct model calls, and must route model work through admitted native subagents. - Bounds: deadline at most 7 days, maxRuns 1-100, 4 schedules per invocation and 8 active schedules per loaded plugin instance and parent session. Only enabled schedules of the same instance in the current Gateway process count. - Retirement: the scheduler disables the job and clears its next run in the same transaction that launches the final allowed attempt or finds it expired, exhausted, invalid or from a previous process. A replaced plugin instance retires the schedule on its first refusal. - v1 scope: schedules end when the Gateway restarts or the plugin reloads; plugins re-enroll from a later requester command. - Rows persist under a dedicated `pluginCommand` payload kind so hosts without this feature quarantine them instead of running a model prompt. - `command-scheduled-turns-v1` advertises support. - The session-event route predicates move to `timer-session-route.ts` so a scheduled occurrence can never prepare parent notices or prompt the model. * refactor(plugins): break scheduled command import cycles Move the stored schedule contract and its reserved message into `src/cron/plugin-command-schedule.types.ts`, and the native subagent request source into `src/agents/plugin-native-subagent.types.ts`, so cron types, creation and storage, and the native subagent runtime and scheduled turns no longer import each other. No behavior change. * test(plugins): prove queued scheduled children re-admit their requester A scheduled occurrence queues a native child, settles, and the child launches later through the real Gateway instance runtime. While the requester stays authorized the child passes the agent turn's admission revalidation; after the requester is demoted (committed and published as `users.setRole` does), the next queued child is refused at that admission, before any model runner. * test(plugins): close the agent turn runtime without awaiting a void result * fix(plugins): keep the native child list helper in command runtimes The command runtime projected `subagents` to spawn and collect so scheduling stays outside that object, which dropped the optional `list` helper added by openclaw#180274 for every command. Forward `list` when the native runtime provides it, and pin the exact helper set through a real command invocation.
What Problem This Solves
A plugin that launches native subagents can lose track of an accepted child: if it crashes or is interrupted after the host accepts the spawn but before the plugin saves the returned ID, spawn and collect alone give it no way to find that child again.
User Impact
Plugin developers can call the new optional
ctx.runtimeContext.subagents.list({ status? })to recover the native children their plugin launched for the current requester, then collect them as usual. Hosts advertise support with thenative-subagent-list-v1capability; older hosts simply do not offerlist. Plugins can only see their own children for the same requester and parent session, never another plugin's, another requester's, or a reset parent's. Children accepted before this change carry no ownership record and are intentionally not listed.Why This Change Was Made
Recovery reads the host's existing native-child registry instead of adding a plugin-side store or a second index.
agents_wait. A reader that is missing, denied for the turn, blocked by sandbox policy, or shadowed by a same-named tool is refused, with no administrator fallback. Spawn and collect now use the same callable-reader check, so a name-only match can no longer pass on the joined spawn path either. A config change during a listing fails with a retryable error instead of returning a stale answer.{ runId, childSessionKey, requestId, label?, status }, with no task text, results or authority material. Terminal execution is reported as such and is not presented as successful completion.Spawn, collect and reply-dispatch signatures are unchanged; the reply adapter forwards
listonly when the runtime implements it. No hook, scheduler, pagination, database or plugin-specific routing is added.Builds on #180173 (plugin commands launching native subagents), now merged; this branch is rebased onto
maincontaining it.Evidence
Run at this head on
main(including #180173 and #180283), with task-private HOME, TMPDIR, state and handoff SQLite store, and inheritedOPENCLAW_*removed. No live Gateway or provider was used.subagent-spawn.production-boundary.test.ts)tsgo)oxfmt --check, export-name-collision guardThe new behavioral cases run through the real reply/command native facade, admission and SQLite registry:
list,collectandspawnrefused, with no preparation, registry row or model run, whenagents_waitis absent, denied for the turn, or shadowed by a same-named tool;listrejected under an explicit sandbox deny, the sandbox default allowlist, and a sandbox-required session, and allowed otherwise; live tool-policy revocation; operator-source revocation;These tests failed before the fixes. Two of the failures: a denied reader made
listreturn[]instead of rejecting, and a sandbox-deniedlistreturned the child. Reverting the tie-break to locale order, or to internal-ID order, fails the tie test.An independent review of the same change on its previous base measured the Plugin SDK API acknowledgement digest
10f223cf. It found no new public facade API beyond the optionallistmethod and its child type, and one internal declaration (isAgentToolExecutionAvailable). The digest will be rechecked by CI on this base.check-changedpassed 34 of 37 gates. The three failures do not involve this change. The max-lines suppression ratchet flags three untouched UI files. The core test-shard root budget is over in the gateway-root and infra graphs. The dead-export scan lists none of this change's exports. All three also appear without this change.src/plugins/memory-background-reload.test.tstimes out onmainwithout this change. It reproduces locally on #180173's based20b7fbc6c7, and #180173 attributes it to #178979. That suite runs here only because this change touchessrc/plugins/**.