Repository navigation
refactor(agents): drop mid-run operator re-checks in agent tools, sandbox and command - #204093
Conversation
…dbox and command
Admission already decided the run's operator authority. Delete the mid-run
`operatorAuthority.assertCurrent` reads in src/agents/{tools,sandbox,command};
each path keeps its abort signal (Stop) and its data fences.
Delete tests that asserted a mid-run source revocation refusal.
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. |
|
|
Evidence on head
Tests deleted (they assert a mid-run permission refusal):
verdict.json (checks){
"pass": true,
"prefix": "HEAD",
"models": [
null,
"gpt-5.5-2026-04-23"
],
"checks": [
{
"id": "R.running-turn-finishes",
"pass": true,
"detail": {
"state": "final",
"toolEnds": 3,
"toolEndsAfterRevoke": 3
}
},
{
"id": "Q.queued-input-refused-visibly",
"pass": true,
"detail": {
"accepted": true,
"providerRequestsWithQueuedMarker": 0,
"visibleRefusalInTranscript": true
}
},
{
"id": "S.stop-cancels",
"pass": true,
"detail": {
"abort": {
"ok": true,
"aborted": true,
"runIds": [
"934d7d20-d9a5-449b-a301-17d0445016fb"
]
},
"state": "aborted",
"requestsWithStopMarker": 1
}
}
]
}
|
|
Codex review: needs maintainer review before merge. What this changesThis PR removes repeated operator-authority checks from agent tools, sandbox preparation, and command execution while retaining existing cancellation and target checks. Example: Alice’s operator permissions change after her agent turn starts.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR advances the repository’s admission-once policy, and current main still contains the targeted checks; no concrete introduced correctness defect was established. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway admission supplies host-issued operator authority to agent execution; tools, sandbox provisioning, and command lifecycle code consume that authority to perform work and publish results. flowchart TD
A[Operator request] --> B[Gateway admission]
B --> C[Admitted agent run]
C --> D[Tools and sandbox]
C --> E[Command lifecycle]
F[Stop and target checks] --> D
F --> E
D --> G[Effects and results]
E --> G
Technical reviewBest possible solution: Keep admission authoritative at request start and remove redundant caller rechecks while preserving existing Stop, lifecycle, and target owners. Do we have a high-confidence way to reproduce the issue? The base directly reevaluates operator source predicates during admitted execution, so a subsequently throwing source reaches the reported interruption path; no independent reproduction was run during this read-only review. Is this the best way to solve the issue? The deletion-focused approach uses existing admission and cancellation owners, and the removed assertions correspond to behavior intentionally superseded by the admission-once policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d38fed580398. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -45, Tests -71. Total -116 across 21 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. 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 23, 2026, 9:43 AM ET / 14:43 UTC. |
…elf-archive The run's operator source is admitted once; a revoke during the detached archive or between tool calls in the same run no longer refuses. Co-authored-by: obviyus <[email protected]>
|
Maintainer override: the only red on head
|
|
Landed as 5c2145e. Admitted runs no longer re-check the operator authority mid-run in agent tools, sandbox setup and command prep/post-run: a role or grant change after admission lets the turn finish, and the next request is admitted again. Stop still cancels (each path keeps its abort signal). Proof: one-admission E2E R/Q/S pass, local review clean, CI red only on the main-also |
…dbox and command (openclaw#204093) ## Problem Authority is checked once, when work starts. A started run may finish; Stop cancels; data fences stay. After parts 1–3 (openclaw#203999, openclaw#204031, openclaw#204048), code in `src/agents/**` still calls `operatorAuthority.assertCurrent()` (the admitted run operator authority) mid-run. That call re-runs the source's check and the authority's revocation signal, so a run that admission already allowed can fail partway through. This is part 4b of the agents/sessions/auto-reply refusal sweep: the `src/agents/{tools,sandbox,command}` callers. Part 4a (auto-reply callers) is a separate PR. ## Fix Test for each site: can it fire when only a permission, approval or config changes, and nothing about the run or its data changes? Yes → mid-run authority re-check, deleted. Every site below passed that test. Each path keeps its own Stop signal and data fences; the table says which ones. | Site | Kind | Action | |---|---|---| | `tools/gateway.ts` `readGatewayToolOperatorScopes` | authority (presentation hint; RPC admission decides) | deleted | | `tools/sessions-operator-authority.ts` `captureSessionControlAuthority` per-source `source.assertCurrent` | authority | deleted. The host-issued check and the same-source check do not change, so they now run once at capture. Invocation Stop and its check stay | | `tools/sessions-operator-authority.ts` `prepareSandboxSessionTools` | authority | deleted (host-issued check stays) | | `tools/presence-tool-authority.ts` | authority | deleted. The tool request keeps its `signal` (Stop) | | `tools/agent-step.ts` returned peer result `operatorSource.assertCurrent` | authority | deleted. `operatorSource.signal` (Stop) and the prepared session source stay | | `tools/image-tool.ts`, `tools/pdf-tool.ts` (×3) | authority | deleted. The execution signal (tool signal + operator signal), the invocation check and the runtime claim stay | | `tools/gateway-caller-context.ts` operator selection and `withGatewayToolOperatorContinuation` | authority | deleted. `GatewayToolOperatorSelection.assertCurrent` is now only the selected participant's check, so it is optional | | `sandbox/docker.ts`, `sandbox/docker-backend.ts` | authority | deleted. The runtime/caller checks and the container lifecycle lease stay | | `sandbox/context.ts` (×2), `sandbox/stream-context.ts` | authority | deleted. The workspace signal (abort + operator signal), the state owner and the host guard stay | | `command/prepare.ts`, `maintenance.ts`, `session-preparation.ts`, `post-run.ts` (×3), `cli-compaction.ts` | authority | deleted. The abort signal, the source assertion and the lifecycle generation stay | | `command/model-selection.ts` (×3, including two `assertCommitAllowed` session writes) | authority | deleted. The host-issued check and the model-policy checks from admission stay | None of these sites throws its own refusal string, so the lifetime-check ratchet counts do not change. No text was reworded. Left for part 4c (the next split, 14 production files): `admitted-run-context.ts` (5 internal reads), `bash-tools.exec-runtime.ts`, `model-fallback-runner.ts`, `model-fallback-image.ts`, `operator-run-recovery-source.ts`, `plugin-tool-execution.ts`, `plugin-native-subagent.ts`, `harness/host-source-authority.ts`, `harness/selection.ts`, `cli-runner/tool-authority.ts`, `embedded-agent-runner/compact.queued.ts`, `subagents/spawn/subagent-spawn{,-collector}.ts`, `sessions/session-controller.tool-authority.ts`. ## User impact - When an operator's role, grant or device changes during a run, a started agent turn no longer fails in the middle of session prep, model selection, post-run delivery, CLI compaction, sandbox setup, or the image, PDF, presence, session-control or agent-step tools. The next request is admitted again. - Stop still cancels: each path keeps its abort signal. - No new refusal, prompt or wait. ## Tests Deleted (they assert a mid-run permission refusal): - `agents/tools/gateway.operator-scopes.test.ts` (whole file: revoked source throws while scopes are read). - `agents/tools/sessions-control-authority.test.ts`: source-revocation assertions in 4 cases. The checks on unissued copies, forged sources, insufficient scopes, reassignment and profile facts stay. - `agents/tools/sessions-create-tool.test.ts`: the revocation step of the catalog projection case. - `agents/sandbox/docker.access-lifetime.test.ts`: "does not let a revoked queued caller discard another grant's private custody". An admitted caller's grant is revoked while it waits on the container lifecycle lock. - `agents/tools/sessions-tool.self-archive.test.ts`: the `revoked` row (source revoked during the detached archive) and the `retired-assign` step (a later tool call in the same run after revocation). Found in CI round 1. ## Evidence - One-admission E2E on `846944a58649` (production is unchanged after it): R `running-turn-finishes`, Q `queued-input-refused-visibly`, S `stop-cancels` all pass. Details: openclaw#204093 (comment) - Local review: clean on each head. - `tsgo:core`, `tsgo:test`, oxfmt/oxlint on changed files: clean. `check:changed`: all ratchets and guards pass. - `server-methods/users-personal-file.test.ts` "live" rows fail on main too (merge base `a02826832065`, locally; ci-triage MAIN-ALSO). Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
Authority is checked once, when work starts. A started run may finish; Stop cancels; data fences stay. After parts 1–3 (#203999, #204031, #204048), code in
src/agents/**still callsoperatorAuthority.assertCurrent()(the admitted run operator authority) mid-run. That call re-runs the source's check and the authority's revocation signal, so a run that admission already allowed can fail partway through.This is part 4b of the agents/sessions/auto-reply refusal sweep: the
src/agents/{tools,sandbox,command}callers. Part 4a (auto-reply callers) is a separate PR.Fix
Test for each site: can it fire when only a permission, approval or config changes, and nothing about the run or its data changes? Yes → mid-run authority re-check, deleted. Every site below passed that test. Each path keeps its own Stop signal and data fences; the table says which ones.
tools/gateway.tsreadGatewayToolOperatorScopestools/sessions-operator-authority.tscaptureSessionControlAuthorityper-sourcesource.assertCurrenttools/sessions-operator-authority.tsprepareSandboxSessionToolstools/presence-tool-authority.tssignal(Stop)tools/agent-step.tsreturned peer resultoperatorSource.assertCurrentoperatorSource.signal(Stop) and the prepared session source staytools/image-tool.ts,tools/pdf-tool.ts(×3)tools/gateway-caller-context.tsoperator selection andwithGatewayToolOperatorContinuationGatewayToolOperatorSelection.assertCurrentis now only the selected participant's check, so it is optionalsandbox/docker.ts,sandbox/docker-backend.tssandbox/context.ts(×2),sandbox/stream-context.tscommand/prepare.ts,maintenance.ts,session-preparation.ts,post-run.ts(×3),cli-compaction.tscommand/model-selection.ts(×3, including twoassertCommitAllowedsession writes)None of these sites throws its own refusal string, so the lifetime-check ratchet counts do not change. No text was reworded.
Left for part 4c (the next split, 14 production files):
admitted-run-context.ts(5 internal reads),bash-tools.exec-runtime.ts,model-fallback-runner.ts,model-fallback-image.ts,operator-run-recovery-source.ts,plugin-tool-execution.ts,plugin-native-subagent.ts,harness/host-source-authority.ts,harness/selection.ts,cli-runner/tool-authority.ts,embedded-agent-runner/compact.queued.ts,subagents/spawn/subagent-spawn{,-collector}.ts,sessions/session-controller.tool-authority.ts.User impact
Tests
Deleted (they assert a mid-run permission refusal):
agents/tools/gateway.operator-scopes.test.ts(whole file: revoked source throws while scopes are read).agents/tools/sessions-control-authority.test.ts: source-revocation assertions in 4 cases. The checks on unissued copies, forged sources, insufficient scopes, reassignment and profile facts stay.agents/tools/sessions-create-tool.test.ts: the revocation step of the catalog projection case.agents/sandbox/docker.access-lifetime.test.ts: "does not let a revoked queued caller discard another grant's private custody". An admitted caller's grant is revoked while it waits on the container lifecycle lock.agents/tools/sessions-tool.self-archive.test.ts: therevokedrow (source revoked during the detached archive) and theretired-assignstep (a later tool call in the same run after revocation). Found in CI round 1.Evidence
846944a58649(production is unchanged after it): Rrunning-turn-finishes, Qqueued-input-refused-visibly, Sstop-cancelsall pass. Details: refactor(agents): drop mid-run operator re-checks in agent tools, sandbox and command #204093 (comment)tsgo:core,tsgo:test, oxfmt/oxlint on changed files: clean.check:changed: all ratchets and guards pass.server-methods/users-personal-file.test.ts"live" rows fail on main too (merge base6c8c6dd946b7, locally; ci-triage MAIN-ALSO).