Skip to content

[Bug] [integrations][anthropic] temperature defaults to 0.1 and is always sent, returning HTTP 400 on Claude 4.7 and later #1036

Closed

Description

@weiqingy

Search before asking

  • I searched in the issues and found nothing similar.

Description

The Anthropic integration gives temperature a default of 0.1 and puts it on every request, with no check against the model. Claude 4.7 and later reject a non-default sampling parameter with an HTTP 400, so selecting one of those models turns every chat call into a provider error. Omitting the parameter, or sending the provider default, is still accepted, so the fix is to stop sending it rather than to change its value.

Both languages have the defect and neither gates on the model.

Java sets DEFAULT_TEMPERATURE = 0.1d in AnthropicChatModelSetup and puts the value on the parameter map unconditionally, and AnthropicChatModelConnection copies it onto the request builder whenever it is a Number. Python does the same through DEFAULT_TEMPERATURE = 0.1 and the model_kwargs property, which always includes temperature.

The affected names are the 4.7 generation onward: claude-opus-4-7, claude-opus-4-8, claude-opus-5, claude-sonnet-5, claude-fable-5, claude-mythos-5 and claude-mythos-preview. Sampling parameters are still accepted on claude-opus-4-6 and claude-sonnet-4-6.

That boundary is worth stating explicitly, because it is not the boundary either existing list in this connection encodes. Native structured output starts at the 4.5 generation, prefill rejection starts at 4.6, and sampling rejection starts at 4.7. Claude 4.6 rejects a prefill while still accepting a temperature, so PREFILL_UNSUPPORTED_MODELS cannot be reused here and a third list is needed. The comment already sitting on PREFILL_UNSUPPORTED_MODELS anticipates exactly this case, noting that sharing one list would hold only until a model moved one boundary without moving the other.

An untouched configuration does not hit this. The default model is claude-sonnet-4-20250514, which accepts sampling parameters, so reaching the failure requires selecting a newer model. This is the same shape as the prefill defect in #1009.

Not in scope here: top_p and top_k reach the request through additional_kwargs in Java and **kwargs in Python, and the same models reject them. Those are values a caller passes explicitly rather than a default the integration injects, so they are a separate concern.

How to reproduce

  1. Configure an Anthropic chat model and select a 4.7-generation or later model, for example claude-opus-4-7, leaving temperature at its default.
  2. Run an agent that issues a chat request through that model.
  3. The provider answers HTTP 400 rather than a completion, because the request carries temperature: 0.1.

The same steps against claude-sonnet-4-6 succeed, which isolates the failure to the sampling parameter rather than to the model selection itself.

Version and environment

Reproduces on the current main. Affects both the Java and Python Anthropic integrations.

Are you willing to submit a PR?

  • I'm willing to submit a PR!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

affectVersion/0.2.1affectVersion/0.3.1The bug affects the 0.3.1 version. The features are not needed.bug[Issue Type] Something isn't working as expected.fixVersion/0.4.0priority/majorDefault priority of the PR or issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions