[Bug] [integrations][anthropic] temperature defaults to 0.1 and is always sent, returning HTTP 400 on Claude 4.7 and later
- Dominant language
- Java
- Stars
- 452
- Forks
- 167
- Avg merge
- 5d 9h
- Merged PRs (30d)
- 49
Description
### Search before asking
- [X] I searched in the [issues](https://github.com/apache/flink-agents/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?
- [X] I'm willing to submit a PR!
Contributor guide
Assessment
This issue has not been assessed yet.