{"id":7900,"library":"ag-ui-langgraph","title":"AG-UI LangGraph Integration","description":"ag-ui-langgraph is a Python library that provides a comprehensive integration of the Agent User Interaction (AG-UI) protocol with LangGraph. It enables standardized, event-driven communication between frontend applications and LangGraph-powered AI agents, facilitating real-time streaming interactions and state synchronization. The current version is 0.0.33 and it appears to have a relatively active release cadence with frequent updates to align with LangChain/LangGraph developments.","status":"active","version":"0.0.33","language":"python","source_language":"en","source_url":"https://github.com/ag-ui-org/ag-ui","tags":["langgraph","ai-agents","frontend-integration","real-time","fastapi","ag-ui","event-driven"],"install":[{"cmd":"pip install ag-ui-langgraph","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for defining agent workflows.","package":"langgraph","optional":false},{"reason":"Foundational LangChain components.","package":"langchain-core","optional":false},{"reason":"Used for various LangChain utilities and integrations.","package":"langchain","optional":false},{"reason":"Data validation and settings management, with some noted deprecation warnings.","package":"pydantic","optional":false},{"reason":"Defines the core AG-UI event types and structures.","package":"ag-ui-protocol","optional":false}],"imports":[{"wrong":"from ag_ui_langgraph import LangGraphAgent","symbol":"LangGraphAgent","correct":"from ag_ui_langgraph import LangGraphAgent"}],"quickstart":{"code":"import os\nfrom fastapi import FastAPI\nfrom langgraph.graph import StateGraph, MessagesState\nfrom langchain_openai import ChatOpenAI\nfrom langchain_core.messages import HumanMessage, AIMessage\nfrom ag_ui_langgraph import add_langgraph_fastapi_endpoint\n\n# Ensure OPENAI_API_KEY is set in your environment\nos.environ['OPENAI_API_KEY'] = os.environ.get('OPENAI_API_KEY', 'your_openai_api_key_here')\n\n# Define your LangGraph workflow\nclass AgentState(MessagesState):\n    pass\n\ndef call_model(state):\n    messages = state['messages']\n    model = ChatOpenAI(model=\"gpt-4o-mini\") # Using a cost-effective model for quickstart\n    response = model.invoke(messages)\n    return {\"messages\": [response]}\n\nworkflow = StateGraph(AgentState)\nworkflow.add_node(\"oracle\", call_model)\nworkflow.set_entry_point(\"oracle\")\nworkflow.set_finish_point(\"oracle\")\n\ngraph = workflow.compile()\n\n# Create a FastAPI app\napp = FastAPI()\n\n# Integrate LangGraph with FastAPI using ag-ui-langgraph\n# The endpoint will be available at /agent\nadd_langgraph_fastapi_endpoint(app, graph, \"/agent\")\n\n# To run this:\n# 1. Save as, e.g., main.py\n# 2. pip install 'fastapi[all]' uvicorn ag-ui-langgraph langchain-openai langgraph\n# 3. uvicorn main:app --reload --port 8000\n# 4. Access http://localhost:8000/agent with a compatible AG-UI frontend\n#    or use curl:\n#    curl -X POST \"http://localhost:8000/agent\" \\\n#      -H \"Content-Type: application/json\" \\\n#      -d '{ \"thread_id\": \"test_thread_123\", \"messages\": [{ \"role\": \"user\", \"content\": \"Hello!\" }] }'","lang":"python","description":"This quickstart demonstrates how to expose a simple LangGraph agent as a FastAPI endpoint using `ag-ui-langgraph`. It defines a basic `StateGraph` with a single node that calls an OpenAI model, then integrates it into a FastAPI application, ready to serve AG-UI compatible requests."},"warnings":[{"fix":"Monitor official GitHub for updates. Consider patching locally or downgrading `pydantic` if warnings are disruptive and do not indicate a critical issue. Keep `langchain-core` updated to v1.x or higher as recommended by `langsmith` security patches.","message":"The `ag-ui-langgraph` adapter has been observed to throw warnings related to deprecated functions from `Pydantic` and `LangGraph` versions. While not always breaking, this can create noise in logs.","severity":"gotcha","affected_versions":"All versions, particularly when `langchain-core` or `pydantic` update their APIs."},{"fix":"Implement a factory pattern where `add_langgraph_fastapi_endpoint` accepts a function that returns a *fresh* agent instance for each request, rather than a shared singleton. Alternatively, refactor the `LangGraphAgent` to pass `active_run` as a local variable or via `contextvars` for true thread-safety.","message":"Concurrent requests to an endpoint created with `add_langgraph_fastapi_endpoint` can lead to state corruption. This is due to `LangGraphAgent` storing per-request state in a shared `self.active_run` instance variable, leading to interleaving and corrupted state when multiple requests hit the same singleton agent instance.","severity":"breaking","affected_versions":"All versions up to 0.0.25 (and likely current versions if not addressed)."},{"fix":"Apply a fallback when retrieving `tool_call_name`, using `tool_msg.name or event.get(\"name\", \"\")` to ensure a valid string is always provided to `ToolCallStartEvent`.","message":"When one LangGraph agent calls another as a tool (agent-to-agent communication), the `ToolMessage.name` can be `None`, causing a `Pydantic validation error` in `ToolCallStartEvent` and crashing the Server-Sent Events (SSE) stream.","severity":"gotcha","affected_versions":"Versions up to 0.0.25 (and potentially later if not patched)."},{"fix":"Update `ag-ui-langgraph` and related `langchain` packages to use `@langchain/core ^1.1.0` or higher, which requires `langsmith >= 0.5.0`. This may require manually overriding package manager dependencies if the direct dependency is not updated.","message":"Older versions of `ag-ui-langgraph` might depend on `@langchain/core ^0.3.80`, which transitively pulls in `langsmith < 0.4.6`. This older `langsmith` version is affected by `CVE-2026-25528` (SSRF via tracing header injection).","severity":"breaking","affected_versions":"Versions depending on `langchain-core` 0.3.x."}],"env_vars":null,"search_vec":"'0.0.33':59 'activ':67 'ag':2,7,25,90 'ag-ui':1,24,89 'ag-ui-langgraph':6 'agent':21,45,81 'ai':44,80 'ai-ag':79 'align':74 'appear':62 'applic':39 'cadenc':69 'communic':36 'comprehens':17 'current':56 'develop':77 'driven':35,94 'enabl':31 'event':34,93 'event-driven':33,92 'facilit':46 'fastapi':88 'frequent':71 'frontend':38,83 'frontend-integr':82 'integr':5,18,84 'interact':23,51 'langchain/langgraph':76 'langgraph':4,9,29,42,78 'langgraph-pow':41 'librari':13 'power':43 'protocol':27 'provid':15 'python':12 'real':48,86 'real-tim':47,85 'relat':66 'releas':68 'standard':32 'state':53 'stream':50 'synchron':54 'time':49,87 'ui':3,8,26,91 'updat':72 'user':22 'version':57","created_at":"2026-04-16T16:58:31.021558+00:00","updated_at":"2026-04-16T16:58:31.021558+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmpnjspuq3i/venv/lib/python3.12/site-packages/ag_ui_langgraph/__init__.py\", line 20, in <module>\n    from .endpoint import add_langgraph_fastapi_endpoint\n  File \"/tmp/tmpnjspuq3i/venv/lib/python3.12/site-packages/"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.0.41","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/ag-ui-langgraph/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["llm-agents","ai-ml","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}