Skip to content

fix(gen): fix init llm function - #265

Draft
OscarDDD wants to merge 4 commits into
mainfrom
fix_init_llm_function
Draft

OscarDDD wants to merge 4 commits into
mainfrom
fix_init_llm_function

Conversation

@OscarDDD

@OscarDDD OscarDDD commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Context

Closes SAP/ai-sdk-python-backlog#102.

What this PR does and why it is needed

Problem

The LangChain convenience method init_llm did not correctly set up ChatBedrock for the latest Anthropic Claude models.

The root cause was that our SDK injected its own default sampling values into the request before handing off to the model. For the newest Claude models this is harmful: they reject forced sampling
parameters (e.g. a hard-coded temperature / top_p), so a call that should have "just worked" failed or behaved incorrectly. In other words, the SDK was overriding what should have been the model's own defaults.

Fix

Two changes, both aimed at letting the model own its behavior instead of the SDK:

  1. Stop injecting SDK-side default values. Instead of setting explicit defaults for sampling parameters in our wrapper, we now only forward parameters the caller actually provides. When nothing is
    passed, no value is sent — so the model's own defaults apply. This removes the forced values that the latest Anthropic models rejected.
  2. Switch to the Converse API. Anthropic model initialization now routes through the Bedrock Converse API (ChatBedrockConverse) rather than the legacy Invoke path. Converse provides a unified, standardized request/response interface across models and is the recommended path for Claude (including native tool use), making init_llm reliable for the latest Anthropic models.
  3. Fix the client_params is not default parameter problem by restructuring AICoreBedrockBaseModel kwargs.

Result

init_llm can now initialize and call Anthropic Claude models correctly. Caller-provided sampling params are forwarded as-is; when omitted, the model applies its own defaults instead of SDK-imposed ones.


Definition of Done

  • Code is tested (Unit, Integration, E2E)
  • Error handling created / updated & covered by the tests above
  • Documentation updated
    • Only Public APIs are allowed to be used in documentation/tutorials/sample code -> Do it with another PR to the docs repository
  • (Optional) Aligned changes with the JS/TS and Java SDK
  • (Optional) Release notes updated -->

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.

1 participant