-
Notifications
You must be signed in to change notification settings - Fork 192
Description
🐞 Bug: Bedrock Application Inference ARN breaks Claude Sonnet tools usage (regional inference works)
Issue description
When running a LangChain agent using tools with Bedrock Claude Sonnet 3.7, the behavior differs between regional inference and application inference profiles.
- With regional inference (
us.anthropic.claude-3-7-sonnet-20250219-v1:0
), tools are passed properly and the agent calls tools as expected. - With application inference ARN (
arn:aws:bedrock:us-east-1:111111484058:application-inference-profile/c3myu2h6fllr
), the LLM does not use the tools properly - tools are not passed and the output ignores them.
This makes it impossible to use tools with Claude when specifying an application inference ARN.
I confirmed with an AWS Bedrock specialist that the Application Inference Profile has exactly the same API as the regional inference and supports all features, including the tools API. Therefore, this appears to be a bug in how langchain-aws
detects and handles the model name when using an ARN.
Investigation
In bedrock.py
, the relevant logic is here:
if "claude-" in self._get_base_model():
When using a regional inference name (us.anthropic.claude-3-7-sonnet-20250219-v1:0
), this condition passes, so tools are serialized properly using the Anthropic tools JSON API.
When using an application inference ARN (arn:aws:bedrock:...
), the ARN string does not contain "claude-"
, so the condition fails, and tools are not passed correctly - which results in the LLM ignoring them.
In my older local version of the package (about 1 month old), the check was even stricter:
if "claude-3" in self._get_base_model():
So it seems this code is actively evolving - but the issue remains: using the ARN prevents tools from being passed properly.
Example
Regional inference (works):
model = ChatBedrock(
model="anthropic.claude-3-7-sonnet-20250219-v1:0",
...
)
agent = model.bind_tools(...)
# tools invoked as expected
Application ARN (broken):
model = ChatBedrock(
model="arn:aws:bedrock:us-east-1:111111484058:application-inference-profile/c3myu2h6fllr",
...
)
agent = model.bind_tools(...)
# tools ignored
Expected behavior
Tools should be passed properly even when using an application inference ARN, since AWS confirms that the API and feature set are identical to regional inference. If detection of model type from ARN is needed, the implementation should handle this accordingly.