Repository navigation
Description
What happened?
When the Claude CLI live-session backend (src/agents/cli-runner/claude-live-session.ts, bundled as dist/claude-live-session-*.js) is used as the claude-cli provider, the bridge does not respond to Claude CLI control_request messages of subtype can_use_tool. Claude CLI emits these control_request events when it wants to use one of its native tools (e.g. native Bash, Read, Edit) and is waiting for a permission decision. Because OpenClaw's bridge silently ignores them, the CLI sits forever waiting for a control_response, and the live session eventually times out:
queued_work_without_active_run
classification=stale_session_state
recovery skipped: active_reply_work
... CLI produced no output for {180,600}s and was terminated.
From the user's perspective, the model answered the first turn, then made one tool call, and the session simply stopped — no error in the UI until the timeout fires.
What did you expect to happen?
The bridge should consume type: "control_request" messages from Claude CLI's stream-json output and write a matching type: "control_response" to stdin so Claude CLI can either run the native tool or fail fast with a meaningful error.
It should also map decisions to OpenClaw's effective exec policy for the agent:
- If the resolved exec policy is
security: full, ask: off, allow nativeBash(matches the existing--dangerously-skip-permissionssemantics OpenClaw uses elsewhere when the policy is fully permissive). - Otherwise, deny native
Bashcleanly with a message that points the agent at OpenClaw MCP tools instead. - For non-
Bashnative tools (Read,Edit,Write, etc.), deny with a message that says "use OpenClaw MCP tools instead", since OpenClaw's policy/audit pipeline expects the MCP path.
Reproduction steps
- Configure a Claude CLI backend in
agents.defaults.cliBackends.claude-cliso it runs the bundled binary with stream-json (-p,--output-format stream-json,--input-format stream-json,--verbose,--setting-sources user,--allowedTools mcp__openclaw__*,--permission-mode default). - Pick any agent and switch its model to
claude-cli/claude-opus-4-6(or4-7) in the OpenClaw Control UI. - In a fresh dashboard session, ask the model to do something that triggers a Claude native tool — e.g., "tail the last 50 lines of /var/log/syslog" (Claude will try native
Bash). - Observe: the model runs one tool call, then nothing further. After 180s (or 600s for resumed turns) you'll see the stuck-detector + termination log lines above. Earlier turns may succeed if they happened to use only OpenClaw MCP tools.
Reproduces on
openclaw 2026.5.3-1(Docker container, Linux 6.12.24-Unraid x64, node v24.14.0)dist/claude-live-session-D20mQ3LE.js(bundle hash visible in install) — source:src/agents/cli-runner/claude-live-session.ts- Claude Agent SDK CLI bundled at
/app/node_modules/@anthropic-ai/claude-agent-sdk-linux-x64/claude - Claude models:
claude-opus-4-6,claude-opus-4-7
Workaround / patch we are running locally
We patched the live bundle to:
- Resolve and persist a
controlRequestPolicyper session derived from agent-leveltools.exec(falling back to globaltools.exec), with{ allowNativeBash, ask, security }. - On stream-json
parsed.type === "control_request":- For
subtype: "can_use_tool":- If
tool_name === "Bash"andcontrolRequestPolicy.allowNativeBash, write acontrol_responseof{ behavior: "allow", updatedInput }. - Otherwise write
{ behavior: "deny", message, decisionClassification: "user_reject" }with a message that explains the policy and points at OpenClaw MCP tools.
- If
- For other subtypes, write a
control_responseerror explaining the bridge does not yet support that subtype.
- For
- Silently ignore
parsed.type === "control_response"(we never originate requests).
The patch wires the resolved policy through params.controlRequestPolicy in the helpers that hash params/build sessions, so the policy is captured at session-start time rather than recomputed mid-stream.
A diff of the patched bundled JS (against the unpatched bundle in the same install) is small (~80 lines, mostly the new helpers and the dispatch lines).
Suggested upstream fix
A real source-tree fix in src/agents/cli-runner/claude-live-session.ts that:
- Resolves an effective exec policy per session/agent at start time and threads it into the session record.
- Adds a
control_requesthandler that mapscan_use_tooldecisions through that policy and emitscontrol_responseto stdin. - Logs the decision (tool name, decision, policy), and treats unsupported subtypes as a structured error response rather than a no-op.
Without this, any Claude CLI-backed session that triggers a native tool prompt will appear to hang and only fail at the global no-output timeout, which is a confusing UX for OpenClaw operators.
Anything else?
Happy to open a draft PR against src/agents/cli-runner/claude-live-session.ts mirroring the local patch — let me know if maintainers prefer that, and whether there's a preferred shape for the policy-resolution helper (some helpers.ts patterns exist in the same directory).
Reported for openclaw 2026.5.3-1.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon May 12, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.
Summary
Keep open: current main still starts Claude live sessions in stdio permission-prompt mode but has no
control_requesthandling orcontrol_responsewrite path, so the reported stall remains source-proven on main and on the latest shipped tag.Reproducibility: yes. source-level reproduction is high confidence: a Claude stream-json
control_requestreacheshandleClaudeLiveLine, is appended to the turn, and then returns because it is not aresult. I did not run a live Claude CLI session because this checkout does not include the Claude binary or auth material.Next step
The root cause and likely files are clear, but the fix changes native Claude tool permission decisions around Bash and file tools, so it should get maintainer policy confirmation before a repair PR is queued.
Review details
Best possible solution:
Add focused Claude live-session handling that writes tested
control_responseframes forcan_use_tool, denies native tools by default with MCP guidance, and only allows native Bash when the resolved OpenClaw exec policy is fully permissive.Do we have a high-confidence way to reproduce the issue?
Yes, source-level reproduction is high confidence: a Claude stream-json
control_requestreacheshandleClaudeLiveLine, is appended to the turn, and then returns because it is not aresult. I did not run a live Claude CLI session because this checkout does not include the Claude binary or auth material.Is this the best way to solve the issue?
Mostly yes: handling
can_use_toolinsidesrc/agents/cli-runner/claude-live-session.tsis the narrow fix. A maintainer should confirm the native Bash allow/deny boundary before implementation because this touches Claude's native permission surface.What I checked:
buildClaudeLiveArgsforces--input-format stream-json,--output-format stream-json, and--permission-prompt-tool stdiofor Claude live sessions, making the bridge responsible for responding to permission prompts. (src/agents/cli-runner/claude-live-session.ts:174, 3abb2ee78108)handleClaudeLiveLineparses and stores each JSONL record, then returns for everyparsed.type !== "result"; there is no special case forcontrol_requestorcan_use_tool. (src/agents/cli-runner/claude-live-session.ts:522, 3abb2ee78108)control_request,control_response, orcan_use_toolimplementation in the relevant source, tests, docs, or Anthropic plugin paths. (src/agents/cli-runner/claude-live-session.ts:673, 3abb2ee78108)tools.exec.security: full,tools.exec.ask: off) to Claude--permission-mode bypassPermissions, with per-agent exec policy overriding global exec policy. Public docs:docs/gateway/cli-backends.md. (docs/gateway/cli-backends.md:181, 3abb2ee78108)src/agents/cli-runner/claude-live-session.ts:563, eeef4864494f)canUseTool, pause execution until a response returns, and accept allow/deny responses shaped as{ behavior: "allow", updatedInput }or{ behavior: "deny", message }. (code.claude.com)Likely related people:
src/agents/cli-runner/claude-live-session.ts,extensions/anthropic/cli-shared.ts,docs/gateway/cli-backends.md)Remaining risk / open question:
control_requestframe fields against the installed Claude Code version while adding tests, because the public docs cover the callback semantics more directly than the low-level wire shape.Codex review notes: model gpt-5.5, reasoning high; reviewed against 3abb2ee78108.
fix(agents): answer Claude live control_request can_use_tool via exec…
fix(agents): align Claude live control_request policy with backend de…
fix(agents): honor effective exec policy for Claude live Bash (#86330)
fix(agents): honor effective exec policy for Claude live Bash (opencl…
fix(agents): honor effective exec policy for Claude live Bash (opencl…
fix(agents): honor effective exec policy for Claude live Bash (opencl…