AnthropicLlm silently ignores generation config parameters
AnthropicLlm.generate_content_async accepts an LlmRequest with a fully populated GenerateContentConfig, but standard generation parameters are never forwarded to the Anthropic API — they are silently dropped. Additionally, newer Claude models (Claude 4.x / Opus 4.7+) introduce an output_config.effort parameter that has no ADK equivalent yet.
Part 1 — Sampling parameters silently dropped
Affected parameters: temperature, top_p, top_k, stop_sequences
Both the non-streaming and streaming messages.create calls pass only model, system, messages, tools, tool_choice, max_tokens, and thinking. Any value set on llm_request.config.temperature etc. is ignored. This is even visible in the test fixture (test_anthropic_llm.py) which sets temperature=0.1 — the value is never used.
These should be forwarded when set:
temperature=llm_request.config.temperature or NOT_GIVEN,
top_p=llm_request.config.top_p or NOT_GIVEN,
top_k=llm_request.config.top_k or NOT_GIVEN,
stop_sequences=llm_request.config.stop_sequences or NOT_GIVEN,
The same applies to _generate_content_streaming. LiteLlm already does this correctly for reference.
Part 2 — output_config.effort not supported (Claude 4.x / Opus 4.7+)
The Anthropic SDK added output_config: OutputConfigParam to messages.create. For Claude 4.x models, this is the preferred way to control output quality/speed tradeoffs ("low" / "medium" / "high" / "xhigh" / "max"). There is currently no way to pass this through AnthropicLlm.
Recommended approach: ThinkingLevel already exists on types.ThinkingConfig with values MINIMAL, LOW, MEDIUM, HIGH that map cleanly:
ThinkingLevel |
Anthropic effort |
|---|---|
MINIMAL |
"low" |
LOW |
"medium" |
MEDIUM |
"high" |
HIGH |
"xhigh" |
AnthropicLlm reads llm_request.config.thinking_config.thinking_level and maps it to output_config={"effort": value} — no new types, no ADK core changes.
For users who need effort="max" (no ThinkingLevel equivalent), an AnthropicGenerateContentConfig(types.GenerateContentConfig) subclass in anthropic_llm.py could serve as an escape hatch.
Note: when effort is set, temperature/top_p/top_k should not also be sent — the two APIs conflict.
I'd like to work on this. Can I be assigned?
Hello @sebastienc ,
Thank you for your interest in contributing. Do you already have a solution in mind? If so please feel free to submit a PR. Once it passes all checks and is approved by reviewer, it will be merged.
Yes. I can submit a PR. Thanks.
Hi, was this bug fixed? I see PRs were made then closed. If this is fixed, which version of adk-python contains the fix?