Repository navigation
测试:补迁上游 AI SDK 测试(按用例名约 18% 对上) #278
Description
进度(2026-10-27 更新)
按 RFC-0045(#281,已合入)逐个厂商迁:每家一个测试 PR,迁移中发现的行为差异修在这家的一个 fix: PR 里,一处一个提交(各带一个在 master 上失败的 aimux 测试,登记到 #276),测试 PR 叠在 fix PR 上,只放测试和 layout.toml。测试 PR 合入就勾上;括号里是有标记的用例数和上游用例数,fix 后面是修了几处。10-25:全部 PR 已转 ready,eric 两轮评审的意见都已改完推送,每次 master 有新合入都把各分支合上 master;修复 PR 先合,再合测试 PR,再合拆 crate 的搬迁 PR。 10-27:15 家厂商的测试 PR 和修复 PR 已全部合入,剩下 core 和 provider-utils。
- mistral:test: port the upstream Mistral tests #295(已合入),fix fix: Mistral injects the JSON instruction like the AI SDK #283(1 处,已合入)
- cohere:test: port the upstream Cohere tests #296(80 / 80,已合入)
- deepseek:test: port the upstream DeepSeek tests #299(已合入),fix fix: DeepSeek usage counts must be numbers #309(1 处,已合入)
- groq:test: port the upstream Groq tests #301(已合入),fix fix: Groq usage.raw keeps null fields #308(1 处,已合入)
- huggingface:test: port the upstream Hugging Face tests #303(34 / 38,已合入),fix fix: Hugging Face stream errors end with an error finish #307(3 处,已合入)
- xai:test: port the upstream xAI tests #312(297 / 367,已合入),fix fix: dropping an xAI streaming transcription closes the socket #311(2 处,已合入)
- anthropic-aws:test: port the upstream Anthropic AWS tests #319(46 / 53,已合入),fix fix: Anthropic AWS resolves the default fetch per request #318(5 处,已合入)
- azure:test: port the upstream Azure tests #324(88 / 97,已合入),fix 3 处都在 OpenAI 共用代码里,已随 fix: OpenAI Responses, chat, transcription and image behaviour match the AI SDK #368 合入(fix: OpenAI Responses reasoning deltas carry the item id #323 因此关闭)
- open-responses:test: port the upstream Open Responses tests #347(93 / 124,已合入),fix fix: Open Responses missing output is an API call error #346(16 处,已合入)
- google-vertex:test: port the upstream Google Vertex tests #352(已合入),fix fix: Vertex image and Live transcription match the AI SDK #351(2 处,其中 Live 转写那处在 Google 共用代码里,已合入)
- openai-compatible:test: port the upstream OpenAI-compatible tests #355(已合入),fix fix: OpenAI-compatible unparsable stream chunks are AI SDK parse errors #354(1 处,在 provider-utils 共用的 SSE 解析里,已合入)
- amazon-bedrock:test: port the upstream Amazon Bedrock tests #358(436 / 457,不含 anthropic/、mantle/ 两个子 provider,已合入),fix fix: Amazon Bedrock errors, warnings, usage and transport match the AI SDK #357(7 处,已合入)
- anthropic:test: port the upstream Anthropic tests #361(562 / 614,batch 与工具工厂未实现,不迁,已合入),fix fix: Anthropic prompts, betas, safeguards and streams match the AI SDK #360(12 处,已合入;另带的 fix: OpenAI-compatible unparsable stream chunks are AI SDK parse errors #354 共用 SSE 修复已随 fix: OpenAI-compatible unparsable stream chunks are AI SDK parse errors #354 合入)
- google:test: port the upstream Google tests #363(496 / 840,Interactions、realtime、Batch、语音翻译、工具结果下载未实现,不迁,已合入),fix fix: Google image inputs and live transcription match the AI SDK #362(1 处,已合入;另带的 fix: Vertex image and Live transcription match the AI SDK #351 Live 转写修复已随 fix: Vertex image and Live transcription match the AI SDK #351 合入)
- openai:test: port the upstream OpenAI tests #369(732 / 780,live、realtime、Batch、Skills、语音翻译未实现,不迁,已合入),fix fix: OpenAI Responses, chat, transcription and image behaviour match the AI SDK #368(36 处,已合入;其中 3 处是 Azure 的那 3 处,1 处与 fix: OpenAI-compatible unparsable stream chunks are AI SDK parse errors #354 相同)
- core(
ai包)和 provider-utils:上面 15 家都开完再做
迁移中记下、留给 core 迁移处理的问题在下面的评论里。
原始核对(2026-10-19)
迁移策略见 RFC-0045(#281):只迁 aimux 已实现模块对应的上游测试,选中文件里按固定类别排除用例(单步 core 不做的多步与工具执行、还没做的遥测、TS 专属、已登记差异、未做的子功能)。按这个策略估计要补约 3000 到 3500 个用例。下面的数字是按全部上游用例算的原始覆盖。
核对基线:master 5743a40a,上游 vercel/ai 在 ai@7.0.127 的提交 eb77f09e。只算 aimux 对齐的 17 个 provider 包和 ai/ 里在范围内的子目录。
现状
上游在范围内共 7784 个测试用例,按用例名能在 aimux 的 Rust 测试里找到对应的只有 1412 个(18%)。抽 95 个没对上的逐条核对,估计真实覆盖约 25%。没对上的里面,约一半是代码已有、没有测试;约三成是功能没实现(没登记的那部分已补进 #275、#276);约一成五不适用(TS 的 v2/v3 适配器等)。
这也是已知差距不会让 CI 变红的原因:对应的上游测试从来没迁过来。
各包覆盖(按用例名匹配)
| 包 | 上游用例 | 对上 | 比例 |
|---|---|---|---|
| ai/generate-text | 1137 | 38 | 3% |
| provider-utils | 831 | 67 | 8% |
| openai | 816 | 154 | 19% |
| 806 | 125 | 16% | |
| anthropic | 596 | 85 | 14% |
| amazon-bedrock | 511 | 147 | 29% |
| xai | 359 | 169 | 47% |
| openai-compatible | 267 | 82 | 31% |
| google-vertex | 245 | 41 | 17% |
| ai/util | 244 | 59 | 24% |
| ai/model | 193 | 12 | 6% |
| ai/prompt | 182 | 12 | 7% |
| ai/middleware | 162 | 2 | 1% |
| azure | 130 | 25 | 19% |
| ai/generate-object | 122 | 5 | 4% |
| groq、deepseek、huggingface、mistral、cohere | 445 | 287 | 50–84% |
清单(按优先级)
- core:
stream-text.test.ts(459 个用例)和generate-text.test.ts(284)合计 743 个,对上 38 个。其中约 400 个测多步、工具执行与审批,单步 core 按设计不做(对齐文档 Q1),不迁;约 80 个测遥测与回调,等可观测性 RFC。要补的约 250 个:文本、推理、sources()(aimux-core/src/generate.rs:386,只测了序列化)、文件、工具调用、错误、中止、结构化输出、工具选择检查。 - middleware:多个
transformParams的执行顺序(aimux-core/src/language_model_middleware.rs:86-110),以及 prompt 转换(ai/prompt7%)。 - Anthropic:
anthropic-language-model.test.ts(299 个没对上)、convert-to-anthropic-prompt.test.ts(81)。例如 code_execution 流结果、非 Anthropic 模型保留 temperature/topP、工具调用之间的 thinking 流。 - OpenAI:Responses 语言模型(185)、
convert-to-openai-responses-input(127)、openai-responses-prepare-tools(66)、chat(72)。例如include拼接、serviceTier、默认模型走 Responses、imageDetail、Azure 的 providerMetadata 键名。 - Google:
google-language-model.test.ts(171)。例如serviceTier、groundingChunks 图片来源、连续转写分段 id。 - Bedrock:
amazon-bedrock-chat-language-model.test.ts(129)。例如帧解码错误、Agent Runtime 独立 endpoint、显式 endpoint 时不读 region。 - openai-compatible、xAI、Vertex:PDF URL 报错、废弃键警告、reasoning 超出时 token 归零;xAI logprobs、x_search 工具名映射;Vertex 取 token 失败、私钥有无 kid。
- provider-utils 小文件一次迁完(
detect-media-type.test.ts69 个只对上 1 个等)。 - 差分 fixture 扩到 Bedrock、xAI、Vertex(现在 29 个,只覆盖 openai、openai-compatible、anthropic、google 和 provider-utils;录制脚本
scripts/aisdk-fixtures/record.mjs现成)。 - aimux 自己的薄弱点:OpenAI 兼容输出的流 id 与 model(RFC-0026)没有测试;DTO 向量覆盖 101/297 个类型([15/15] feat!: generate binding DTOs from the Rust types #268 G-i)。
- CI 校验与进度报表(RFC-0045 §7):出处标记指向真实上游用例,按文件打印已迁、已排除、未处理。
迁的过程中发现行为和上游不一致:按厂商修在一个 fix: PR 里,一处一个提交(RFC-0045 §5.4),刻意保留的差异登记后写进 layout.toml 的 registered。
Generated by Claude Code
Activity
cunninghamcard-bit commentedon Oct 20, 2026
开 RFC-0045(#281,已合入)之后才发现的补充问题。进度表已挪到正文开头;正文最后那句「在同一个 PR 里修」也已改成现在的做法(每处差异单开
fix:PR,RFC-0045 §5.4)。foo.test.ts测的是foo.ts。@ai-sdk/azure的azure-transcription-model.test.ts没有同名源文件,它测的AzureTranscriptionModel定义在azure-openai-provider.ts里。test: port the upstream Azure tests #324 把这个文件的排除写在azure-openai-provider.ts的条目下,并在layout.toml里加了注释。check.mjs上线时需要支持这种情况:可以加一个字段写明测试文件,或者按标记里的测试文件路径归组。NoSuchModel的文案:aimux-core 统一是no such model: …,上游是No such {modelType}: …(例如No such embeddingModel: …)。SigV4Fetch把取凭证失败包成ApiCall,上游直接抛凭证回调自己的错误。Anthropic AWS、Bedrock、Polly 都受影响。Generated by Claude Code