The Tool Execution Error
While tailing the OpenClaw gateway logs, you notice this:
2026-02-26T00:10:35.329+00:00 [tools] exec failed:
sh: 1: jest: Permission denied
Command not foundThe agent tried to run jest â a JavaScript test runner â and the containerâs shell denied the execution. This isnât a bug; itâs the sandbox doing its job. But understanding why it happened and how to control tool access is essential for production deployments.
How Agent Tool Execution Works
When OpenClawâs AI agent decides it needs to run a shell command, the execution flow is:
- Agent decides â The LLM (e.g.,
github-copilot/claude-opus-4.6) generates a tool call requesting command execution - Gateway intercepts â The gateway evaluates the tool call against the approval policy
- Sandbox executes â If approved, the command runs inside the agentâs sandbox environment
- Result returns â stdout/stderr are captured and returned to the agent
The [tools] exec failed log message means step 3 failed â the command was approved but couldnât actually execute.
Why âPermission Deniedâ Happens
1. Binary Not Installed
The most common cause: the tool simply doesnât exist in the container. OpenClawâs Docker image is a minimal Node.js environment â it doesnât ship with development tools like jest, pytest, gcc, or most CLI utilities:
# Check what's available inside the container
docker exec -it openclaw-openclaw-gateway-1 sh -c 'which jest || echo "not found"'
# Output: not found2. PATH Restrictions
Even if a binary exists, the sandbox may run with a restricted $PATH that excludes it:
# Check the sandbox PATH
docker exec -it openclaw-openclaw-gateway-1 sh -c 'echo $PATH'3. File Permission Bits
If youâve installed tools manually inside the container, they may lack execute permissions:
# Check permissions on a binary
docker exec -it openclaw-openclaw-gateway-1 sh -c 'ls -la /usr/local/bin/jest 2>/dev/null'4. Sandbox Isolation
OpenClaw can run agent commands in an isolated sandbox container. If sandbox mode is enabled, the tool execution happens in a separate, even more restricted environment:
# Check sandbox configuration
docker compose run --rm openclaw-cli config get agents.defaults.sandboxThe Exec Approval System
Before a command even reaches the sandbox, OpenClawâs approval system gates it. Check the current approval policy:
docker compose run --rm openclaw-cli approvals --helpApprovals can be configured to:
| Mode | Behavior |
|---|---|
auto | All commands execute without user confirmation |
prompt | Each command requires interactive approval |
allowlist | Only pre-approved commands run |
deny | All tool execution is blocked |
The âPermission deniedâ error in the logs means the command passed the approval gate but failed at the OS level.
Fixing Tool Execution Errors
Option 1: Install the Missing Tool
If the agent legitimately needs jest (or any other tool), install it inside the container:
# Install globally inside the running container
docker exec -it openclaw-openclaw-gateway-1 sh -c 'npm install -g jest'Warning: This change is ephemeral â itâs lost on container restart. For persistence, create a custom Dockerfile.
Option 2: Custom Dockerfile
Create a Dockerfile.custom that extends the OpenClaw image with your tools:
FROM openclaw:local
# Install development tools the agent might need
RUN npm install -g jest typescript ts-node eslint prettier
# Install system utilities
USER root
RUN apk add --no-cache python3 py3-pip git curl jq sqlite
USER nodeUpdate your docker-compose.yml:
services:
openclaw-gateway:
build:
context: .
dockerfile: Dockerfile.custom
# ... rest of configThen rebuild:
docker compose build openclaw-gateway
docker compose up -d openclaw-gatewayOption 3: Mount Host Tools
Map host directories into the container so the agent can use tools installed on the VM:
services:
openclaw-gateway:
volumes:
- /home/azureuser/.openclaw:/home/node/.openclaw
- /usr/local/bin/jq:/usr/local/bin/jq:ro # Read-only mountOption 4: Use Sandbox Containers
OpenClaw supports running agent commands in dedicated sandbox containers that come pre-loaded with tools:
# Configure sandbox
docker compose run --rm openclaw-cli config set agents.defaults.sandbox.enabled true
docker compose run --rm openclaw-cli config set agents.defaults.sandbox.image "node:20-alpine"The sandbox container can be a standard node:20 image with all development tooling pre-installed, while the gateway container remains slim.
Understanding the Error Message
Letâs decode the full error:
2026-02-26T00:10:35.329+00:00 [tools] exec failed:
sh: 1: jest: Permission denied| Part | Meaning |
|---|---|
[tools] | The gatewayâs tool execution subsystem |
exec failed | The shell command returned a non-zero exit |
sh: 1: | POSIX shell, line 1 of the command |
jest | The binary the agent tried to run |
Permission denied | OS-level denial (missing binary or no execute bit) |
The separate line Command not found is OpenClawâs own interpretation â it recognizes the pattern and provides a cleaner message.
Auditing Agent Tool Usage
Watch what tools the agent tries to use:
# Filter logs for all tool execution events
docker logs --tail=500 openclaw-openclaw-gateway-1 | \
grep -E "\[tools\]" | tail -20The command-logger hook (automatically registered on startup) records every command the agent executes:
[hooks:loader] Registered hook: command-logger -> commandThis means every tool call is logged. You can review the log to understand what tools the agent needs most and configure your environment accordingly.
Security Considerations
Donât Install Everything
Itâs tempting to install every possible tool the agent might need. Resist this urge â each binary you add to the container increases the attack surface.
Use Read-Only Mounts
When mounting host tools into the container, always use :ro to prevent the agent from modifying them:
volumes:
- /host/path/tool:/container/path/tool:roThe Approvals Layer
Configure the approval system to allowlist specific commands:
# Enable approval prompts for dangerous commands
docker compose run --rm openclaw-cli config set agents.defaults.approvals.mode allowlistMonitor Tool Calls
Set up a log watcher for tool execution failures to catch unexpected agent behavior:
#!/bin/bash
# monitor-tool-errors.sh
ERRORS=$(docker logs --tail=100 openclaw-openclaw-gateway-1 2>&1 | \
grep -c "\[tools\] exec failed")
if [ "$ERRORS" -gt 5 ]; then
echo "ALERT: $ERRORS tool execution failures in recent logs"
fiCommon Tool Errors Reference
| Error Message | Cause | Fix |
|---|---|---|
Permission denied | Binary missing or not executable | Install tool or fix perms |
Command not found | Not in PATH | Install or add to PATH |
Operation not permitted | Sandbox/seccomp restriction | Check sandbox config |
No such file or directory | Wrong path or missing dependency | Install package |
exec format error | Architecture mismatch (ARM vs x86) | Use correct image |
Series Navigation
Previous: Fixing OpenClaw Gateway Token Mismatch WebSocket Errors Next: Exploring OpenClaw Browser Control and Canvas Features
Part 27 of the OpenClaw on Azure series. The sandbox is your friend â it keeps the agent from running rm -rf / while you sleep.

