Skip to content

fix(bedrock): drop temperature for Grok 4.6/4.7 and Kimi K3 on converse - #49367

Open
IsmaelMartinez wants to merge 1 commit into
BerriAI:mainfrom
IsmaelMartinez:fix/bedrock-sampling-params-xai-kimi
Open

IsmaelMartinez wants to merge 1 commit into
BerriAI:mainfrom
IsmaelMartinez:fix/bedrock-sampling-params-xai-kimi

Conversation

@IsmaelMartinez

Copy link
Copy Markdown

Bedrock rejects any temperature on Grok 4.6, Grok 4.7 and Kimi K3 through Converse, but LiteLLM still sends it, even with drop_params. This marks their Converse cost-map entries as not supporting sampling params, so LiteLLM drops temperature and top_p the way it already does for Claude Fable 5 and GPT 5.6.

Details

TLDR

Problem this solves:

  • Grok 4.6/4.7 and Kimi K3 reject temperature on Converse
  • LiteLLM forwards it even with drop_params=True

How it solves it:

User Flow

Before: a developer calling Kimi K3 on Bedrock with a temperature gets a 400

  1. They call litellm.completion(model="bedrock/global.moonshotai.kimi-k3", temperature=0.2, drop_params=True)
  2. Bedrock answers This model doesn't support the temperature field

After: the same call succeeds

  1. They call litellm.completion(model="bedrock/global.moonshotai.kimi-k3", temperature=0.2, drop_params=True)
  2. LiteLLM drops the temperature and Bedrock returns a completion
  3. Without drop_params they get LiteLLM's UnsupportedParamsError instead of Bedrock's 400

Relevant issues

Fixes #49366

Seen downstream in The-PR-Agent/pr-agent#4530.

Screenshots / Proof of Fix

Live calls with temperature=0.2, max_tokens=16, LITELLM_LOCAL_MODEL_COST_MAP=True.

Before (a9b1814)

  1. bedrock/global.moonshotai.kimi-k3, drop_params=True: BadRequestError: BedrockException - {"message":"This model doesn't support the temperature field. Remove temperature and try again."}
  2. bedrock/converse/us.xai.grok-4.6 and bedrock/converse/global.xai.grok-4.7, drop_params=True: same error
  3. bedrock/global.zai.glm-5.3: OK
  4. Direct boto3 converse on all three models: top_p=0.9, temperature=1 and temperature=0 are rejected too ("doesn't support the topP field" / "the temperature field"); GLM-5.3 accepts all three

After (4856b82)

  1. bedrock/global.moonshotai.kimi-k3, drop_params=True: OK; with drop_params=False: UnsupportedParamsError: bedrock does not support parameters: ['temperature']
  2. The two Grok calls: same as Kimi K3
  3. bedrock/global.zai.glm-5.3: OK
  4. test_converse_drops_temperature_for_grok_and_kimi: 9 passed; with the map restored to main, 9 failed

Type

🐛 Bug Fix
✅ Test

Caveats (if any)

Low

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

🤖 Generated with Claude Code

Bedrock answers any temperature on these models with "This model doesn't support the temperature field", so mark their converse entries supports_sampling_params: false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anishpentyala

Copy link
Copy Markdown

Verified this independently against the mechanism in #49366 (litellm main @ c4b01b2 vs this PR head 4856b82, pure-Python path):

  • Mechanism confirmed in code: AmazonConverseConfig.get_supported_openai_params consults _supports_sampling_params, which reads supports_sampling_params from the cost map (exact model name first, then global./us./eu. + base-model candidates) and defaults to True. The 9 new tests fail on main (temperature listed as supported and forwarded even with drop_params=True) and pass on this branch. Full tests/unit/llms/bedrock/chat/test_converse_transformation.py on this branch: 608 passed.
  • Completeness: every bedrock_converse cost-map entry for these models now carries the flag (us./global./us-gov. grok-4.6, us./global. grok-4.7, bare/us./global./in. kimi-k3); no other region variants exist in the map, and unprefixed lookups still resolve to the flag through the base-model candidates. Both JSON mirrors updated identically.
  • The drop_params=False path now raises litellm's UnsupportedParamsError with a clear message instead of Bedrock's opaque 400, which is the better failure.
  • External grounding of the provider behavior: an independent direct-API report for Grok 4.6 on Bedrock documents the same ValidationException ("This model doesn't support the temperature field") and that maxTokens-only requests succeed (https://forum.cursor.com/t/support-xai-grok-4-6-on-aws-bedrock/169641), and Moonshot's own docs state K3 fixes temperature at 1.0 and top_p at 0.95, errors on other values, and advises not passing them (https://platform.kimi.ai/docs/api/models-overview). Dropping both params matches those constraints. One thing I could not verify end-to-end: live Bedrock calls, since I have no AWS credentials - the issue reporter's live before/after screenshots cover that.
  • Prior-art check: 207 cost-map entries already carry supports_sampling_params: false on main (Claude Fable 5 / Opus 4.7 families), so this follows the established pattern from fix(bedrock): drop unsupported sampling params on converse reasoning models #39834.

(Written with AI assistance; the verification steps above were run as described.)

@IsmaelMartinez

Copy link
Copy Markdown
Author

Thanks @anishpentyala for verifying this independently. One detail on the Moonshot docs you linked: through Bedrock Converse, Kimi K3 and both Grok models reject even temperature=1 and temperature=0, and top_p=0.9, so dropping the fields rather than sending the fixed values is the right shape.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Bedrock Converse sends temperature to Grok 4.6/4.7 and Kimi K3, which reject it

2 participants