Repository navigation
fix: let owners fork a chat with exec after a subagent or exec completion - #206483
Conversation
…ored turn Plugin forks read the owner flag from the latest stored user row. Internal wakes (subagent and exec completions, cron, sessions_send, restart continuations) are stored senderIsOwner: false, so an owner's /better fork was refused whenever a wake came last. - forkPluginSession sets the requester owner flag from the admitted operator grant (operator.admin), explicit false otherwise, for both admission and the run. - readSessionForkRequesterFromTurn no longer returns senderIsOwner. - prepareSessionFork drops the caller param and the senderId === caller clause. - Keep-warm prewarms pass an explicit false. Co-authored-by: obviyus <[email protected]>
|
🦞👀 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: passed. What this changesThis PR derives plugin-fork owner authority from the admitted caller instead of the anchored transcript message. Example: An operator.admin caller requests read, ls and exec immediately after a subagent completion.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR repairs a current fork-authority bug, with no blocking code findings. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Gateway admits plugin fork requests, combines caller authority with the anchored conversation's policy and model, and passes eligible work to the shared session-fork runner. flowchart TD
A[Plugin fork request] --> B[Gateway caller admission]
C[Anchored conversation facts] --> D[Fork requester]
B --> D
D --> E[Session tool policy]
E --> F[Shared fork runner]
F --> G[Model and permitted tools]
Technical reviewBest possible solution: Use the existing admitted caller grant consistently for fork preparation and execution while preserving anchored sender policy and session restrictions. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the refusal path, and the author records matching before/after live Gateway results; this review performed no runtime reproduction. Is this the best way to solve the issue? The patch fixes the shared authority boundary without transcript markers, backfills or another owner producer, and explicitly explains the intentional departure from prior fork policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ee8e86ba2eec. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource 0, Tests +112, Docs +4. Total +116 across 7 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. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 Reviewed November 27, 2026, 2:56 AM ET / 07:56 UTC. |
|
Landed as 8b1df01. Bug: plugin forks such as |
…restoration-ci-189390-20261127 * commit '6feeb50a3f14fbf0aa5167d342f186dc4d67fc18': (9846 commits) fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341) refactor(codex): centralize native completion delivery (#206447) fix(subagents): finish claimed stops after session rotation (#206405) fix: let owners fork a chat with exec after a subagent or exec completion (#206483) test(cli): gate agent --local cold-start processes and workers (#206466) perf(ci): skip baseline inventory when line-cap debt is empty (#189909) refactor(test): share core process-result fixtures (#174149) refactor(ci): reuse canonical budget flag parsing (#189480) fix: recover Codex chats after oversized requests (#206475) fix(agents): skip the bootstrap ritual in one-shot runs (#206477) fix(test): preserve stack coordinates in redacted failure reports (#152384) fix(gateway): return consistent unavailable response guidance (#191933) fix: preserve emphasis in Markdown table row labels (#205349) fix(nextcloud-talk): keep webhook spool helpers private (#206470) perf(plugins): overlay native receipts once per visible root (#206464) fix: keep GitHub comment approvals alive and skip repeat approval on the session PR (#206129) perf(config): retain one snapshot for unchanged validation results (#206465) refactor(test): reuse canonical secret fixture cleanup (#189492) refactor(subagents): own descendant Stop cancellation (#206444) refactor(subagents): keep announce cleanup action type private (#206407) ...
* commit 'fd681ab8786e062045fa5ec6261b1b06f60832eb': (2115 commits) fix: keep doctor --fix pending checks from creating SQLite sidecars (#206485) fix(ci): update iOS screenshot reducer gate (#206497) fix: keep chat photo previews sharp within their byte limits (#206461) fix: let agents use short Workboard card IDs fix(tui): run provider sign-in in the local TUI (#200605) improve(config): reduce repeated directory checks for larger agent rosters (#206494) perf(test): reuse the Periphery producer workflow snapshot (#189681) fix(ci): keep locale assets within the installed package budget (#206492) fix: preserve failed Apple chat messages across partial history pages (#205404) improve: avoid merging unrelated settings for agent directory lookups (#206489) fix: show typing while a queued follow-up turn runs (#201920) fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341) refactor(codex): centralize native completion delivery (#206447) fix(subagents): finish claimed stops after session rotation (#206405) fix: let owners fork a chat with exec after a subagent or exec completion (#206483) test(cli): gate agent --local cold-start processes and workers (#206466) perf(ci): skip baseline inventory when line-cap debt is empty (#189909) refactor(test): share core process-result fixtures (#174149) refactor(ci): reuse canonical budget flag parsing (#189480) fix: recover Codex chats after oversized requests (#206475) ...
* commit 'fd681ab8786e062045fa5ec6261b1b06f60832eb': (923 commits) fix: keep doctor --fix pending checks from creating SQLite sidecars (#206485) fix(ci): update iOS screenshot reducer gate (#206497) fix: keep chat photo previews sharp within their byte limits (#206461) fix: let agents use short Workboard card IDs fix(tui): run provider sign-in in the local TUI (#200605) improve(config): reduce repeated directory checks for larger agent rosters (#206494) perf(test): reuse the Periphery producer workflow snapshot (#189681) fix(ci): keep locale assets within the installed package budget (#206492) fix: preserve failed Apple chat messages across partial history pages (#205404) improve: avoid merging unrelated settings for agent directory lookups (#206489) fix: show typing while a queued follow-up turn runs (#201920) fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341) refactor(codex): centralize native completion delivery (#206447) fix(subagents): finish claimed stops after session rotation (#206405) fix: let owners fork a chat with exec after a subagent or exec completion (#206483) test(cli): gate agent --local cold-start processes and workers (#206466) perf(ci): skip baseline inventory when line-cap debt is empty (#189909) refactor(test): share core process-result fixtures (#174149) refactor(ci): reuse canonical budget flag parsing (#189480) fix: recover Codex chats after oversized requests (#206475) ...
…tion (openclaw#206483) ## What Problem This Solves A plugin that forks the current chat with `exec` (for example better-prompt's `/better`, which calls `api.runtime.subagent.runForkedTurn({ tools: ["read", "ls", "exec"] })`) is refused with "This chat's tool policy does not allow read, ls and exec" when the owner uses it in a chat where the latest input is an internal wake: a subagent completion, an exec completion, a cron or `sessions_send` delivery, or a restart continuation. In an orchestrator chat that is most of the time. Cause: the fork took its owner flag from the latest stored user row (`__openclaw.senderIsOwner`). The host stores every internal wake with `senderIsOwner: false`, whoever started the work. The transcript records who typed an input (attribution), not the authority a run holds. Introduced by openclaw#204411. ## User Impact - An owner (a caller with the `operator.admin` scope) can fork any chat with `exec`, whatever the latest input is. `/better` works after a subagent or exec completion. - A caller without owner authority (for example a session writer with `operator.sessions.write`) still never gets `exec`. `read` and `ls` stay under the session's own policy, unchanged. - Sender, group and channel tool policy still follow the anchored turn. Two plugin-visible behavior changes: 1. **Forks with no admitted operator caller no longer get `exec`, even on owner turns.** A fork started from background work that no Gateway request started (for example an `agent_end` hook) has no operator grant, so `exec` is refused there. Before, such a fork got `exec` when the anchored turn was the owner's. The bundled `skill-workshop` review requests only `["skill_workshop"]` and is unaffected. `plugin-sdk-impact` for `runtime-member:runtime.subagent.runForkedTurn`: 0 static references across 2,768 eligible ClawHub releases (2,333 complete, 432 partial, 3 failed coverage); the only bundled consumer is `skill-workshop`. 2. **An admin calling through a `sessionAccess` method on another person's owner turn now gets `exec`.** openclaw#204411 refused it with a `senderId === caller` clause. That clause closed nothing: the same admin already ran `exec` on that turn through a plain `operator.write` method (its own e2e asserted it). The assertion that refused it is replaced with one that admits it. Deferred, not written: an `ownerAllowFrom` decider for channel callers that arrive without an operator grant. No such fork entry point exists today; it lands when one is proven. ## Why This Change Was Made Authority is checked once, when the work starts, by the owner of that check. `runPluginForkedTurn` already admits the caller (`execution.operatorAuthority`); `forkPluginSession` now sets `requester.senderIsOwner = operatorAuthority?.grant.owner === true` and passes that requester to both `prepareSessionFork` (exec admission) and `runSessionFork` (capability profile, sandbox session tools, plugin tool context, memory-write provenance). The flag is an explicit boolean: several consumers restrict only on `=== false`, so a missing flag would widen access. - `readSessionForkRequesterFromTurn` no longer returns `senderIsOwner`; the anchored turn supplies conversation facts and the model only. - `prepareSessionFork` loses the `caller` parameter and the `senderId === caller` clause; its single producer is gone. - Prompt-cache keep-warm prewarms (no caller, no tools) pass an explicit `false`. - No SDK type change. `SubagentForkedTurnResult` is unchanged. - Docs: `docs/plugins/sdk-runtime.md` says `exec` follows the caller's admitted authority, not the anchored turn. Production code: +28 / −27 lines (flat). Tests: +135 / −23. ## Evidence **Reproduction on the base (merge base 824cc36):** - vitest-source: the new test `runs exec on the caller's admitted authority when the latest input is an internal wake` fails at its first fork with `{ status: "refused", reason: "tool_policy" }` (owner `operator.admin` caller, latest user row a stored `inter_session`/`subagent_announce` wake with `senderIsOwner: false`). The session-writer wake case passes on the base, as expected. - dist-nodts real Gateway E2E: isolated scratch Gateway on a random port, owner Control UI client (trusted-proxy identity with `operator.admin`), real Anthropic `claude-sonnet-5-5`, scratch plugin calling `runForkedTurn` with `["read", "ls", "exec"]` from a `sessionAccess` method. The agent spawned a real subagent; its completion wake became the latest user row (`provenance: inter_session / subagent_announce`, `senderIsOwner: false`, `requesterOrigin.operatorProfileId` set). Fork result: `{ status: "refused", reason: "tool_policy" }`. **Head:** - vitest-source, one `ocx test` call, all green: `gateway-plugin-forked-turn-session-tools.e2e.test.ts` (4), `gateway-plugin-forked-turn.e2e.test.ts` (7), `session-fork-run.test.ts`, `prompt-cache-keep-warm.test.ts`, `session-manager-model-context-limits.test.ts`, `cron/maintenance-lifecycle.test.ts`, `cron/maintenance-snapshot.test.ts`. - Owner caller forks with `read`/`ls`/`exec` after a subagent-completion wake and after an exec-completion (`internal_system`) wake, through a plain operator method and through a `sessionAccess` method: settled, exec output present. - Session writer (`operator.sessions.write`) after a wake: `exec` refused, `read`/`ls` settled. - A non-admin `operator.write` caller's fork reaches the plugin tool with `senderIsOwner: false` (explicit, not missing); the admin caller's fork with `true`. - dist-nodts real Gateway E2E, same script as the base: the latest user row was again a real subagent completion wake (`inter_session` / `subagent_announce`, `senderIsOwner: false`). Fork result: `{ status: "settled", value: { text: "FORK_EXEC_OK" } }`. The recorded provider requests show the fork's `exec` tool call (`echo FORK_EXEC_OK`) and its tool result `FORK_EXEC_OK`, so the command ran, not only the model text. Live Gateway check after both E2E runs: the `ai.openclaw.peanutto` pid did not change, and the live config was last written on 2026-11-24, before these runs. Co-authored-by: Ayaan Zaidi <[email protected]>
* fix(runtime): defer optional work under host memory pressure * style(infra): format memory pressure admission * style(gateway): format the deferred prewarm check (cherry picked from commit 9f50802) Companion audit: #207993 selected later for publication fixture isolation. #206779 required if the new Cron host-memory fixture spoofs platform: preserve native SQLite namespace. #206041/#206230/#206308/#206746 are separate cgroup detection and optimization changes; #206322 is service-aware cron run budget, #206483 forks chat and #206384 changes a main-only warmer. Release adaptation: Extend the stable optional-memory owner and its existing callers only. Preserve cgroup/Bun/macOS behavior and upstream threshold cases; omit main-only prompt warmer, cgroup diagnosis, and Cron platform-spoof changes. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
A plugin that forks the current chat with
exec(for example better-prompt's/better, which callsapi.runtime.subagent.runForkedTurn({ tools: ["read", "ls", "exec"] })) is refused with "This chat's tool policy does not allow read, ls and exec" when the owner uses it in a chat where the latest input is an internal wake: a subagent completion, an exec completion, a cron orsessions_senddelivery, or a restart continuation. In an orchestrator chat that is most of the time.Cause: the fork took its owner flag from the latest stored user row (
__openclaw.senderIsOwner). The host stores every internal wake withsenderIsOwner: false, whoever started the work. The transcript records who typed an input (attribution), not the authority a run holds. Introduced by #204411.User Impact
operator.adminscope) can fork any chat withexec, whatever the latest input is./betterworks after a subagent or exec completion.operator.sessions.write) still never getsexec.readandlsstay under the session's own policy, unchanged.Two plugin-visible behavior changes:
exec, even on owner turns. A fork started from background work that no Gateway request started (for example anagent_endhook) has no operator grant, soexecis refused there. Before, such a fork gotexecwhen the anchored turn was the owner's. The bundledskill-workshopreview requests only["skill_workshop"]and is unaffected.plugin-sdk-impactforruntime-member:runtime.subagent.runForkedTurn: 0 static references across 2,768 eligible ClawHub releases (2,333 complete, 432 partial, 3 failed coverage); the only bundled consumer isskill-workshop.sessionAccessmethod on another person's owner turn now getsexec. fix(plugins): run session-scoped plugin forks in the admitted session #204411 refused it with asenderId === callerclause. That clause closed nothing: the same admin already ranexecon that turn through a plainoperator.writemethod (its own e2e asserted it). The assertion that refused it is replaced with one that admits it.Deferred, not written: an
ownerAllowFromdecider for channel callers that arrive without an operator grant. No such fork entry point exists today; it lands when one is proven.Why This Change Was Made
Authority is checked once, when the work starts, by the owner of that check.
runPluginForkedTurnalready admits the caller (execution.operatorAuthority);forkPluginSessionnow setsrequester.senderIsOwner = operatorAuthority?.grant.owner === trueand passes that requester to bothprepareSessionFork(exec admission) andrunSessionFork(capability profile, sandbox session tools, plugin tool context, memory-write provenance). The flag is an explicit boolean: several consumers restrict only on=== false, so a missing flag would widen access.readSessionForkRequesterFromTurnno longer returnssenderIsOwner; the anchored turn supplies conversation facts and the model only.prepareSessionForkloses thecallerparameter and thesenderId === callerclause; its single producer is gone.false.SubagentForkedTurnResultis unchanged.docs/plugins/sdk-runtime.mdsaysexecfollows the caller's admitted authority, not the anchored turn.Production code: +28 / −27 lines (flat). Tests: +135 / −23.
Evidence
Reproduction on the base (merge base 313b211):
runs exec on the caller's admitted authority when the latest input is an internal wakefails at its first fork with{ status: "refused", reason: "tool_policy" }(owneroperator.admincaller, latest user row a storedinter_session/subagent_announcewake withsenderIsOwner: false). The session-writer wake case passes on the base, as expected.operator.admin), real Anthropicclaude-sonnet-5-5, scratch plugin callingrunForkedTurnwith["read", "ls", "exec"]from asessionAccessmethod. The agent spawned a real subagent; its completion wake became the latest user row (provenance: inter_session / subagent_announce,senderIsOwner: false,requesterOrigin.operatorProfileIdset). Fork result:{ status: "refused", reason: "tool_policy" }.Head:
ocx testcall, all green:gateway-plugin-forked-turn-session-tools.e2e.test.ts(4),gateway-plugin-forked-turn.e2e.test.ts(7),session-fork-run.test.ts,prompt-cache-keep-warm.test.ts,session-manager-model-context-limits.test.ts,cron/maintenance-lifecycle.test.ts,cron/maintenance-snapshot.test.ts.read/ls/execafter a subagent-completion wake and after an exec-completion (internal_system) wake, through a plain operator method and through asessionAccessmethod: settled, exec output present.operator.sessions.write) after a wake:execrefused,read/lssettled.operator.writecaller's fork reaches the plugin tool withsenderIsOwner: false(explicit, not missing); the admin caller's fork withtrue.inter_session/subagent_announce,senderIsOwner: false). Fork result:{ status: "settled", value: { text: "FORK_EXEC_OK" } }. The recorded provider requests show the fork'sexectool call (echo FORK_EXEC_OK) and its tool resultFORK_EXEC_OK, so the command ran, not only the model text.Live Gateway check after both E2E runs: the
ai.openclaw.peanuttopid did not change, and the live config was last written on 2026-11-24, before these runs.