Skip to content

[Bug]: Exec approval flow is fire-and-forget - tool returns immediately without waiting for user approval #2402

@BjoernSchotte

Description

@BjoernSchotte

(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

  1. Configure exec with ask: "on-miss" and security: "allowlist" in clawdbot.json
  2. Configure approval forwarding to Discord DM with approvals.exec.enabled: true and mode: "targets" pointing to user:<USER_ID>
  3. Start the gateway with clawdbot gateway start
  4. Send a Discord message that triggers the agent to run a command NOT in safeBins (e.g., touch /tmp/test)
  5. Agent shows "Exec approval required" with ID and "Expires in: 120s"
  6. Approve within 10-20 seconds using /approve <id> allow-once
  7. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions