Skip to content

Transient APIConnectionError surfaced to user channel instead of being handled silently #15083

@redrum137-glitch

Description

@redrum137-glitch

Summary

Transient network errors from the Anthropic SDK are being delivered to user channels (Discord) instead of being retried silently or logged internally. This results in "Connection error." spam in chat.

Steps to reproduce

  1. Run OpenClaw with Discord channel enabled
  2. Have intermittent network conditions or API hiccups
  3. Observe "Connection error." messages posted to Discord

Expected behavior

  • Transient connection errors should be retried N times silently
  • If retries fail, log internally (not to user channel)
  • Only surface to user if the error is persistent/critical

Actual behavior

  • Every transient APIConnectionError from the Anthropic SDK is immediately posted to the Discord channel
  • Multiple "Connection error." messages appear in chat
  • Affects all bot accounts in multi-account setups

Environment

  • OpenClaw version: 2026.2.9
  • OS: Windows 10 (22621)
  • Install method: npm global

Logs or screenshots

The error path appears to be:

  • APIConnectionError thrown by @anthropic-ai/sdk
  • Error goes through formatErrorMessage() which extracts err.message
  • Message gets delivered to the user channel via the standard reply path

Suggested Fix

  1. Wrap API calls with retry logic for transient connection errors
  2. Classify APIConnectionError / socket errors as retriable
  3. Only surface to user after all retries exhausted
  4. Consider logging these internally rather than posting to chat

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked as stale due to inactivity

    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