fix: auto-retry on OpenAI stream stall errors (#355)

When the OpenAI responses stream stalls (e.g. with github-copilot/
gpt-5.4), the error message "stream stalled while waiting for the
next event" is now recognized as a retryable transient error.

Two locations updated:
- packages/ai/src/utils/retry.ts: add "stream stall" to
  TRANSIENT_MESSAGE_PATTERN (used by provider-level retry logic)
- packages/coding-agent/src/session/agent-session.ts: add
  "stream stall" to #isRetryableErrorMessage() regex (used by
  agent-session retry loop for both thrown errors and error
  AssistantMessages)

Fixes #348

Co-authored-by: GitHub User <user@example.com>
This commit is contained in:
elliotllliu
2026-03-10 07:28:16 +01:00
committed by GitHub
co-authored by GitHub User
parent acf4b45062
commit a648772ae5
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ type ErrorLike = {
};
const TRANSIENT_MESSAGE_PATTERN =
/overloaded|rate.?limit|usage.?limit|too many requests|service.?unavailable|server error|internal error|connection.?error|unable to connect|fetch failed/i;
/overloaded|rate.?limit|usage.?limit|too many requests|service.?unavailable|server error|internal error|connection.?error|unable to connect|fetch failed|stream stall/i;
const VALIDATION_MESSAGE_PATTERN =
/invalid|validation|bad request|unsupported|schema|missing required|not found|unauthorized|forbidden/i;
@@ -4113,8 +4113,8 @@ export class AgentSession {
}
#isRetryableErrorMessage(errorMessage: string): boolean {
// Match: overloaded_error, rate limit, usage limit, 429, 500, 502, 503, 504, service unavailable, connection error, fetch failed, retry delay exceeded
return /overloaded|rate.?limit|usage.?limit|too many requests|429|500|502|503|504|service.?unavailable|server error|internal error|connection.?error|unable to connect|fetch failed|retry delay/i.test(
// Match: overloaded_error, rate limit, usage limit, 429, 500, 502, 503, 504, service unavailable, connection error, fetch failed, retry delay exceeded, stream stall
return /overloaded|rate.?limit|usage.?limit|too many requests|429|500|502|503|504|service.?unavailable|server error|internal error|connection.?error|unable to connect|fetch failed|retry delay|stream stall/i.test(
errorMessage,
);
}