Skip to content

fix(claude-cli): also disable native background Bash and Monitor in --print runs - #95008

Merged
obviyus merged 2 commits into
openclaw:mainfrom
anagnorisis2peripeteia:fix/claude-cli-no-native-background
Jun 22, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
anagnorisis2peripeteia:fix/claude-cli-no-native-background

Conversation

@anagnorisis2peripeteia

@anagnorisis2peripeteia anagnorisis2peripeteia commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

What

Extend the claude-cli backend's existing --disallowedTools list to also deny the two native background tools, in both fresh args and resumeArgs:

"ScheduleWakeup,CronCreate"  ->  "ScheduleWakeup,CronCreate,Bash(run_in_background:true),Monitor"

This follows the exact pattern established in #84434 (which disabled ScheduleWakeup/CronCreate in --print Claude runs) — same flag, same rationale, two more tools.

Why

Bash(run_in_background:true) and Monitor promise the model a completion callback ("I'll re-wake you when the background process exits / when output changes"). The claude-cli backend has no mechanism to re-wake the agent on that signal, so the model strands deferred work in a process it will never hear back from — the same failure mode #84434 fixed for the native scheduler tools. Deferred / long-running work should route through OpenClaw cron wake (#83738 merged, #92037 open), which the backend can deliver.

Scope boundary

  • claude-cli backend only; no other backend touched.
  • Denial is scoped to the run_in_background:true variant of Bash (foreground Bash is untouched) and to the Monitor tool specifically. No general Bash restriction.
  • Two values changed (fresh + resume args); nothing else in cli-backend.ts changes.

Proof

Local behavioral proof on real Claude CLI 2.1.183, using the exact shipped deny value. Recording deliberately omitted — this is a backend-argv default with no transport-visible surface (telegram-visible proof not applicable).

Invoked claude -p ... --disallowedTools "ScheduleWakeup,CronCreate,Bash(run_in_background:true),Monitor":

  • Background Bash denied — tool_result is_error:true: "Permission to use Bash with run_in_background:true has been denied." (denial events present in the run).
  • Monitor absent from the init tools list.
  • ScheduleWakeup / CronCreate also absent (the pre-existing denials still hold).
  • Foreground Bash in the same run succeeds (fg-ok) — only the background variant is denied, not Bash generally.

Contrast (no deny flags, same CLI): background Bash launches and Monitor is present — isolating the flag as the cause. A focused regression test asserts both args and resumeArgs carry the two new deny rules.

Risk / mitigation

Not tested

  • End-to-end through a live OpenClaw-spawned session (effect proven via a faithful claude -p invocation with the exact shipped value; the backend wiring is a static arg-array change verified by the unit test).
  • Backends other than claude-cli (intentionally out of scope).

Test command

$ node scripts/test-projects.mjs extensions/anthropic/cli-shared.test.ts
 Test Files  1 passed (1)
      Tests  21 passed (21)

The added it("disables native background Bash and Monitor tools in args and resumeArgs") asserts both args and resumeArgs carry the two new deny rules.

OpenClaw-spawned proof (per ClawSweeper review)

Built this branch (532635e) and ran a real embedded OpenClaw turn (openclaw agent --local --model claude-cli/claude-sonnet-4-6).

1. The OpenClaw-spawned claude argv carries the deny value — captured from /proc/<pid>/cmdline of the gateway-spawned process:

claude -p --include-partial-messages --verbose --setting-sources user \
  --allowedTools mcp__openclaw__* \
  --disallowedTools ScheduleWakeup,CronCreate,Bash(run_in_background:true),Monitor \
  --strict-mcp-config --mcp-config <redacted> --plugin-dir <redacted> --effort low \
  --model claude-sonnet-4-6 --append-system-prompt-file <redacted> \
  --input-format stream-json --output-format stream-json \
  --permission-prompt-tool stdio --replay-user-messages --permission-mode bypassPermissions

2. That exact flag combination denies background Bash and hides Monitor — raw claude stream-json (same --allowedTools mcp__openclaw__* --disallowedTools … --permission-mode bypassPermissions, attempting a background bash):

"name":"Bash" … "run_in_background":true
tool_result is_error:true: "Permission to use Bash with run_in_background:true has been denied."
result.permission_denials:[{"tool_name":"Bash", … "run_in_background":true, "command":"echo hi"}]

Monitor is absent from the session's init tool list; foreground Bash is unaffected.

On self-report vs ground truth: driven through the OpenClaw agent turn, the model's prose claimed the background task "completed … I received a completion notification." That is confabulation — the tool-layer denial above is ground truth, and the phantom "completion notification" is precisely the misleading affordance this PR removes. (OpenClaw's agent CLI surfaces only final assistant text, not raw tool events, so the raw claude stream-json is shown here.)

@anagnorisis2peripeteia
anagnorisis2peripeteia requested a review from a team as a code owner June 19, 2026 15:40
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser app: android App: android app: ios App: ios app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime extensions: copilot-proxy Extension: copilot-proxy extensions: diagnostics-otel Extension: diagnostics-otel extensions: llm-task Extension: llm-task extensions: lobster Extension: lobster extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb labels Jun 19, 2026
@github-actions

github-actions Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Dependency graph guard cleared

This PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh /allow-dependencies-change comment after the guard blocks that new head SHA.

  • Current SHA: 317b26efb5c629e3de7014b28780f2d1959fdffe

@clawsweeper

clawsweeper Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 20, 2026, 6:09 PM ET / 22:09 UTC.

Summary
The branch adds Bash(run_in_background:true),Monitor to the Anthropic claude-cli default --disallowedTools value for fresh and resumed runs and adds a focused argv regression test.

PR surface: Source 0, Tests +11. Total +11 across 2 files.

Reproducibility: yes. Source inspection shows current main omits the new deny entries in the exact argv arrays consumed by the runner, and the PR body provides terminal/live-output proof that patched argv denies background Bash and hides Monitor.

Review metrics: 1 noteworthy metric.

  • Claude native tool denials: 2 added across 2 argv paths. Changing default native tool availability for both fresh and resumed Claude CLI runs is compatibility-sensitive before merge.

Root-cause cluster
Relationship: canonical
Canonical: #95008
Summary: This PR is the focused candidate for disabling unsupported native background Bash and Monitor in the bundled Claude CLI backend; related items are adjacent or prior partial work, not replacements for this exact change.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] Merging intentionally makes native background Bash and Monitor unavailable by default for OpenClaw-managed claude-cli runs, so existing prompts or workflows that relied on those Claude callbacks will receive denial instead of the previous behavior.
  • [P1] The broader on-exit cron replacement remains open, so maintainers should explicitly accept fail-closed native background tooling as the interim product behavior.

Maintainer options:

  1. Accept Fail-Closed Background Tools (recommended)
    Land if maintainers agree native background Bash and Monitor callbacks are unsupported in OpenClaw-managed claude-cli and explicit denial is better than stranded deferred work.
  2. Pause Until Replacement Is Clear
    Pause if Monitor should remain available until feat(cron): on-exit schedule — wake on a watched command's exit #92037 or another replacement path is merged and documented.
  3. Require An Opt-In Escape Hatch
    Ask for a maintainer-approved opt-in path if specialized deployments must retain these native Claude tools under OpenClaw spawning.

Next step before merge

  • The remaining action is maintainer acceptance of the default tool-availability tradeoff and normal merge gating; no automated repair is indicated.

Security
Cleared: No security or supply-chain concern found; the diff only changes static Claude CLI argv defaults plus a test and reduces native tool exposure.

Review details

Best possible solution:

Land the owner-plugin deny-list update if maintainers accept unsupported native background callbacks should fail closed; keep custom escape hatches or on-exit cron policy as separate work.

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

Yes. Source inspection shows current main omits the new deny entries in the exact argv arrays consumed by the runner, and the PR body provides terminal/live-output proof that patched argv denies background Bash and hides Monitor.

Is this the best way to solve the issue?

Yes for the bundled default path. The change belongs in the Anthropic provider-owned CLI backend and is narrower than core filtering, but merge readiness still depends on maintainer acceptance of the compatibility tradeoff.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f18ff7551edc.

Label changes

Label justifications:

  • P2: This is a bounded Claude CLI backend bug mitigation with limited but real agent workflow impact.
  • merge-risk: 🚨 compatibility: The PR changes default Claude CLI native tool availability and can break workflows that relied on background Bash or Monitor.
  • 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. Sufficient (terminal): The PR body includes terminal/live-output proof from a patched OpenClaw-spawned Claude process plus raw Claude stream-json showing the changed denial behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal/live-output proof from a patched OpenClaw-spawned Claude process plus raw Claude stream-json showing the changed denial behavior.
Evidence reviewed

PR surface:

Source 0, Tests +11. Total +11 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 2 0
Tests 1 11 0 +11
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 13 2 +11

What I checked:

Likely related people:

  • SkyWolfDreamer: Authored the merged prior PR that added ScheduleWakeup,CronCreate denial in the same claude-cli backend argv surface. (role: introduced adjacent behavior; confidence: high; commits: d1e1c86fa0a7, 8e56cf591daa; files: extensions/anthropic/cli-backend.ts)
  • vincentkoc: Merged the prior scheduler-deny PR and is tied to the release/current-history provenance for this backend surface. (role: merger and recent area carrier; confidence: high; commits: 8e56cf591daa; files: extensions/anthropic/cli-backend.ts)
  • anagnorisis2peripeteia: Authored the merged cron wake origin work and the open on-exit cron proposal that this PR cites as the supported replacement path for deferred work. (role: adjacent wake-path contributor; confidence: medium; commits: f1f00cbf1d58, 5515b232fdb9; files: src/cron/service/wake.ts, src/agents/tools/cron-tool.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@anagnorisis2peripeteia

Copy link
Copy Markdown
Contributor Author

Added OpenClaw-spawned proof to the PR description: the patched backend spawns claude with --disallowedTools …Bash(run_in_background:true),Monitor (captured from /proc), and that exact flag set denies background Bash + hides Monitor in raw claude stream-json (foreground Bash unaffected). Notably the agent's prose confabulated a 'completion notification' for the denied background task — the exact misleading affordance this removes.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

anagnorisis2peripeteia and others added 2 commits June 21, 2026 17:11
…-print runs

Extends the existing --disallowedTools list (ScheduleWakeup,CronCreate from openclaw#84434)
to also deny Bash(run_in_background:true) and Monitor on the claude-cli backend.
Those native tools promise a completion callback the CLI backend cannot deliver,
so the model strands deferred work; deferred work should use OpenClaw cron wake
(openclaw#83738, openclaw#92037). Adds a focused regression test on the backend args.
@obviyus

obviyus commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Landed via squash onto main.

  • Scoped tests: node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/land-95008-extensions-test.tsbuildinfo; node scripts/run-vitest.mjs extensions/anthropic/cli-shared.test.ts
  • Changelog: release-owned; not edited
  • Land commit: 317b26e
  • Merge commit: 298a0cd

Thanks @anagnorisis2peripeteia!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: anthropic merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants