summarize() sends temperature 0.3 to models that reject sampling parameters (e.g. claude-sonnet-5-5)
Maintainers usually reply within 1 day
Assessment
This issue has not been assessed yet.
Description
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.
- Dominant language
- TypeScript
- Stars
- 3.2k
- Forks
- 361
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 210
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TanStack/ai
-
ai-openrouter: malformed Chat Completions tool arguments execute as an empty objectPossibly taken @tombeckenham claimed this 2 days ago. Openhas-pr waiting-on: maintainer
TanStack/ai#1689 · 1 assignee ·
Maintainers usually reply within 1 day
-
StreamProcessor discards metadata from REASONING_MESSAGE_STARTPossibly taken @tombeckenham claimed this 2 days ago. Openwaiting-on: maintainer
TanStack/ai#1667 · 1 assignee ·
Maintainers usually reply within 1 day
-
Async persistence restored before attach() never rejoins an in-flight runPossibly taken @tombeckenham claimed this 5 days ago. Openhas-pr waiting-on: maintainer
TanStack/ai#1639 · 1 assignee ·
Maintainers usually reply within 1 day
-
`ai-opencode`: `RUN_FINISHED` never arrives when an adapter teardown step does not settlePossibly taken @tombeckenham claimed this 5 days ago. Openwaiting-on: maintainer
TanStack/ai#1638 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
ai-mcp: support publishing MCP list changes to subscribed clientsPossibly taken @jherr claimed this 5 days ago. Openwaiting-on: maintainer
Difficulty 5/5 Over a week Newbie friendliness 28/100
TanStack/ai#1631 · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
nextjs-tracking
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
cloudflare/vinext#3887 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
apache/rocketmq-dashboard#6331 ·
Maintainers usually reply within 5 days
-
bug cache clinical-safety P1-critical
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
juspay/blend-design-system#1788 ·
Maintainers usually reply within 1 day
-
[Analytics] Add Focus Time-Block Efficiency Ratio Calculator in src/lib/focus/efficiency-ratio.tsOpenanalytics beginner friendly community contributions-welcome enhancement good first issue hacktoberfest help wanted up-for-grabs
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day