Skip to content

[Bug]: Exec tool error output (non-zero exit code) sent as message to active WhatsApp/Telegram channel #9651

@Valinainformatica

Description

@Valinainformatica

Description

When the agent executes a command via the exec tool that returns a non-zero exit code, the error output is sent as a visible message to the active WhatsApp/Telegram channel (i.e., to the client the agent is currently chatting with).

This is a serious issue for production deployments where the agent handles customer-facing messaging.

Steps to Reproduce

  1. Agent is processing a WhatsApp message from a client
  2. Agent runs a command that fails, e.g.: find ~/workspace/clients/ -type f | xargs grep -l "123456789" (grep returns exit code 1 when no match found)
  3. The error output (Command exited with code 1) is sent as a WhatsApp message to the client

Real Examples

  • find ~/clawd/clientes/ -type f | xargs grep -l "675604689" 2>/dev/null failed: Command exited with code 1 → sent to client via WhatsApp
  • Read: ~/clawd/memory/clientes/684208483.md failed: ENOENT: no such file or directory → sent to client via WhatsApp
  • Cross-context messaging denied... → sent to client as audio message via WhatsApp

Expected Behavior

Exec tool errors should NEVER be forwarded to the active messaging channel. They should be:

  1. Returned to the agent context only (so the agent can handle it gracefully)
  2. Optionally logged to a debug/admin channel
  3. Never visible to the end user/client

Current Workaround

We instruct the agent via system prompt to always append 2>/dev/null || true to every command. This works most of the time, but is not 100% reliable since it depends on the LLM following the instruction consistently.

Related Issues

Environment

  • OpenClaw version: 2026.2.3-1
  • Channels: WhatsApp + Telegram
  • Runtime: direct (no sandbox)
  • Model: Claude Opus
  • OS: macOS

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