summarize() sends temperature 0.3 to models that reject sampling parameters (e.g. claude-sonnet-5-5)
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
TanStack AI version
@tanstack/ai 0.68.0, @tanstack/ai-anthropic 0.21.1
Framework/Library version
TypeScript 7.0.2 (framework-independent)
Describe the bug and the steps to reproduce it
ChatStreamSummarizeAdapter.buildTextOptions always calls applyDefaultTemperature(this.name, 0.3, working) (chat-stream-summarize.ts#L375), which adds temperature: 0.3 unless the caller already set one. Several Anthropic models don't accept sampling parameters: their model meta leaves out AnthropicSamplingOptions (claude-sonnet-5, claude-sonnet-5-5, claude-opus-4-7, claude-opus-4-8, claude-fable-5, claude-fable-5-1, claude-haiku-5-5), and the AnthropicMaxTokensOptions doc comment notes that Fable 5 and Opus 4.7/4.8 reject them outright while Sonnet 5 returns a 400 for a non-default value. summarize() against these models still sends temperature: 0.3.
The documented opt-out ("the caller always wins") isn't available either: temperature isn't part of these models' modelOptions type, so summarize({ ..., modelOptions: { temperature: 1 } }) fails with TS2353.
Steps:
import { summarize } from "@tanstack/ai";
import { createAnthropicSummarize } from "@tanstack/ai-anthropic";
const bodies: Array<Record<string, unknown>> = [];
const fetch = async (_url: string, init: RequestInit) => {
bodies.push(JSON.parse(String(init.body)));
return new Response(JSON.stringify({ type: "error", error: { type: "invalid_request_error", message: "captured" } }), {
status: 400,
headers: { "content-type": "application/json" },
});
};
try {
await summarize({
adapter: createAnthropicSummarize("claude-sonnet-5-5", "key", { fetch, maxRetries: 0 }),
text: "Some long text.",
});
} catch {}
console.log(bodies[0]);
The captured request contains "model": "claude-sonnet-5-5", "temperature": 0.3, "max_tokens": 128000.
Expected: no temperature for models that reject sampling parameters, or a typed way to turn the default off.
A possible fix: let the text adapter report whether its model accepts sampling parameters (the provider model meta already knows) and skip the default when it doesn't. Meanwhile we wrap the text adapter handed to ChatStreamSummarizeAdapter and drop temperature from modelOptions in chatStream.
Possibly related: Anthropic's model docs list claude-opus-5 and claude-opus-5-5 as rejecting sampling parameters as well, while their model meta still includes AnthropicSamplingOptions. Might be worth a check.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
Inline above.
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
- 主要语言
- TypeScript
- 星标
- 3.2k
- 派生
- 372
- 平均合并
- 1 天 16 小时
- 30 天内合并 PR
- 244
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/ai 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
-
Durable resume through withPersistence never fills ctx.inputResponse for mcp_input interrupts可能已有人在做 @tombeckenham 于 3 天前认领。 未关闭waiting-on: maintainer
维护者通常 1 天内回复
-
ai, ai-persistence: a nested subagent that waits runs again from the start under withPersistence可能已有人在做 @tombeckenham 于 4 天前认领。 未关闭waiting-on: maintainer
维护者通常 1 天内回复
-
ai-ollama: streamed chat() reports finishReason "stop" when done_reason is "length"可能已有人在做 @AlemTuzlak 于 4 天前认领。 未关闭waiting-on: maintainer
维护者通常 1 天内回复
-
Discriminate status-dependent record and option types (RunRecord, SessionIndexEntry, InputState, durable-only options)可能已有人在做 @jherr 于 10 天前认领。 未关闭enhancement waiting-on: maintainer
维护者通常 1 天内回复
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 82/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
juice-shop/juice-shop#3706 ·
维护者通常 1 天内回复
-
sbx up from a subfolder silently pushes the whole work tree可能已有人在做 @pdettori 今天认领。 未关闭enhancement
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
outline/outline#14348 · 1 条评论 ·
维护者通常 1 天内回复
-
bug needs-triage
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复