Missing langchain dependency in langgraph.prebuild pyproject.toml file. #723

Closed
opened 2026-02-20 17:41:26 -05:00 by yindo · 2 comments
Owner

Originally created by @Andrii-Osipov on GitHub (Jun 13, 2025).

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

"""create or replace procedure langgraph_sp()
returns string
language python
packages=('snowflake-snowpark-python', 'langgraph', 'langchain-core')
runtime_version={runtime_version}
handler='handler'
as
$$
from langgraph.prebuilt import create_react_agent

def get_weather(city: str) -> str:
    '''Get weather for a given city.'''
    return f"It's always sunny in {{city}}!"
def handler(session):
    agent = create_react_agent(
    model="anthropic:claude-3-7-sonnet-latest",
    tools=[get_weather],
    prompt="You are a helpful assistant"
    )

    # Run the agent
    agent.invoke(
        {{"messages": [{{"role": "user", "content": "what is the weather in sf"}}]}}
    )
    return "success"
   

$$;
        """

Error Message and Stack Trace (if applicable)

{'errno': 100357, 'sqlstate': 'P0000', 'message': 'Python Interpreter Error:\nTraceback (most recent call last):\n  File "/usr/lib/python_udf/55a7560e83fb5b8c54caeb201b949065cb47b174e805e8dfd83b565878d5ded7/lib/python3.9/site-packages/langgraph/prebuilt/chat_agent_executor.py", line 434, in create_react_agent\n    from langchain.chat_models import (  # type: ignore[import-not-found]\nModuleNotFoundError: No module named \'langchain\'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File "_udf_code.py", line 8, in handler\n    agent = create_react_agent(\n  File "/usr/lib/python_udf/55a7560e83fb5b8c54caeb201b949065cb47b174e805e8dfd83b565878d5ded7/lib/python3.9/site-packages/langgraph/prebuilt/chat_agent_executor.py", line 438, in create_react_agent\n    raise ImportError(\nImportError: Please install langchain (`pip install langchain`) to use \'<provider>:<model>\' string syntax for `model` parameter.\n in function LANGGRAPH_SP with handler handler'}

Description

langgraph 0.4.7
I am trying to use create_react_agent as in the example of: https://github.com/langchain-ai/langgraph/blob/0.4.7/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py#L385-L400
These are the requirements that I used to build the pkg: https://github.com/AnacondaRecipes/langgraph-prebuilt-feedstock/blob/main/recipe/meta.yaml#L22
These are the requirements in upstream langgraph-prebuild: https://github.com/langchain-ai/langgraph/blob/0.4.7/libs/prebuilt/pyproject.toml#L14
Expected that the code must work through the langchain-core >=0.3.22, but it used langchain (which means that langchain-core is not used).
I don`t get why langchain.chat_models is used instead of langchain-core.language_models.chat_models.BaseChatModel, for example.
In this case, we needed to add langchain as an optional dependency in pyproject.toml for langgraph-prebuild, or rewrite the logic of create_react_agent to work through the langchain-core.
Thanks in advance!

System Info

Originally created by @Andrii-Osipov on GitHub (Jun 13, 2025). ### Checked other resources - [x] This is a bug, not a usage question. For questions, please use GitHub Discussions. - [x] I added a clear and detailed title that summarizes the issue. - [x] I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example). - [x] I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue. ### Example Code ```python """create or replace procedure langgraph_sp() returns string language python packages=('snowflake-snowpark-python', 'langgraph', 'langchain-core') runtime_version={runtime_version} handler='handler' as $$ from langgraph.prebuilt import create_react_agent def get_weather(city: str) -> str: '''Get weather for a given city.''' return f"It's always sunny in {{city}}!" def handler(session): agent = create_react_agent( model="anthropic:claude-3-7-sonnet-latest", tools=[get_weather], prompt="You are a helpful assistant" ) # Run the agent agent.invoke( {{"messages": [{{"role": "user", "content": "what is the weather in sf"}}]}} ) return "success" $$; """ ``` ### Error Message and Stack Trace (if applicable) ```shell {'errno': 100357, 'sqlstate': 'P0000', 'message': 'Python Interpreter Error:\nTraceback (most recent call last):\n File "/usr/lib/python_udf/55a7560e83fb5b8c54caeb201b949065cb47b174e805e8dfd83b565878d5ded7/lib/python3.9/site-packages/langgraph/prebuilt/chat_agent_executor.py", line 434, in create_react_agent\n from langchain.chat_models import ( # type: ignore[import-not-found]\nModuleNotFoundError: No module named \'langchain\'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "_udf_code.py", line 8, in handler\n agent = create_react_agent(\n File "/usr/lib/python_udf/55a7560e83fb5b8c54caeb201b949065cb47b174e805e8dfd83b565878d5ded7/lib/python3.9/site-packages/langgraph/prebuilt/chat_agent_executor.py", line 438, in create_react_agent\n raise ImportError(\nImportError: Please install langchain (`pip install langchain`) to use \'<provider>:<model>\' string syntax for `model` parameter.\n in function LANGGRAPH_SP with handler handler'} ``` ### Description **langgraph 0.4.7** I am trying to use **create_react_agent** as in the example of: https://github.com/langchain-ai/langgraph/blob/0.4.7/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py#L385-L400 These are the **requirements** that I used to build the pkg: https://github.com/AnacondaRecipes/langgraph-prebuilt-feedstock/blob/main/recipe/meta.yaml#L22 These are the **requirements** in upstream **langgraph-prebuild**: https://github.com/langchain-ai/langgraph/blob/0.4.7/libs/prebuilt/pyproject.toml#L14 Expected that the code must work through the **langchain-core >=0.3.22**, but it used **langchain** (which means that **langchain-core** is not used). I don`t get why **langchain.chat_models** is used instead of **langchain-core.language_models.chat_models.BaseChatModel**, for example. In this case, we needed to add **langchain** as an **optional dependency** in **pyproject.toml** for **langgraph-prebuild**, or rewrite the logic of **create_react_agent** to work through the **langchain-core**. Thanks in advance! ### System Info -
yindo added the bugpending labels 2026-02-20 17:41:26 -05:00
yindo closed this issue 2026-02-20 17:41:26 -05:00
Author
Owner

@sydney-runkle commented on GitHub (Jun 13, 2025):

if isinstance(model, str):
        try:
            from langchain.chat_models import (  # type: ignore[import-not-found]
                init_chat_model,
            )
        except ImportError:
            raise ImportError(
                "Please install langchain (`pip install langchain`) to use '<provider>:<model>' string syntax for `model` parameter."
            )

You'll need to install langchain if you want to use that syntax for models, else you can use ChatOpenAI directly with the required langchian-openai dependency.

@sydney-runkle commented on GitHub (Jun 13, 2025): ```py if isinstance(model, str): try: from langchain.chat_models import ( # type: ignore[import-not-found] init_chat_model, ) except ImportError: raise ImportError( "Please install langchain (`pip install langchain`) to use '<provider>:<model>' string syntax for `model` parameter." ) ``` You'll need to install langchain if you want to use that syntax for models, else you can use `ChatOpenAI` directly with the required `langchian-openai` dependency.
Author
Owner

@Andrii-Osipov commented on GitHub (Jun 13, 2025):

@sydney-runkle But why not add langchain as an optional dependency?

@Andrii-Osipov commented on GitHub (Jun 13, 2025): @sydney-runkle But why not add **langchain** as an **optional** dependency?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#723