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
- フォーク
- 361
- 平均マージ
- 1日 13時間
- マージ済み PR(30日)
- 241
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/ai のほかの issue
-
decide() drops billed usage when a call fails after the provider responded対応中かも @tombeckenham が 1 日前に担当しました。 オープンhas-pr waiting-on: maintainer
メンテナーはふだん 1 日以内に返信
-
chat(): sign the state of a suspended run so a resume without persistence cannot change it対応中かも @AlemTuzlak が 1 日前に担当しました。 オープンwaiting-on: maintainer
TanStack/ai#1740 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
@tanstack/ai-anthropic: a stream that fails after message_start loses the call's input usage対応中かも @AlemTuzlak が 2 日前に担当しました。 オープンwaiting-on: maintainer
メンテナーはふだん 1 日以内に返信
-
@tanstack/openai-base: Responses usage drops input_tokens_details.cache_write_tokens対応中かも @tombeckenham が 2 日前に担当しました。 オープンwaiting-on: maintainer
メンテナーはふだん 1 日以内に返信
-
ai-openrouter: malformed Chat Completions tool arguments execute as an empty object対応中かも @tombeckenham が 5 日前に担当しました。 オープンhas-pr waiting-on: maintainer
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
AvaProtocol/ava-sdk-js#276 ·
メンテナーはふだん 1 日以内に返信
-
useFragment does not require `variables` when the fragment's variables type has required fieldsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
apollographql/apollo-client#13493 ·
メンテナーはふだん 1 日以内に返信
-
Custom hosts written as trailing-dot FQDNs (`host.local.`) aren't detected as local backends対応中かも @roboomp が今日担当しました。 オープンbug prio:p2 providers triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
can1357/oh-my-pi#15798 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
code-yeongyu/oh-my-openagent#10172 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
PDFCraftTool/pdfcraft#189 ·