Skip to content

failover: classify AbortError / stream-abort messages as timeout (#58315)#58324

Merged
altaywtf merged 3 commits into
openclaw:mainfrom
yelog:fix/58315-abort-error-timeout-classification
Apr 1, 2026
Merged

failover: classify AbortError / stream-abort messages as timeout (#58315)#58324
altaywtf merged 3 commits into
openclaw:mainfrom
yelog:fix/58315-abort-error-timeout-classification

Conversation

@yelog

@yelog yelog commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix Ollama NDJSON stream abort errors producing reason=unknown in model fallback logs instead of reason=timeout
  • When a stream is aborted mid-read (timeout/signal), the fetch reader rejects with an AbortError whose message ("The operation was aborted", "stream closed", etc.) did not match any existing timeout pattern

Changes

  • Added two new regex patterns to the timeout error patterns in failover-matches.ts:
    • /\boperation was aborted\b/i — matches Node.js/undici AbortError messages
    • /\bstream (?:was )?(?:closed|aborted)\b/i — matches stream abort/close messages
  • Added test cases covering all common AbortError message variants

This is a pattern-level fix that benefits all providers (not just Ollama) where a stream abort produces a flattened error message that passes through classifyFailoverReason.

Closes #58315

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Mar 31, 2026
@greptile-apps

greptile-apps Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds two regex patterns to the timeout error-pattern list in failover-matches.ts so that AbortError / stream-abort messages (e.g., "The operation was aborted", "stream closed") are correctly classified as reason=timeout instead of falling through to reason=unknown during model failover. Test coverage is added for all common message variants.

  • /\boperation was aborted\b/i — maps Node.js/undici AbortError messages to timeout
  • /\bstream (?:was )?(?:closed|aborted)\b/i — maps stream abort/close messages to timeout
  • Both patterns use \b word boundaries to avoid partial-word false matches (e.g., "downstream closed" will not match)
  • classifyFailoverReason calls isTimeoutErrorMessage late in its priority chain (after billing/auth/server-error checks), so higher-priority classifiers are unaffected
  • Tests use expectTimeoutFailoverSamples, which validates isTimeoutErrorMessage, classifyFailoverReason, and isFailoverErrorMessage — thorough for the scope of the change

Confidence Score: 5/5

Safe to merge — minimal, targeted change with no logic regressions or false-positive risk from the new patterns.

Both new regex patterns are well-bounded by \b word anchors, follow the established convention in the file, and are exercised by comprehensive new test cases. The priority ordering in classifyFailoverReason ensures higher-specificity classifiers (billing, auth, server errors) still take precedence. No P0 or P1 findings were identified.

No files require special attention.

Important Files Changed

Filename Overview
src/agents/pi-embedded-helpers/failover-matches.ts Two new timeout regex patterns added with proper word-boundary anchors; follows existing conventions and does not affect higher-priority classifiers.
src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts New test block covers all AbortError/stream-abort message variants using the established expectTimeoutFailoverSamples helper.

Reviews (1): Last reviewed commit: "failover: classify AbortError and stream..." | Re-trigger Greptile

@yelog
yelog force-pushed the fix/58315-abort-error-timeout-classification branch 3 times, most recently from b370253 to 847f1a3 Compare April 1, 2026 08:47
@SonicBotMan

This comment was marked as spam.

@yelog
yelog force-pushed the fix/58315-abort-error-timeout-classification branch from 847f1a3 to bc5b467 Compare April 1, 2026 12:12
@altaywtf altaywtf self-assigned this Apr 1, 2026
@altaywtf
altaywtf force-pushed the fix/58315-abort-error-timeout-classification branch 2 times, most recently from 2f96c63 to 0531b64 Compare April 1, 2026 20:44
@altaywtf
altaywtf force-pushed the fix/58315-abort-error-timeout-classification branch from 0531b64 to d8412f2 Compare April 1, 2026 20:58
@altaywtf
altaywtf merged commit d9a7ffe into openclaw:main Apr 1, 2026
41 checks passed
@altaywtf

altaywtf commented Apr 1, 2026

Copy link
Copy Markdown
Member

Merged via squash.

Thanks @yelog!

steipete pushed a commit to duncanita/openclaw that referenced this pull request Apr 4, 2026
…nclaw#58315) (openclaw#58324)

Merged via squash.

Prepared head SHA: d8412f2
Co-authored-by: yelog <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…nclaw#58315) (openclaw#58324)

Merged via squash.

Prepared head SHA: d8412f2
Co-authored-by: yelog <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…nclaw#58315) (openclaw#58324)

Merged via squash.

Prepared head SHA: d8412f2
Co-authored-by: yelog <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…nclaw#58315) (openclaw#58324)

Merged via squash.

Prepared head SHA: d8412f2
Co-authored-by: yelog <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…nclaw#58315) (openclaw#58324)

Merged via squash.

Prepared head SHA: d8412f2
Co-authored-by: yelog <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
…nclaw#58315) (openclaw#58324)

Merged via squash.

Prepared head SHA: d8412f2
Co-authored-by: yelog <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
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: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Ollama NDJSON stream abort errors produce reason=unknown in model fallback logs

3 participants