fix(failover): recognize 'abort' stop reason as timeout for model fallback

When streaming providers (GLM, OpenRouter, etc.) return 'stop reason: abort'
due to stream interruption, OpenClaw's failover mechanism did not recognize
this as a timeout condition. This prevented fallback models from being
triggered, leaving users with failed requests instead of graceful failover.

Changes:
- Add abort patterns to ERROR_PATTERNS.timeout in pi-embedded-helpers/errors.ts
- Extend TIMEOUT_HINT_RE regex to include abort patterns in failover-error.ts

Fixes #18453

Co-authored-by: James <james@openclaw.ai>
This commit is contained in:
Daniel Sauer
2026-02-16 23:32:45 +01:00
committed by Peter Steinberger
parent 32c66aff49
commit 12ce358da5
2 changed files with 5 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
import { classifyFailoverReason, type FailoverReason } from "./pi-embedded-helpers.js";
const TIMEOUT_HINT_RE = /timeout|timed out|deadline exceeded|context deadline exceeded/i;
const TIMEOUT_HINT_RE =
/timeout|timed out|deadline exceeded|context deadline exceeded|stop reason:\s*abort|unhandled stop reason:\s*abort/i;
const ABORT_TIMEOUT_RE = /request was aborted|request aborted/i;
export class FailoverError extends Error {

View File

@@ -599,6 +599,9 @@ const ERROR_PATTERNS = {
"deadline exceeded",
"context deadline exceeded",
/without sending (?:any )?chunks?/i,
/\bstop reason:\s*abort\b/i,
/\breason:\s*abort\b/i,
/\bunhandled stop reason:\s*abort\b/i,
],
billing: [
/["']?(?:status|code)["']?\s*[:=]\s*402\b|\bhttp\s*402\b|\berror(?:\s+code)?\s*[:=]?\s*402\b|\b(?:got|returned|received)\s+(?:a\s+)?402\b|^\s*402\s+payment/i,