Skip to content

[BUG] claude-opus-4-7 deprecates temperature — agent.stream() returns 400, no framework-level handling (parity with PrefillErrorHandler) #16247

Description

@danielnc

Describe the Bug

Anthropic's 2026 breaking change to claude-opus-4-7 (and likely the wider 4.7 family) deprecates the temperature parameter (along with top_p / top_k). Any request that includes temperature returns:

400 — `temperature` is deprecated for this model.

Mastra's agent.stream() carries a default temperature (or whatever the user sets in defaultOptions / per-call callSettings) straight through to @ai-sdk/anthropic, which forwards it to the API verbatim. The result is a hard 400 in production with no graceful path.

This is the same shape of breaking change that motivated #13969 / #14435 (prefill removed in 4.5/4.6) — a model in a previously-supported family quietly drops a parameter, and the framework has no capability layer to absorb it.

Live failure

Production agent on claude-opus-4-7 with temperature: 0.3 → 400 mid-stream → run fails for the user with no automatic recovery. We currently have no way to ship 4-7 without forking Mastra or sanitising callSettings outside the framework.

Steps To Reproduce

  1. Create a Mastra Agent configured with model: anthropic('claude-opus-4-7') and any non-zero temperature (or rely on the SDK default).
  2. Call agent.stream({ messages: [{ role: 'user', content: 'hello' }] }).
  3. Anthropic returns 400 'temperature' is deprecated for this model.
  4. The error surfaces to the user; there is no processAPIError hook that fires for this since the PrefillErrorHandler regex doesn't match, and no other built-in processor strips the param.

Expected Behavior

Pick one of these (in order of preference):

  1. Auto-strip dropped-capability params for known models. Same shape as the auto-injected PrefillErrorHandler — a built-in inputProcessor (or call-settings sanitiser) consults a capability matrix per provider+modelId and removes params the model doesn't accept (temperature, top_p, top_k, prefill-trailing-assistant, etc.) before dispatch.
  2. Expose a public capability matrix users can extend. e.g. setModelCapabilities('claude-opus-4-7', { supportsTemperature: false }) so adding a new Anthropic / OpenAI / xAI release becomes a one-row catalog edit instead of a code search across every agent definition.
  3. At minimum: a built-in TemperatureDeprecatedHandler sibling to PrefillErrorHandler, registered the same way (auto-injected via errorProcessors), that on the 400 strips temperature (and top_p/top_k) from runState.callSettings and signals retry.

Why this matters / context

The ecosystem is hitting this same shape across frameworks each time Anthropic ships a breaking change:

Each framework currently solves it independently with its own per-model deny-list. Mastra is uniquely positioned to handle this at the provider + processor layer so users don't have to maintain their own model_capabilities.ts.

The processAPIError infrastructure that #14435 added is exactly the right primitive — it just needs (a) more matchers and (b) a way for the matcher to mutate callSettings, not just messageList. From the #14435 PR description, processors today can mutate messageList and signal { retry: true }; if processAPIError were extended to allow mutating callSettings (or returning a patched options bag), a stock TemperatureDeprecatedHandler becomes ~20 lines.

Reference

Verification

  • I have searched the existing issues to make sure this is not a duplicate (no issue mentions claude-opus-4-7 + temperature as of filing).
  • I have included sufficient information for the team to reproduce and understand the issue.

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions