Skip to content

ChatBedrock: response_metadata["model_provider"] disagrees with _get_ls_params()["ls_provider"] #946

@AmberPann

Description

@AmberPann

Package

langchain-aws

Checked other resources

  • I added a descriptive title to this issue
  • I searched the LangChain documentation with the integrated search
  • I used the GitHub search to find a similar issue and didn't find it
  • I am sure this is a bug and not a question or request for help

Example Code

from langchain_aws import ChatBedrock
from langchain_core.messages import HumanMessage

model = ChatBedrock(
    model="global.anthropic.claude-sonnet-4-6",
    region="us-east-1",
)

ai = model.invoke([HumanMessage("Say OK in one word.")])
ls = model._get_ls_params()

print("response_metadata model_provider:", ai.response_metadata.get("model_provider"))
print("_get_ls_params ls_provider:", ls.get("ls_provider"))
assert ai.response_metadata.get("model_provider") == ls.get("ls_provider")

Error Message and Stack Trace (if applicable)

Description

Version:
langchain-aws==1.4.1
langchain==1.2.13

Bug Description:
ChatBedrock sets AIMessage.response_metadata["model_provider"] to "bedrock", but _get_ls_params()["ls_provider"] is "amazon_bedrock". Any code that compares these two strings as the same provider (e.g. LangChain SummarizationMiddleware’s usage-based trigger) never matches for Bedrock.

Image Image

SummarizationMiddleware:

Image

Metadata

Metadata

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions