Skip to content

Langsmith include_model broken due to deserialization allowlist #34645

@gabrielrfg

Description

@gabrielrfg

Package

  • langchain-core
  • langchain-aws

Example Code (Python)

from langsmith import Client

client = Client(api_key=LANGSMITH_API_KEY)
prompt = client.pull_prompt(PROMPT_ID, include_model=True) #Model must be any ChatBedrockConverse in Langsmith

print(prompt.last.bound.invoke("hi"))

Error Message and Stack Trace (if applicable)

ValueError: Deserialization of ('langchain', 'chat_models', 'openai', 'ChatOpenAI') is not allowed. The default (allowed_objects='core') only permits core langchain-core classes. To allow trusted partner integrations, use allowed_objects='all'. Alternatively, pass an explicit list of allowed classes via allowed_objects=[...]. See langchain_core.load.mapping for the full allowlist.

Description

Irrespective of langchain-aws and langsmith versions, pulling ChatBedrockConverse models through langsmith's pull_prompt method with include_model=True is broken from langchain-core>=1.2.5, works perfectly in 1.2.4.

I traced it to #34455. In this PR it seems there was a larger enforcement of the whitelist for partner models/packages. The issue I'm facing is also referenced in langchain-ai/langchain-aws#816, where allowed_objects='all' is used to pass unit tests, however, when pulling using the langsmith client this is not possible to set, resulting in the broken integration.

Looked into the allow list in langchain_core/load/mapping.py and I found the issue: ChatBedrock is allowed, BedrockLLM is allowed, but ChatBedrockConverse is not in the list. I quickly patched this locally and the issue seems to be fully fixed. I'll be creating a PR for this, but would appreciate if anyone could point out anything I might've missed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugRelated to a bug, vulnerability, unexpected error with an existing featurecore`langchain-core` package issues & PRsexternal

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions