🎯 Changes#
Fixes #2267
OpenRouter ends a failed Responses stream with response.failed, which carries response.error_type next to response.error. Both response.failed branches in the Responses adapter (chatStream and structuredOutputStream) built RUN_ERROR from response.error.code only, so the error type was lost. code is coarse (server_error covers overloads, timeouts and auth failures).
Both branches now set errorType, which chat() moves to metadata.tanstack.errorType. The SDK parses the field as response.errorType; the unknown-event fallback now maps error_type to it too. The value goes through toRunErrorDetails, so the same 128-character limit as other adapters applies.
- Unit: four cases (both methods, parsed and fallback events) fail on
main and pass here.
- E2E:
openrouter-responses-error-type-wire feeds the SSE from the issue through the real SDK parser.
- Docs: one sentence in
docs/chat/stream-events.md.
Verified locally: @tanstack/ai-openrouter tests (423 passed) and tsc, @tanstack/ai-e2e tsc, the new Playwright spec. The full pnpm run test:pr was not run.
This change was prepared with AI assistance.
✅ Checklist#
🚀 Release Impact#
Summary by CodeRabbit#
- Bug Fixes
- OpenRouter Responses errors now preserve the provider’s error type in chat and structured-output streams. When a provider reports an issue such as overload, that type is included in the reported error alongside the server-error code.
- Documentation
- Updated the stream-events documentation to describe the error type included with OpenRouter Responses errors.
View your CI Pipeline Execution ↗ for commit ba930324c81c7c185a8efdaaab400f63314e451c
nx affected --targets=test:sherif,test:knip,tes...nx run-many --targets=test:coverage --projects=...nx run-many --targets=build --exclude=examples/...💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗
☁️ Nx Cloud last updated this comment at
2026-11-30 09:32:10UTC