You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sessions die on transient socket closes because @ai-sdk/gateway is pinned 87 versions behind the retryability fix #48761
A dropped connection to the AI Gateway kills the assistant turn instead of being retried, surfacing as:
GatewayResponseError: Invalid error response format: Gateway request failed
(cause: AI_APICallError: Cannot connect to API: The socket connection was closed unexpectedly)
The retry path in session/retry.ts is already set up to handle this. RETRYABLE_MESSAGE_PATTERNS includes socket connection was closed. It never matches, because @ai-sdk/gateway rewrites the message before opencode sees it.
Running the two strings against opencode's own patterns:
"Invalid error response format: Gateway request failed" -> no match, turn dies
"Cannot connect to API: The socket connection was closed unexpectedly" -> matches, would retry
Three checks fail at once:
The rewritten message matches none of the RETRYABLE_MESSAGE_PATTERNS entries.
The Gateway preserves a 200 status on these, so the status >= 500 check does not catch it either.
error.data.isRetryable is false.
This was fixed upstream in vercel/ai#19890 ("mark response body network errors as retryable"), released in @ai-sdk/gateway 3.0.185. packages/opencode and packages/core both pin 3.0.104, which is 87 patch versions behind, so opencode does not have it.
It affects both failure shapes. In my own logs across 151 occurrences, 60% fail before any response byte and 25% fail more than 60s in, mid-stream. Both are response-body network errors and both are covered by the upstream fix.
Related to #30611, which asks for the same outcome from the opposite direction (widening opencode-side classification). This issue is specifically the stale dependency pin.
Plugins
None relevant
OpenCode version
1.18.30
Steps to reproduce
Use the vercel provider against the AI Gateway for an extended session.
Wait for the edge to retire a pooled keep-alive connection mid-session.
The turn ends with Invalid error response format: Gateway request failed instead of retrying.
Frequency here is roughly 0.9% of streams (151 failures across 16,510), and they cluster in bursts, so a long session is the practical way to hit it.
Activity
github-actions commentedon Sep 13, 2026
This issue might be a duplicate of existing issues. Please check:
Note: #30611 is already referenced in the issue body and covers the broader retry classification problem this is a specific root cause for.