{"id":655,"library":"langgraph-prebuilt","title":"LangGraph Prebuilt Agents","description":"LangGraph Prebuilt is a Python library offering high-level APIs for creating and executing LangGraph agents and tools. It simplifies building complex agentic workflows by providing pre-packaged components and architectures, reducing the need for low-level graph construction. Currently at version 1.0.8, this library is part of the broader LangGraph ecosystem, which undergoes frequent updates, with `langgraph-prebuilt` releases typically aligning with major feature additions to its high-level components. [2, 18]","status":"active","version":"1.0.8","language":"python","source_language":"en","source_url":"https://github.com/langchain-ai/langgraph/tree/main/libs/prebuilt","tags":["langchain","langgraph","ai-agents","llm","orchestration","agentic-workflows"],"install":[{"cmd":"pip install langgraph-prebuilt langchain-openai tavily-python","lang":"bash","label":"Install core library and common dependencies"}],"dependencies":[{"reason":"Core orchestration framework upon which prebuilt agents are built.","package":"langgraph","optional":false},{"reason":"Common LLM integration for agent models.","package":"langchain-openai","optional":true},{"reason":"Common tool integration for search functionality.","package":"tavily-python","optional":true},{"reason":"Used for defining state and output schemas.","package":"pydantic","optional":true}],"imports":[{"symbol":"create_react_agent","correct":"from langgraph.prebuilt import create_react_agent"},{"symbol":"ToolNode","correct":"from langgraph.prebuilt import ToolNode"},{"symbol":"tools_condition","correct":"from langgraph.prebuilt import tools_condition"},{"note":"MessagesState is part of the core langgraph graph module, not prebuilt.","wrong":"from langgraph.prebuilt import MessagesState","symbol":"MessagesState","correct":"from langgraph.graph import MessagesState"}],"quickstart":{"code":"import os\nfrom langchain_openai import ChatOpenAI\nfrom langchain_community.tools.tavily_search import TavilySearchResults\nfrom langgraph.prebuilt import create_react_agent\nfrom typing import Annotated, Sequence, TypedDict\nfrom langchain_core.messages import BaseMessage\n\n# Set API keys (replace with actual keys or set as environment variables)\nos.environ[\"OPENAI_API_KEY\"] = os.environ.get(\"OPENAI_API_KEY\", \"YOUR_OPENAI_API_KEY\")\nos.environ[\"TAVILY_API_KEY\"] = os.environ.get(\"TAVILY_API_KEY\", \"YOUR_TAVILY_API_KEY\")\n\n# Define the agent state (LangGraph requires a defined state)\nclass AgentState(TypedDict):\n    messages: Annotated[Sequence[BaseMessage], lambda x, y: x + y]\n\n# Initialize LLM and tools\nllm = ChatOpenAI(model=\"gpt-4o-mini\") # or any other tool-calling capable LLM\nsearch_tool = TavilySearchResults(max_results=3)\ntools = [search_tool]\n\n# Create the prebuilt ReAct agent\nagent_executor = create_react_agent(llm, tools=tools)\n\n# Example usage\n# Ensure OPENAI_API_KEY and TAVILY_API_KEY are set\nif os.environ[\"OPENAI_API_KEY\"] == \"YOUR_OPENAI_API_KEY\" or os.environ[\"TAVILY_API_KEY\"] == \"YOUR_TAVILY_API_KEY\":\n    print(\"Please set OPENAI_API_KEY and TAVILY_API_KEY environment variables or replace placeholders.\")\nelse:\n    response = agent_executor.invoke(\n        {\"messages\": [(\"human\", \"What is the weather in London and what is 123 + 456?\")]}\n    )\n    print(response[\"messages\"][-1].content)\n","lang":"python","description":"This quickstart demonstrates how to set up and use `create_react_agent` from `langgraph-prebuilt`. It initializes an OpenAI LLM, a Tavily search tool, and then creates an agent capable of using these tools. The agent is then invoked with a query, showcasing its ability to use tools for information retrieval and simple calculations. Ensure `OPENAI_API_KEY` and `TAVILY_API_KEY` are set in your environment for the example to run. [8, 13]"},"warnings":[{"fix":"For complex customizations, consider extending or modifying the prebuilt agent's internal graph if the documentation provides a clear path, or build a custom graph from scratch using `langgraph.graph.StateGraph` for full control. For simpler cases, leverage the provided prebuilt agent parameters and hooks. Consult the official LangGraph documentation for advanced patterns. [5, 8, 9]","message":"LangGraph is a low-level framework, while `langgraph-prebuilt` offers higher-level abstractions. Mixing low-level graph construction (e.g., `StateGraph`, `add_node`) with prebuilt agents (like `create_react_agent`) without understanding LangGraph's state management can lead to unexpected behavior or difficult-to-debug issues. Stick to one paradigm or thoroughly understand how state is managed across both. [3, 5, 6]","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always verify that all necessary API keys are correctly set in your environment or explicitly passed to the respective LLM/tool constructors before running the agent. Test credentials independently if an agent is failing. Use a `.env` file and `python-dotenv` for local development. [1, 6]","message":"Prebuilt agents often rely on external services (LLMs, search tools). Failing to set required API keys as environment variables (e.g., `OPENAI_API_KEY`, `TAVILY_API_KEY`) or passing incorrect values will cause agents to fail silently or with authentication errors. [1, 6, 13]","severity":"gotcha","affected_versions":"All versions"},{"fix":"Regularly consult the official LangChain/LangGraph documentation and quickstarts for the latest recommended practices and agent architectures. Pay attention to release notes for potential API changes or new high-level abstractions. [1, 7, 10]","message":"The LangGraph ecosystem, including `langgraph-prebuilt`, is actively developed. Older patterns for agents or tool integration, while functional, might be superseded by more efficient, flexible, or recommended approaches in newer releases. [7]","severity":"deprecated","affected_versions":"Versions <= 1.0.8, potentially future versions"},{"fix":"Ensure `langchain_community` is listed in your project's `requirements.txt` or explicitly installed via `pip install langchain-community` in your environment before running agents that rely on it. Verify your environment setup, especially in containerized or CI/CD contexts, to ensure all necessary dependencies are installed.","message":"The `langchain_community` package, which provides various tools and utilities (e.g., `TavilySearchResults`), is a common dependency for agents utilizing external services. If it's not explicitly installed, importing modules from it will result in a `ModuleNotFoundError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure all necessary Python packages are installed in the environment. This typically involves running `pip install <package_name>` for each required package, or using `pip install -r requirements.txt` if a `requirements.txt` file is present. Verify that the correct virtual environment is activated if applicable.","message":"A `ModuleNotFoundError` for packages like `langchain_community` indicates that required dependencies are not installed in the execution environment. Prebuilt agents and tools often rely on specific packages that must be explicitly added.","severity":"breaking","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T17:23:03.373Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Rename any local file named `langgraph.py` to something else. Ensure `langgraph` and `langgraph-prebuilt` are installed in your active virtual environment using: `pip install langgraph langgraph-prebuilt`. If issues persist, try creating a fresh virtual environment.","cause":"This error most commonly occurs when a Python file in your project is named `langgraph.py`, which shadows the installed `langgraph` package, or when `langgraph-prebuilt` is not properly installed or detected in the environment.","error":"ModuleNotFoundError: No module named 'langgraph.prebuilt'"},{"fix":"Ensure both `langgraph` and `langgraph-prebuilt` are updated to their latest compatible versions. It is recommended to install them together, or upgrade both: `pip install --upgrade langgraph langgraph-prebuilt`. If the problem persists, confirm the function's availability in the specific version's documentation.","cause":"This indicates that the `create_react_agent` function (or other specific components) cannot be found within `langgraph.prebuilt`, often due to a version mismatch between `langgraph` and `langgraph-prebuilt`, or an outdated installation.","error":"ImportError: cannot import name 'create_react_agent' from 'langgraph.prebuilt'"},{"fix":"Upgrade your `langgraph` package to a version compatible with your `langgraph-prebuilt` installation, or update both packages simultaneously: `pip install --upgrade langgraph langgraph-prebuilt`. Pinning compatible versions together is also a solution (e.g., `langgraph==1.1.x` for `langgraph-prebuilt==1.0.x`).","cause":"`langgraph-prebuilt` imports components like `ServerInfo` from `langgraph.runtime`, and this error occurs when your installed `langgraph` version is older and does not export these required names, indicating an incompatibility.","error":"ImportError: cannot import name 'ServerInfo' from 'langgraph.runtime'"},{"fix":"Ensure the LLM model you are using supports tool calling and implements the `bind_tools` method. If your current LLM does not, consider switching to a compatible model (e.g., OpenAI's Chat models, Anthropic's Claude 3, or other models with explicit tool-calling support) or integrate it via a custom wrapper that exposes the `bind_tools` functionality.","cause":"This error arises when using `langgraph-prebuilt` agents (like `create_react_agent`) with LLM models that do not support the `bind_tools` method, which is a required interface for tool calling within LangGraph agents.","error":"AttributeError: 'HuggingFaceEndpoint' object has no attribute 'bind_tools'"}],"ecosystem":"pypi","meta_description":null,"install_score":0,"install_tag":"stale","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":"1.1.0","install_checks":{"last_tested":"2026-05-12","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"89.9M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":10.6,"import_time_s":null,"mem_mb":null,"disk_size":"98M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"96.9M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":9.4,"import_time_s":null,"mem_mb":null,"disk_size":"105M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"87.5M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":7.7,"import_time_s":null,"mem_mb":null,"disk_size":"95M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"87.2M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":7.6,"import_time_s":null,"mem_mb":null,"disk_size":"95M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"86.2M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":11.9,"import_time_s":null,"mem_mb":null,"disk_size":"94M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}