Skip to content

fix(claude-cli): ask native tool approvals instead of denying them under exec ask - #183984

Merged
steipete merged 1 commit into
openclaw:mainfrom
holgergruenhagen:fix/claude-cli-native-approval-owner
Oct 26, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
holgergruenhagen:fix/claude-cli-native-approval-owner

Conversation

@holgergruenhagen

@holgergruenhagen holgergruenhagen commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: native Claude Code tools are denied immediately, without an approval prompt, when a claude-cli turn uses exec ask on-miss or always.

User Impact

Operators can approve or deny native tools exposed by managedNativeTools or the node exec host. Deny, timeout, cancellation, and unavailable approval routes still fail closed. Existing non-prompting policies are unchanged.

Why This Change Was Made

Native approval registration omitted the backend owner required by the Gateway's agent-runtime authority check. Bind that request to the existing backend owner, as the other approval paths already do. Keep decision waiting outside that binding and retain the host's final active-run check. Log unavailable approval errors so operators can diagnose failures; intentional aborts stay quiet.

Thanks to @holgergruenhagen for the fix and isolated-Gateway reproduction. The simplification pass retained the focused implementation: it adds no new policy, configuration, or state owner. Net delta: production +14 lines, tests +35 lines. The small production increase supplies owner binding and failure diagnostics.

Evidence

  • Current-main regression: the production module on 642b31d1993bd93ce3a0ea68fc3bf581a8058ab1 is identical to the PR baseline. Running the owner regression against that module fails because plugin.approval.request has no claude-cli owner; the other 40 cases were skipped for this red run.
  • Fixed head: node scripts/run-vitest.mjs src/agents/cli-runner/cli-native-tool-approval.test.ts --maxWorkers=1 passes 41/41. Runner wall time was 198.47 s, including a cold shared-worker build; Vitest reported 164.01 s, with about 4% spent in tests.
  • Static checks: targeted oxlint and oxfmt pass. Local tsgo refuses this linked worktree's shared dependency installation; exact-head CI provides the broad type/build proof.
  • Independent review: Codex autoreview found no actionable P0–P2 issues in the committed patch.
  • CI: run 40248165098 is green for b89bbfbeec508f73f697f498fc408a936aad0e38; the repository watcher reports GREEN. Local merge-tree verification against current main is conflict-free.

Live proof supplied by the contributor, using isolated Gateways and the real Control UI: before the fix, native Agent calls under ask policy were denied after 30–45 ms with no pending approval, and native Read on the node-host path was denied after 60 ms. With this production patch, Agent and Read created approval requests and ran after allow-once; explicit denial and a 120-second timeout remained denied. An ordinary exec approval and non-prompting native tool execution remained working controls.

The contributor also tested stop, stop followed by a new turn, session reset, and turn replacement while approval was pending. All four cancelled the old request, rejected late approval, and left the test marker absent; the active-turn control wrote its marker. The pending approval screenshot is retained below.

Native Agent approval with Allow once, Always allow, and Deny actions

Not repeated in this maintenance pass: an authenticated Claude Code/Control UI round-trip. The existing isolated-Gateway evidence covers the unchanged production patch; no new authenticated harness was introduced.

Related: #138853 concerns the separate approval-route limitation of turns sent through gateway call chat.send; this PR does not claim to fix it.

…der exec ask

Under exec ask (on-miss or always), native Claude Code tools in claude-cli
turns (Agent/Workflow kept by the managedNativeTools opt-in, or native Read
through exec host node) were denied about 30 ms after the call without any
approval request. requestCliNativeToolApproval called plugin.approval.request
without naming the backend as approval owner, so the Gateway rejected the
agent-runtime request with "signed plugin approval owner is unavailable" and
the catch turned that into "approval was not granted".

Wrap the request in withGatewayToolApprovalOwner like the before_tool_call
and harness approval paths do, and log the swallowed Gateway error before
failing closed (aborts stay silent).

Docs promise this path: docs/gateway/cli-backends.md, "Keeping Claude Code
orchestration tools on managed turns" ("ask on-miss or always routes it
through approval").
Context: openclaw#183765
@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Oct 26, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR binds native CLI approval requests to their backend owner and logs approval failures while keeping cancellations quiet.

Example: A claude-cli turn calls native Agent with exec ask set to on-miss.

  • Before: The Gateway rejects the request because its signed approval owner is missing, so Agent is denied without prompting.
  • After: The Control UI presents an approval request, and Allow once permits the call while the turn remains active.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused repair with shipped-entry-point evidence, negative authority controls, successful exact-head gates, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Supplied isolated-Gateway and real Control UI results exercise native Agent and node-host Read through the changed registration path: allow-once executes, denial and timeout refuse, and stop, reset, or replacement reject late approval with no marker effect while the active-turn control writes its marker; the inspected screenshot directly confirms the native Agent prompt.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Operators cannot approve native Claude tools under ask policy because requests are rejected before a prompt appears.
Reason: This restores documented behavior through existing approval infrastructure without adding policy, configuration, persistence, or a competing owner.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current, documented approval workflow failure with a focused change; no actionable defects remain.

Priority: P1
Reviewed head: b89bbfbeec508f73f697f498fc408a936aad0e38

Before merge

None.

Findings

None.

Agent review details

How this fits together

The CLI runtime passes native tool requests through OpenClaw policy and Gateway approvals, then returns permission to Claude Code only after checking the admitted turn is still active.

flowchart TD
  A[Claude native tool request] --> B[CLI host policy]
  B --> C[Backend owner binding]
  C --> D[Gateway approval]
  D --> E[Operator decision]
  E --> F[Final active turn check]
  F --> G[Allow or deny native execution]
Loading

Technical review

Best possible solution:

Land the focused owner-binding repair while preserving existing policy, cancellation, and final execution checks.

Do we have a high-confidence way to reproduce the issue?

Yes: current-main registration omits the owner required by the Gateway, and the contributor records the same immediate denial through isolated Gateways; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch repairs registration at its existing owner using the established binding helper, leaves decision waiting outside that binding, and preserves downstream authority checks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against eb6988695915.

Provenance checked

  • Native approval registration keeps the original intent (a229456: Merged feat(agents): relay Claude native tool requests as Gateway approvals #112918 introduced human approval for restrictive native-tool policies; subsequent allowlist work deliberately retained that relay.)
  • Unavailable approval handling keeps the original intent (a229456: The original relay deliberately denied on Gateway failure or cancellation; the patch retains denial and adds diagnostics only when the request was not aborted.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +14, Tests +35. Total +49 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 35 21 +14
Tests 1 41 6 +35
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 76 27 +49

Review metrics

Metric Value Why it matters
Production versus test growth Production +35/-21; tests +41/-6 The net production increase supplies existing-owner binding and failure diagnostics; the test increase covers owner propagation and diagnostic behavior without new production machinery.

Labels

Label changes:

  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Label justifications:

  • P1: Native tools in interactive claude-cli ask-policy turns are denied before operators can approve them, breaking an established agent workflow.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-26T00:27:25.812Z sha b89bbfb :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-26T00:52:20.027Z sha b89bbfb :: needs maintainer review before merge. :: none
  • reviewed 2026-10-26T00:58:12.566Z sha b89bbfb :: needs maintainer review before merge. :: none

Reviewed October 26, 2026, 3:18 AM ET / 07:18 UTC (Revision 4).

@holgergruenhagen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 26, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@steipete
steipete merged commit 864625e into openclaw:main Oct 26, 2026
181 of 182 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…der exec ask (openclaw#183984)

Bind native Claude tool approval registration to the existing backend owner so exec ask on-miss/always can present an approval instead of failing before prompting. Preserve the host's final active-run check, deny/cancel/timeout behavior, and add diagnostics for unavailable approval routes.

Validation: ownership regression fails on base; all 41 focused tests pass. Exact-head CI 40248165098 is green. Contributor isolated Gateway/Control UI evidence covers allow, deny, timeout and cancellation; this maintenance pass retained that evidence without repeating the authenticated session.

Related: openclaw#138853 (separate gateway call chat.send approval routing).

Co-authored-by: Holger Gruenhagen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants