weiqingy opened a new pull request, #1037: URL: https://github.com/apache/flink-agents/pull/1037
Linked issue: #1036 ### Purpose of change The Anthropic integration gives `temperature` a default of `0.1` and puts it on every request without checking the model. Claude 4.7 and later answer a non-default sampling parameter with an HTTP 400, so selecting one of those models turned every chat call into a provider error. Both languages had the defect and neither gated on the model. The parameter is now dropped on models that reject it rather than clamped to the provider default, since substituting a value would quietly change sampling behaviour where omitting the parameter is accepted outright. A dropped temperature is logged once per model name, so the decision is visible without a warning on every request. The model list is kept in its own storage rather than derived from the two lists already in this connection, because the three boundaries do not coincide. Structured output starts at the 4.5 generation, prefill rejection at 4.6, and sampling rejection at 4.7, so Claude 4.6 rejects a prefill while still accepting a temperature. Reusing the prefill list would strip a temperature that the provider accepts on exactly those two names, and a test pins that case. Claude Fable 5, Claude Mythos 5 and Claude Mythos Preview are on the list without a matching sentence in the migration guide. That guide records each release's deltas, and these models succeed Claude Opus 4.8, which already rejects sampling parameters, so there was no delta for it to record. The code comment says so rather than implying a release note restates it. `top_p` and `top_k` can 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 left alone here. ### Tests `AnthropicChatModelConnectionTest` and `test_anthropic_response_parsing.py` each gain the same five cases: the predicate over every rejecting name, the predicate over accepting names including `None`, a dropped temperature on a rejecting model, a sent temperature on an accepting one, and a case pinning that a 4.6 model rejects the prefill while keeping its temperature. Java: 78 tests pass. Python: 81 pass, 2 skipped. Spotless, Ruff and the RAT license check are clean. Both suites were checked against a mutation that makes the new predicate always report supported. It fails 8 of the 18 new Java cases and 8 of the 17 new Python cases, and each source file was restored and confirmed byte-identical by checksum afterwards. ### API No public API change. `temperature` keeps its name, type, range check and `0.1` default in both languages; only whether it reaches the provider now depends on the model. Behaviour is unchanged on every model that accepts sampling parameters, including the default `claude-sonnet-4-20250514`. ### Documentation - [ ] `doc-needed` - [ ] `doc-not-needed` - [x] `doc-included` The `temperature` rows in both Anthropic setup tables in `chat_models.md` now note that the parameter is not sent on Claude 4.7 and later. ### Was this patch authored or co-authored using generative AI tooling? - [x] Yes - [ ] No Generated-by: Claude Code 2.1.240 (Claude Opus 5) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
