Skip to content

Add outbound message hook (message:sent) OR error suppression for provider overload/rate_limit #14210

@AlekseyRodkin

Description

@AlekseyRodkin

Problem Statement

When LLM providers (Anthropic, OpenAI, etc.) return overloaded_error or rate limit responses, OpenClaw sends a user-facing message:

The AI service is temporarily overloaded. Please try again in a moment.

Issues:

  1. Users receive "spam" error messages in Telegram/WhatsApp during high-load periods
  2. No way to suppress these via configuration
  3. No hook to intercept outbound messages before delivery
  4. Operators cannot log suppressed events for monitoring

Current State

Per Hooks documentation, the following events exist:

  • command:new, command:reset, command:stop
  • agent:bootstrap, gateway:startup, tool_result_persist

Planned but not implemented:

  • message:sent — When a message is sent
  • message:received — When a message is received

Proposed Solutions

Option A: Implement message:sent hook (preferred)

Allow hooks to intercept outbound messages before delivery:

const handler: HookHandler = async (event) => {
  if (event.type !== 'message' || event.action !== 'sent') return;
  if (event.context.text.includes('temporarily overloaded')) {
    event.suppress = true;
  }
};

Option B: Config-based error suppression

{
  "messages": {
    "errorSuppression": {
      "overloaded": true,
      "rateLimit": true
    }
  }
}

Option C: Minimal — messages.suppressSystemErrors: true

Use Case

Production cron jobs run every 15 minutes. During Anthropic API overload, each failed cron sends error to Telegram — user receives 10+ "temporarily overloaded" messages per hour.

Expected behavior:

  • Error logged locally
  • Telegram receives nothing (or optional retry)

Acceptance Criteria

  1. Ability to filter outbound messages by pattern
  2. Suppressed messages logged to configurable path
  3. Works for all channels (Telegram, WhatsApp, Discord)

Environment

  • OpenClaw: 2026.2.3-1
  • Channel: Telegram
  • Provider: Anthropic

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    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