Repository navigation
refactor: share provider stream error - #384
Merged
Merged
Conversation
…der_stream_error Ports createProviderStreamError from @ai-sdk/provider-utils 5.0.55: the provider passes message, code, status, retryability and raw data as a ProviderStreamError; an unset retryability still follows the status. Ports the upstream test case that applies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…am_error Each provider keeps its status table and passes retryability and data in, instead of patching the built error afterwards. Errors are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Bedrock built its exception-frame ApiCallError by hand, copying the request body as sent. It now uses create_provider_stream_error, which bounds and redacts it, sanitizes the URL and keeps the frame and the response headers, as the other providers do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
30 of 57 tasks
cunninghamcard-bit
marked this pull request as ready for review
October 27, 2026 22:50
eric8810
reviewed
Oct 27, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
共享 helper 的语义和 13 个 call site 都核对通过,Bedrock 的有意变化也有测试。但当前不能合:
- 对 master 9f9f5ab 已 CONFLICTING:lib.rs、tests/mod.rs、CHANGELOG 三处冲突。注意 naively 解冲突会留下两个
#[cfg(test)] mod tests;,直接编译错;保留一个,并把create_provider_stream_error与resolve_provider_reference两个模块都列上。 - Google
google/error.rs:42、Mistralmistral/error.rs:53、Codexcodex.rs:400没有 in-stream-error 断言;既然这次在集中 raw/data 形状,建议补上,至少 Google/Mistral。 - CI 16/16 是 base b0450d4 的,master 已前进,rebase 后要重跑。
Breaking removal 已记录,可接受。
…ider-stream-error # Conflicts: # CHANGELOG.md # aimux-provider-utils/src/lib.rs # aimux-provider-utils/src/tests/mod.rs
…odex Each test feeds one error event and checks the ApiCallError it becomes: message, provider code, status, retryability, data and response body. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Contributor
Author
|
三条都处理了,新头
Generated by Claude Code |
…ider-stream-error # Conflicts: # aimux-provider-utils/src/tests/mod.rs
eric8810
reviewed
Oct 28, 2026
…ider-stream-error
Contributor
Author
Generated by Claude Code |
eric8810
approved these changes
Oct 28, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
冲突已解且无重复 mod tests;Google/Mistral/Codex 测试保持,helper 语义未变,16/16 CI 通过。Re-approve。
…ider-stream-error # Conflicts: # CHANGELOG.md # aimux-provider-utils/src/lib.rs # aimux-provider-utils/src/tests/mod.rs
Contributor
Author
Generated by Claude Code |
eric8810
reviewed
Oct 28, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
代码/tests 的 rebase 没问题,16/16 CI 也绿;但 CHANGELOG 的冲突解错了:CHANGELOG.md:1457 多插了一个 ### Fixed,导致四条 Added bullet(1464–1474)落在 Fixed 下面,真正的 ### Fixed 在 1476。删掉 1457–1458 的 heading/空行,把 Bedrock bullet 移到 1476 下面即可。
The master merge left a second Fixed heading inside Added, which moved four Added bullets under it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Contributor
Author
Generated by Claude Code |
eric8810
approved these changes
Oct 29, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
CHANGELOG 已修:只有一个 ### Fixed,Bedrock bullet 在 1470-1473;代码/tests 未变,16/16 CI 通过。Approve。
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RFC-0046 R1 的第 6 个小 PR(清单见 #328):把
createProviderStreamError放进aimux-provider-utils,取代原来的stream_error_api_call。12 个厂商的流内错误都由它构造,各家只留自己的状态码表。Before:
stream_error_api_call只收消息、code、状态码和事件。是否可重试只能由状态码推出,原始数据只能等于事件本身,所以 Anthropic、DeepSeek、OpenAI、xAI 拿到错误后再改is_retryable和data。Bedrock 没用它,自己拼ApiCallError,请求体原样带进公开错误(data URL、长提示词都在),也没有响应体和响应头。After:厂商把上游
ProviderStreamError的几个字段(消息、code、状态码、是否可重试、原始数据)交给create_provider_stream_error,不再事后改错误。Bedrock 也走它,请求体按其他厂商一样截断、脱敏,URL 去掉查询串和凭据,帧作为响应体,带上响应头。一、体系现状(概览)
上游:
aimux(master b0450d4,9f9f5ab4 上相同):
二、本 PR 改动(细节)
ApiCallError只有一个 code 字段,上游的type和code由各家选一个填进provider_code,与改动前一致。测试:
src/tests/create_provider_stream_error.rstype);isProviderStreamError那条是 TS 专有;另 2 条非上游:可重试按状态码推出、事件作响应体并读出重试提示tests/chat_language_model_event_stream.rstests/language_model.rs:8012mod in_stream_errorRESOURCE_EXHAUSTED的流内错误tests/chat_language_model.rs:1483mod in_stream_errorrate_limit_error、status_code 429codex.rs:650response.failed新增的 4 条都断言 message、status、provider_code、is_retryable、data、response_body 和 URL。其余厂商的已有用例原样通过。工作区测试 4380 → 4384(provider-utils 的 3 个另计)。
改动规模(对 master 9f9f5ab):
公开 API 与行为
aimux_provider_utils::stream_error_api_call删除,改用create_provider_stream_error和ProviderStreamError。create_provider_stream_error、ProviderStreamError。检查
cargo fmt --check、scripts/check_provider_boundaries.sh、cargo +1.99 clippy(providers 与 provider-utils,-D warnings)、cargo check --workspace、cargo doc、全部测试均通过(基于 master 9f9f5ab)。🤖 Generated with Claude Code
https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW