Ashfaqbs opened a new pull request, #1054: URL: https://github.com/apache/flink-agents/pull/1054
## Summary Fixes #1036. The Anthropic integration gives `temperature` a default of `0.1` and puts it on every request unconditionally, in both the Java and Python connections. Claude 4.7-generation models and later (`claude-opus-4-7`, `claude-opus-4-8`, `claude-opus-5`, `claude-sonnet-5`, `claude-fable-5`, `claude-mythos-5`, `claude-mythos-preview`) reject a non-default sampling parameter with an HTTP 400, so selecting one of those models turned every chat call into a provider error instead of a completion. Claude 4.6-generation models (`claude-opus-4-6`, `claude-sonnet-4-6`) still accept `temperature`, so this boundary sits one generation narrower than the existing `PREFILL_UNSUPPORTED_MODELS` list and can't reuse it (the same reasoning already documented on that list applies here in reverse). ## Changes - **Java** (`AnthropicChatModelConnection.java`): added a `SAMPLING_UNSUPPORTED_MODELS` allowlist and a `supportsSampling(String)` predicate, mirroring the existing `supportsJsonPrefill` gate. `buildRequest` now only forwards `temperature` onto the request builder when the effective model accepts it. - **Python** (`anthropic_chat_model.py`): added the matching `_SAMPLING_UNSUPPORTED_MODELS` / `_supports_sampling` and popped `temperature` from `kwargs` before calling `messages.create` when the model doesn't accept it. - Per the issue, `top_p` and `top_k` are out of scope — those only reach the request when a caller explicitly passes them via `additional_kwargs`/`kwargs`, not as a default the integration injects. The fix omits the parameter rather than changing its value, since Anthropic's own default (or omitting the parameter) is accepted on every model. ## Test plan - Added Java tests to `AnthropicChatModelConnectionTest`: parametrized coverage of every model in the new unsupported list reporting unsupported, every other model (including the 4.6-generation boundary models) reporting supported, and two `buildRequest` tests asserting `temperature` is present/absent on the built request. - Added Python tests to `test_anthropic_response_parsing.py`: parametrized predicate coverage plus two request-level tests asserting `temperature` is omitted/forwarded in the kwargs sent to `messages.create`. - Verified RED→GREEN: with the test files in place and only the source fix reverted (`git stash` on the source-only diff), the Java tests fail to compile against the missing `supportsSampling` symbol and the Python test module fails to import `_supports_sampling` — confirming the tests exercise the new behavior rather than passing vacuously. Restored the fix and reran: all new tests pass. - `mvn -pl integrations/chat-models/anthropic -am test` — full module suite green, no regressions. - `pytest flink_agents/integrations/chat_models/anthropic/tests/test_anthropic_response_parsing.py` — 77 passed. - `ruff check` / `ruff format --check` on the touched Python files — clean. - `spotless:apply` run on the touched Java test file to match AOSP formatting. Generated-by: Claude Code 2.1.226 (Claude Sonnet 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]
