Skip to content

Feature: Graceful error handling for LLM failures — never expose raw errors to users #39612

Description

@66DSurg

Problem

When an LLM request fails (e.g., Anthropic API rejects due to corrupted thinking blocks in session history), the raw error message is sent directly to the user via the messaging channel (WhatsApp, Telegram, etc.) as an auto-reply.

Example: After an OpenClaw update from 2026.2.17 → 2026.3.7, a session with thinking blocks became corrupted. Every subsequent message to the KIMS agent returned:

LLM request rejected: messages.5.content.12: thinking or redacted_thinking blocks in the latest assistant message cannot be modified.

This was sent verbatim to the user on WhatsApp, who had no idea what it meant.

Expected Behavior

  1. Never send raw LLM/API errors as replies to users. The error should be caught internally.
  2. Graceful fallback: On LLM failure, the agent should either:
    • Retry once silently
    • Send a user-friendly message ("I'm having a technical issue, please try again shortly")
    • Go silent (NO_REPLY) rather than forward the error
  3. Auto-escalation (multi-agent setups): If an agent fails 2+ times consecutively, automatically notify the main/default agent so it can investigate and inform the user.
  4. Session corruption detection: After updates, detect and flag sessions with incompatible thinking blocks before they cause repeated failures.

Current Workaround

Added ../shared/error-escalation.md protocol to all persona AGENTS.md files instructing agents to catch errors and escalate. But this only works if the agent can actually process the instruction — in the case above, the LLM call never succeeds, so the agent-level instructions are never read.

This needs to be handled at the framework level, before the LLM response reaches the messaging channel.

Environment

  • OpenClaw 2026.3.7
  • Multi-agent setup (9 personas)
  • WhatsApp + Telegram channels
  • Anthropic Claude as primary model

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions