Repository navigation
fix(agents): apply the fallback delegation gate to CLI-backend runs - #115405
Patrick-Erichsen merged 1 commit into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 12:19 AM ET / 04:19 UTC. ClawSweeper reviewWhat this changesThe branch propagates the existing report-only delegation capability through CLI MCP grants, cache keys, HTTP mapping, and Gateway tool resolution, with regressions for both CLI fallback producers. Regression provenancePossible regression — probable (reviewed change; failure trace; known regression link). No predecessor PR is attributed. Merge readinessKeep this PR open as a viable landing candidate: current main still lacks the CLI loopback propagation, and the refreshed exact-head trace now proves both the allowed and nearest-forbidden final effects. Priority: P1 Review scores
Verification
How this fits togetherCLI-backed agent attempts mint a Gateway loopback grant, then an authenticated child process uses that grant to list and call Gateway tools. The new capability makes fallback completion reports receive the same restricted delegation surface as embedded attempts. flowchart LR
A[Fallback completion report] --> B[CLI attempt producer]
B --> C[Loopback MCP grant]
C --> D[Authenticated Gateway request]
D --> E[Delegation capability gate]
E --> F[Restricted tool list and calls]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +99, Tests +347. Total +446 across 17 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one shared report-only policy and enforce it at the Gateway’s final tool-resolution boundary for CLI fallbacks, backed by the exact producer-to-final-effect regression proof. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source omits the grant, HTTP, and resolver propagation, and the supplied exact-head production trace exercises the corresponding allowed and forbidden tool calls. Is this the best way to solve the issue? Yes. It reuses the shipped shared capability and carries it to the authoritative Gateway resolution boundary rather than creating a CLI-specific delegation policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0e6848e36751. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (40 earlier review cycles; latest 8 shown)
|
4be782f to
8065242
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
6bd850c to
4cf19db
Compare
f5e270a to
9161e57
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Rebased onto current main ( |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Addressed the open P1 on exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Final exact head is |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
@clawsweeper re-review The PR body now carries refreshed exact-head producer proof for |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
@clawsweeper re-review Exact-head authority proof for |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Maintainer merge decision for the two remaining ClawSweeper risk items:
The stored-data-model note is a classifier false positive: |
|
Merged via squash.
|
Refs #92011
Related: #92271
What Problem This Solves
#92011 added a
report_onlydelegation gate for fallback completion-report turns, but only the embedded attempt path applied it. CLI backends get their OpenClaw tools from the Gateway loopback MCP grant, so the runtime shape reported in #92271 could still see and callsessions_spawnand the other delegation launchers.Change
applyDelegationCapabilityafter normal authorization and deny filtering, but before inherited and cron-creator authority are captured.inheritedToolAllowlist,cronCreatorToolAllowlist, availability descriptions, and returned tools from that same gated surface.runCliFallbackCandidateand the command-originrunAgentAttemptpath.The capability is transported through an internal symbol-backed binding, not the public
RunCliAgentParamscontract. Onlyreport_onlycreates the binding; unrestricted/primary runs omit it, preserving their prior grant shape.Review findings addressed
fullfield to the grant.Scope
This PR closes the fallback CLI loopback surface. It deliberately does not wire the separate primary auto-reply CLI dispatch path in
src/auto-reply/reply/agent-runner-cli-dispatch.ts, nor the opt-incliBackendDispatch: "subscription-auth"orchestrator path. Those need separate plumbing and can remain follow-ups.conversations_send/conversations_turnare also left unchanged. Whether unsolicited peer-conversation turns count as new delegation underreport_onlyis a compatibility-policy decision rather than something this PR should decide implicitly.Exact-head producer proof
Environment: macOS, Node
v24.19.0, pnpm12.1.0, exact head3d04d908f3dabf832c62acc33111de6851b71e93.The driver calls the real
runAgentAttempttwice: a primary external-user control and a fallback completion report with{ kind: "inter_session", sourceTool: "subagent_announce" }. A minimal CLI backend and harmless delegation-class plugin tool (llm-task) are installed through the production plugin registry with bundled MCP enabled. The tool's final effect is one append to an isolated marker file.The real producer selects the CLI runtime, mints the grant, writes the strict MCP config, starts a real process-supervisor child, and passes its bearer token and capture key. Each child performs the MCP handshake and sends authenticated production HTTP
tools/list/tools/callrequests to/mcp. The driver does not call the grant builder, minting function, Gateway resolver, or capability gate directly.This proves both final effects on the reviewed head: the primary child retains delegation authority and completes one real tool effect; the report-only fallback cannot discover either delegation launcher, both nearest-forbidden calls fail at the authenticated Gateway boundary, and no second effect occurs.
No live model provider was used; the behavior under test is CLI grant production and Gateway tool authorization, which occur before a model call.
Evidence
Exact-head validation for
3d04d908f3dabf832c62acc33111de6851b71e93:runAgentAttempt→ process-supervisor child → authenticated production loopback HTTP → final-effect proof above — passed, exit 0.resolveGatewayScopedToolsreport-only scenario exposedsessions_spawn/sessions_send; assertion failed as expected.report_onlybecausefallbackActivewas hardcoded; assertion failed as expected. Exact head threads runner-ownedisFallbackRetryand passes.pnpm check— passed.node scripts/run-tsgo-core-test-shards.mjs --stripe 5/5 --concurrency 2— passed.33464835898— passed, includingopenclaw/ci-gate.OPENCLAW_TESTBOX=1 scripts/pr prepare-run 115405— passed with prep/head SHA parity.