Skip to content

fix(errors): classify connection errors as retryable failover reason#15163

Closed
fagemx wants to merge 1 commit intoopenclaw:mainfrom
fagemx:fix/connection-error-classification
Closed

fix(errors): classify connection errors as retryable failover reason#15163
fagemx wants to merge 1 commit intoopenclaw:mainfrom
fagemx:fix/connection-error-classification

Conversation

@fagemx
Copy link
Copy Markdown
Contributor

@fagemx fagemx commented Feb 13, 2026

Summary

  • Add connection error patterns (ECONNREFUSED, ECONNRESET, socket hang up, fetch failed, APIConnectionError, etc.) to ERROR_PATTERNS
  • Wire isConnectionErrorMessage() into classifyFailoverReason() as "timeout" (retryable), so the failover mechanism can retry on a different provider
  • Return a friendly user-facing message instead of leaking raw error text to channels

Test plan

  • New isConnectionErrorMessage test suite (3 tests: SDK message, common patterns, negative cases)
  • New formatAssistantErrorText tests for connection error messages (2 tests)
  • All 269 existing tests pass
  • pnpm build && pnpm check clean

Fixes #15083

lobster-biscuit

🤖 Generated with Claude Code

Greptile Overview

Greptile Summary

This change adds a new connection bucket to the agent error pattern matcher, exposes it via isConnectionErrorMessage(), and uses it in two places:

  • formatAssistantErrorText() now rewrites connection-related failures (e.g., ECONNREFUSED, ECONNRESET, socket hang up, fetch failed, APIConnectionError) into a stable, user-friendly message.
  • classifyFailoverReason() treats those connection errors as retryable transport failures by mapping them to the existing "timeout" failover reason.

New Vitest suites cover both the message classifier and the formatting behavior.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • Changes are localized to error classification/formatting, are covered by new unit tests, and preserve existing failover reason types by mapping connection errors to the already-supported "timeout" category.
  • No files require special attention

Last reviewed commit: 932a781

(4/5) You can add custom instructions or style guidelines for the agent here!

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: S labels Feb 13, 2026
@fagemx fagemx force-pushed the fix/connection-error-classification branch from 360692f to 932a781 Compare February 13, 2026 03:52
@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added stale Marked as stale due to inactivity and removed stale Marked as stale due to inactivity labels Feb 21, 2026
@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Mar 12, 2026
Transient APIConnectionError from the Anthropic SDK (and similar network
failures) was not matched by any error pattern, so it leaked raw error
text to user channels instead of being classified and retried.

Add connection error patterns (ECONNREFUSED, ECONNRESET, socket hang up,
fetch failed, etc.), wire into classifyFailoverReason as "timeout"
(retryable), and return a friendly user-facing message.

Fixes openclaw#15083

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@fagemx
Copy link
Copy Markdown
Contributor Author

fagemx commented Mar 12, 2026

Superseded by #43710 (rebased onto latest main with conflict resolution).

@fagemx fagemx closed this Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transient APIConnectionError surfaced to user channel instead of being handled silently

1 participant