fix: surface provider error details from Responses API stream failures - #12700
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
Verification notes / assumptions
Previous Review Summaries (7 snapshots, latest commit 9245279)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 9245279)Status: No Issues Found | Recommendation: Merge Resolved since the previous review
Files Reviewed (2 files)
Verification notes / assumptions
Previous review (commit 411f28f)Status: 1 Issue Found | Recommendation: Optional polish; nothing blocking Overview
Issue Details (click to expand)SUGGESTION
Resolved since the previous review
Files Reviewed (2 files)
Verification notes / assumptions
Fix these issues in Kilo Cloud Previous review (commit 31d844a)Status: 2 Issues Found | Recommendation: Address the null-code gap before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Resolved since the previous review
Files Reviewed (2 files)
Verification notes / assumptions
Fix these issues in Kilo Cloud Previous review (commit 9779216)Status: 2 Issues Found | Recommendation: Consider the retry-classification regression before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Resolved since the previous review
Files Reviewed (3 files)
Verification notes / assumptions
Fix these issues in Kilo Cloud Previous review (commit 861e2e5)Status: 2 Issues Found | Recommendation: Suggestions only — safe to merge after considering Overview
Issue Details (click to expand)SUGGESTION
Resolved since the previous review
Files Reviewed (5 files)
Verification notes / assumptions
Fix these issues in Kilo Cloud Previous review (commit 0e3ce11)Status: 2 Issues Found | Recommendation: Suggestions only — safe to merge after considering Overview
Issue Details (click to expand)SUGGESTION
Resolved since the previous review
Files Reviewed (5 files)
Verification notes / assumptions
Fix these issues in Kilo Cloud Previous review (commit f695425)Status: 3 Issues Found | Recommendation: Suggestions only — safe to merge after considering Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (5 files)
Verification notes / assumptions
Reviewed by claude-opus-5 · Input: 22 · Output: 2.6K · Cached: 456.6K Review guidance: REVIEW.md from base branch |
fix: surface provider error details from Responses API stream failures

What
Dependency bumps —
@ai-sdk/openai3.0.53 → 3.0.88 inpackages/opencode,packages/core, andpackages/kilo-gateway;@ai-sdk/azure3.0.49 → 3.0.93 (opencode/core); and the AI SDK core set in lockstep so no duplicate provider packages result:aicatalog 6.0.168 → 6.0.235,@ai-sdk/gateway3.0.104 → 3.0.157,@ai-sdk/provider3.0.8 → 3.0.14,@ai-sdk/provider-utils4.0.23 → 4.0.40,@ai-sdk/anthropic(kilo-gateway) 3.0.71 → 3.0.82. The lockfile resolves single shared copies for the bumped set.Error rendering —
ProviderError.parseStreamErrornow recognizes provider stream failures that arrive without the{ type: "error" }envelope, via two additions inpackages/opencode/src/kilocode/provider/error.ts:frame()normalizes the incoming frame with zod schemas: OpenAI Responses APIresponse.failedterminal frames are unwrapped to their innerresponse.error, envelope-less{ error: { code, message } }wrappers and bare{ code, message }objects are wrapped in the standard envelope (nestederrorwins over bare top-level fields, explicitnullfields tolerated).fallback()handles normalized frames whose error code isn't in the existing switch: any frame with a non-emptyerror.messagerenders as a cleanAPIErrorinstead of aJSON.stringifydump, with retryability kept on par with theSession.retryableheuristics that previously applied (429/5xx numeric or string codes, rate-limit/exhausted/overload-style code anderror.typesignals, and a narrow rate-limit-only match on free-form message text).Why
When a Responses API stream ends with a
response.failedevent (e.g. an upstream 429 rate limit from a gateway),@ai-sdk/openai< 3.0.82 parsed theresponse.errorpayload but silently discarded it, ending the stream with a barefinishReason: "error". Kilo then fell back to the generic "The provider ended the response with an error before returning details" notice (KiloSessionProcessor.providerFinishError), hiding actionable messages like "temporarily rate-limited upstream, retry shortly".@ai-sdk/openai@3.0.82(vercel/ai commitae00aeb) fixes the drop: pre-output failures throw anAPICallErrorwith the provider's actual message/status, and mid-stream failures enqueue anerrorchunk with the fullresponse.failedpayload. The mid-stream chunk is a plain object, not anError, so without the frame normalizer it rendered as a raw JSON dump (NamedError.Unknown) — the normalizer routes it into the existing provider-error handling, producing a cleanAPIErrorwith the provider's message and retryability, preserving the original frame inresponseBody.Version choice
Pins are the newest versions that pass the repo's
minimumReleaseAgequarantine (~4.75 days) at PR time; openai 3.0.88 ≥ 3.0.82 so it contains the fix. Azure 3.0.93 adds@ai-sdk/deepseekas a new transitive dependency (2.0.50, quarantine-safe).@ai-sdk/anthropicis quarantine-exempt.Deliberately out of scope
@ai-sdk/amazon-bedrock— its 4.0.141 bump also drags bundled@ai-sdk/anthropic3.0.81 → 3.0.102 (every Claude-on-Bedrock request), which deserves its own PR with a Bedrock smoke test.packages/core/src/github-copilot/responses/has noresponse.failedhandling; porting the upstream fix there is a follow-up. The changeset text is scoped accordingly.ai-gateway-provider(Vercel AI Gateway optional deps) — a third-party transitive resolution we can't pin from here.Testing
packages/opencode/test/kilocode/provider/error.test.tsgrows from 5 to 18 tests: the exactresponse.failedrate-limit payload, envelope-less and bare error objects, nested-error precedence, explicitnullfields, unlisted codes, numeric and numeric-string 429/5xx retryability, Anthropicrate_limit_errorandresource_exhaustedparity with the old heuristics, hyphenated rate-limit prose, and terminal-error messages that merely mention availability.