← Back to PRs

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

by fagemx open 2026-02-13 03:50 View on GitHub →
agents stale size: S
## 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 - [x] New `isConnectionErrorMessage` test suite (3 tests: SDK message, common patterns, negative cases) - [x] New `formatAssistantErrorText` tests for connection error messages (2 tests) - [x] All 269 existing tests pass - [x] `pnpm build && pnpm check` clean Fixes #15083 lobster-biscuit > 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> 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. <h3>Confidence Score: 5/5</h3> - 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 <sub>Last reviewed commit: 932a781</sub> <!-- greptile_other_comments_section --> <sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs