TanStack AI version#
@tanstack/ai-openrouter 1.1.2 (same on main 92e8799), @tanstack/ai 1.8.0
Framework/Library version#
None needed (adapter level, Node 24)
Describe the bug and the steps to reproduce it#
OpenRouter ends a failed Responses stream with response.failed, carrying response.error: { code, message } and response.error_type (docs). code is coarse: server_error covers provider_overloaded, timeout, authentication and others.
Both response.failed branches in responses-text.ts build RUN_ERROR from response.error.code only, so error_type reaches neither errorType nor rawEvent. Other adapters fill RUN_ERROR.errorType since #1880. A consumer can't tell an overload from an auth failure.
Expected: RUN_ERROR.errorType set from error_type (parsed as response.errorType, or response.error_type on the unknown-event fallback).
Repro: chat() with openRouterResponsesText(...) against this SSE (HTTP 200):
event: response.failed
data: {"type":"response.failed","sequence_number":1,"response":{"id":"gen-1","object":"response","status":"failed","output":[],"error":{"code":"server_error","message":"x"},"error_type":"provider_overloaded"}}
Result: RUN_ERROR with code: 'server_error', no errorType.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)#
The SSE body above, served by a mocked httpClient.