Repository navigation
Conversation
A subagent spawned by an isolated scheduled run resolved toolsBySender again when it started, from the run's senderless origin, and got the "*" entry even when the run itself resolved without sender policy (a run capped with toolsAllow, or an owner's internal run). The child then lost tools the run had, and got any grants or side effects of the "*" entry the run never applied. Record at spawn, on the host side, that the spawning turn was such a run: "scheduled-run" next to the inherited snapshot, together with the run's own per-run session key. It is recorded only for a turn on a per-run session the isolated runner created fresh for this run (a fact from the run's admitted scheduled context, never the key's shape), with no sender and no operator. A per-run session key can still be targeted by other turns (another job with that session target, a hook with a request session key, an operator), so the key alone does not identify the run. The run's own turn therefore stamps its requester origin with its session key when its tools are built; the stamp is taken only from that host result, is carried by origin copies of the same run (Gateway loopback tool calls, the outer run's caller identity, inputs the run queued), and is never read from request content. A later admission keeps the child's spawn snapshot only when its origin carries that stamp and is that same run: senderless, no operator, the same session key. The check reads only the child's own row, so rewrites of the run session (compaction, model fallback, post-prompt sync) do not invalidate an admitted child. Nested children receive the record from their parent's admission. Any other turn on the run's session, a run aborted by a Gateway restart or retried under a new key, runs that apply sender policy, shared or named sessions, and children spawned before this change keep resolving current sender policy as before.
|
🦞👀 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: blocked before merge. What this changesPreserves a scheduled run’s inherited tool snapshot for descendants handling work from that same run occurrence. Example: An isolated automation allows read and sessions_spawn while toolsBySender["*"].deny contains read.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 1 item remains This PR repairs a current-main scheduled-delegation regression; no actionable introduced defects were found, and current-head maintainer security approval remains required. Priority: P2 Before merge
FindingsNone. Agent review detailsHow this fits togetherCron admits an occurrence, tool preparation captures its requester policy, spawn persists the child’s ceiling, and later admissions combine that ceiling with applicable current restrictions. flowchart TD
A[Cron occurrence admission] --> B[Prepared requester policy]
B --> C[Stamped requester origin]
B --> D[Persisted child tool snapshot]
C --> E[Child execution admission]
D --> E
E --> F[Filtered tool execution]
Technical reviewBest possible solution: Retain this occurrence-scoped repair in the existing requester-policy and spawn owners while preserving current restrictions for unrelated admissions. Do we have a high-confidence way to reproduce the issue? Current-main source shows origin-bearing scheduled children selecting current wildcard sender policy, and the linked report supplies matching built-Gateway tool listings. Is this the best way to solve the issue? The repair addresses the lost occurrence distinction at the existing policy owner, preserves inherited ceilings, and avoids adding parent-row dependencies or a parallel authority resolver. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2e1b61901c5d. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +259, Tests +871, Docs 0, Other +2. Total +1132 across 57 files. Added test files: 3. 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: No label 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 (5 earlier review cycles)
Reviewed November 15, 2026, 8:19 AM ET / 13:19 UTC (Revision 6). |
The config and before-tool-call mocks in mcp-http.scheduled-run-origin.test.ts now spread the real module via importOriginal and override only the export the test needs, as the mock-export ratchet requires. The tool resolver mock stays closed with a mock-isolation note: the real resolver loads the whole Gateway tool surface, while these rows only check the origin it hands back. The test-line allocation covers the added lines.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…d-tool-snapshot Resolve src/cron/isolated-agent/run-prompt-executor.ts after openclaw#188514 moved resolveCliChildAbortSignal into run-admission.ts: use main's helper, keep hasCliSessionReuseMetadata in run-cli-session.ts, and keep the scheduled-run freshRunSessionKey binding.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…d-tool-snapshot Resolve src/agents/agent-tools.delegated-authority.test.ts after openclaw#188552 appended its prepared-write tests: keep both test blocks and the combined gateway-caller-context import. The import now replaces main's one-line import, so the exact test-line allocation drops from 868 to 867.
|
The current CI failure at The security guard separately requires fresh maintainer approval for the current SHA. The earlier no-findings review covered |
…d-tool-snapshot No conflicts. Picks up main's restored test-line headroom (openclaw#188780); the allocation stays 867.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Fresh exact-head CI at
Merging current main again should pick up #189244 for the publication case. The subagent-spawn fixtures need the same host binding upstream before this head can go green. ClawSweeper's fresh review of this head found no actionable code findings; the remaining merge block is maintainer security approval for the sensitive changes. |
…d-tool-snapshot No conflicts. Picks up main's SDK host binding for the X publication fixture (openclaw#189244); the allocation stays 867.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…d-tool-snapshot Conflicts: - src/agents/agent-tools.ts: main moved tool assembly into agent-tools.assembly.ts; the run-key pass-through next to inheritedToolPolicySource moves with it. - src/agents/harness/codex-subagent-tool-policy.test.ts: keep both appended tests. - src/cron/execution-context-admission.test.ts: import both sides' registry helpers. The test-line record now covers the growth above main's 400-line allowance (openclaw#197602): 871 net test lines, record 471.
- Main's embedded-runner mock rename (openclaw#190017) left the scheduled-run session identity rows on the old mock; use the file's runner mock. - Main brought subagent-spawn.ts to its 700-line cap. The spawn's tool-policy source rule (sender, or a scheduled-run mark only with its run key) moves into inheritedToolPolicySourcePatch beside the inherited allow/deny patches; native spawn, its session patch and ACP spawn share it instead of repeating it, and the native spawn passes delegation.policy directly instead of a single-use alias. No behavior change.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Closes #188441
Related: #178815 (broader consolidation of child authority; this change only restores the spawn snapshot for one case)
What Problem This Solves
Fixes: a subagent spawned by an isolated scheduled run gets the guest
toolsBySender["*"]entry when it starts, even though the run itself does not apply sender policy (a run capped withtoolsAllow, or a run of a job an owner created).User Impact
User impact: subagents (and their own subagents) of such runs now get the same sender policy as the run: the tool snapshot recorded when they were spawned, as released versions do. Current global, agent, provider, sandbox and sub-agent restrictions still apply.
The guest
"*"entry no longer applies to these children in place of the run's policy, which has three visible effects, all matching the run itself:"*"entry grants (for example an optional plugin tool in itsalsoAllow) no longer reach these children, as they never reached the run;Unchanged:
"*"entry, like the run;session:target, a hook request naming that session key, an operator turn) still resolves current sender policy;mainandsession:targets, including names shaped like run keys) never record the exception;Not changed (same as
main, no regression):sessions_spawnwithvisible: true, orsessions.create) do not carry it: their creation path does not persist the record;when-sender-id, so it is not marked;runtime: "acp") get no sub-agent envelope from a scheduled run (as onmain), so the record is not read for them;Why This Change Was Made
Since #157806, a child's admission that carries its requester's origin resolves current requester policy again from that origin. A scheduled run's origin has its run session key but no sender, so the lookup fell through to
"*", whether or not the run applied sender policy, and nothing a child's later admission can read recorded which it was.The spawning turn now records it next to the child's inherited snapshot, and a later admission keeps the snapshot only when the request comes from that same run occurrence: its own turn stamps its requester origin with its fresh per-run session key, so another turn opened on the same session (another job, a hook, an operator) never counts as the run.
Docs: the
nesting.mdtool-policy line now describesmain's behavior since #157806 (senderless work that carries a requester origin re-resolves current sender policy; released versions kept the snapshot for every senderless child run) and states this exception, which restores the snapshot only for a run's own work.How the exception is recorded and checked
The record is
inheritedToolPolicySource: "scheduled-run"together withinheritedToolPolicyRunSessionKey, the run's own per-run session. The host writes both only when the spawning turn resolved without sender policy, with no sender and no operator, on a per-run session that the isolated runner created fresh for this run. That last fact comes from the run's admitted scheduled execution context (set only for detached isolated orcurrentruns whose run key is new), never from the shape of the session key.sessions.patchdoes not accept either field, plugin extension slots cannot claim their names (reserved), and patching a child's inherited allow or deny list drops the exception.A later admission keeps the snapshot only when the request origin is that same run: senderless, no operator, its session key equal to the recorded one, and stamped by that run's own turn. The run's own turn stamps the requester origin it hands to its tools with its per-run session key (
scheduledRunSessionKey, set only from the same host fact that records the exception, copied only from an already captured origin, never from flat request input); its sub-agents inherit that origin unchanged. The new check reads only the child's own row; it adds no parent or intermediate row reads (an explicit delegation grant keeps its existing lineage check), so compaction, model fallback or the post-prompt sync of the run session cannot invalidate an admitted child's prepared policy. Nested children receive the exception and the run key from their parent's own admission. Completion batches keep it only when every completing child records the same run. Any other origin-bearing admission drops it.SessionEntry(exported through the plugin SDK) gains the"scheduled-run"source value and the optional run key.Housekeeping (line caps):
hasCliSessionReuseMetadatamoves unchanged fromrun-prompt-executor.tstorun-cli-session.ts; the newsessions.patchrows live insessions-patch.subagent-policy.test.ts.Evidence
Built Gateway from this branch and, for the
maincolumn, the same build with every changed source file swapped back tomain(b9dd04d047f); scripted model;toolsBySender: { "*": { deny: ["read"] } }; capped runs use atoolsAllowthat includesread. Each cell is what the run's child got when it calledreadon a sentinel file in that turn (offered and returned the file / refused / not offered).mainsessions_send)2026.10.8,2026.10.9or2026.11.3(the pre-upgrade child row stays unmarked)sessionTargetissession:<run A's key>sends to the child"*"policy)"*"policy)"*"policy)"*"policy)chat.sendon run A's key sends to the childsession:target (not a per-run session)"*"itself): its child"Refused" rows: the call is refused at execution with "read is not available in this turn" under the current
"*"policy. Unlikemain, wherereadis never offered, it stays listed because it was offered on the run's own earlier turn (definitions stay pinned within a session). Runs hosted by the Codex harness are not exercised end to end here.src/agents/requester-tool-policy.test.ts: the record (only a run's own turn on its fresh session; not a run-shaped key without the runner's fact, another session, sender policy, an operator, a sender or a group restriction), the check (child, nested child, blank sender kept; legacy child, a mark without its key, another session, the run's stamp on another session, a later run, operator, sender re-resolve), side effects, origin-free resume, completion batches, own-row capability reads, and a prepared read replayed after the run's row is rewritten.requester-origin.test.ts(only from a captured origin, carried only for the same session),conversation-capability-profile.test.ts/tool-resolution.scheduled-run-origin.test.ts(only the run's own turn on its fresh session stamps),gateway-caller-context.test.ts,agent-tools.delegated-authority.test.ts,mcp-http.scheduled-run-origin.test.ts(callers and loopback calls keep the stamped origin).codex-subagent-tool-policy.test.ts: the Codex harness's retained requester facts for a run child name only the child's row.acp-spawn-policy.test-support.ts, mutant only): run key and exception persist only together. Execution context rows: the fresh run session is exposed only for a detached run on its own fresh session.sessions.patchrows (sessions-patch.subagent-policy.test.ts): a patched ceiling drops the exception, never a sender restriction.main's production source fails its new rows on their assertions in 8 files, e.g.keeps the sender snapshot for a child of a senderless scheduled run:expected { allow: undefined, deny: [ …(2) ] } to be undefined(mainapplies the"*"deny to the child).requester-origin.test.ts,execution-context-admission.test.tsandisolated-agent.session-identity.test.tscall helpersmaindoes not have, so they fail on the missing helper rather than on a behavioral assertion and their rows are covered by the mutants below;codex-subagent-tool-policy.test.tspasses onmainby design (it pins that a run child's harness facts name only the child's row).tsgo:core,tsgo:core:test, oxlint, oxfmt on the touched files,check:test-lines-ratchetandgit diff --check: clean.config/test-lines-allocations/scheduled-run-child-tool-snapshot.txt(rows on each owner of the record, the run-key check and the stamp; the table above is the end-to-end proof). Per-file test time (pnpm test <file> --maxWorkers=1), base -> head:requester-tool-policy.test.ts11.2 -> 12.4 s (+38 tests),isolated-agent.session-identity.test.ts27.3 -> 30.8 s (two rows on the real isolated runner); the other changed files within 0.5 s of base, includingconversation-capability-profile.test.ts(44.1 -> 43.6 s, over 30 s onmain) andagent-tools.delegated-authority.test.ts(29.9 -> 29.8 s, with the three caller rows folded in instead of a new file); new filestool-resolution.scheduled-run-origin.test.ts12.0 s,mcp-http.scheduled-run-origin.test.ts12.9 s,sessions-patch.subagent-policy.test.ts10.7 s (mostly transform of the Gateway modules they test). CI seconds once available.