-
-
Notifications
You must be signed in to change notification settings - Fork 69.3k
[Bug]: Exec approval flow is fire-and-forget - tool returns immediately without waiting for user approval #2402
Description
(clawdbot/pi told me this, Junior Claude verified it, can not approve tool calls in discord with /approve bc timeout is too fast. async vs sync)
Summary
Exec tool with ask: "on-miss" returns immediately (~16ms) without waiting for approval. The approval flow in src/agents/bash-tools.exec.ts is wrapped in void (async () => {...}) (fire-and-forget) at
lines 1016 and 1197, causing the tool to complete while approval happens asynchronously in the background. By the time the user approves, the approval ID is orphaned and returns "unknown approval id".
Steps to reproduce
- Configure exec with
ask: "on-miss"andsecurity: "allowlist"inclawdbot.json - Configure approval forwarding to Discord DM with
approvals.exec.enabled: trueandmode: "targets"pointing touser:<USER_ID> - Start the gateway with
clawdbot gateway start - Send a Discord message that triggers the agent to run a command NOT in
safeBins(e.g.,touch /tmp/test) - Agent shows "Exec approval required" with ID and "Expires in: 120s"
- Approve within 10-20 seconds using
/approve <id> allow-once - Observe "unknown approval id" error
Expected behavior
The exec tool should block and wait for approval. After user approves, the command should execute and the agent should receive the output.
Actual behavior
The exec tool returns immediately (~16ms) without waiting. The agent run completes before the user can approve. The /approve command returns "unknown approval id" because the approval is orphaned. The
background approval request eventually times out after 120s.
Environment
- Clawdbot version: 2026.1.24-3
- OS: Linux 6.8.0-90-generic (Ubuntu)
- Install method: npm global
Logs or screenshots
17:27:13.399Z info exec elevated command touch /tmp/approval-test-$(date +%s)
17:27:13.411Z debug embedded run tool start: tool=exec
17:27:13.427Z debug embedded run tool end: tool=exec ← 16ms, didn't wait!
17:27:18.337Z debug session state: prev=processing new=idle ← agent run completed
17:27:30.608Z info exec.approval.resolve errorMessage=unknown approval id ← user approved
17:29:13.444Z info exec.approval.request 120001ms ← orphaned approval timed out
Root cause: void (async () => { at bash-tools.exec.ts:1016 (node) and :1197 (gateway) makes approval non-blocking.
Note: Discord async listener fix #1295 is in place (v2026.1.20+). This is a separate issue in the approval flow itself.