Install & Compatibility
Where this runs
tested against v0.0.41 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.9
✕ build_error
✕ build_error
77MB installed
● package 77MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
LangGraphAgent
✓ from ag_ui_langgraph import LangGraphAgent
✗ from ag_ui_langgraph import LangGraphAgent
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.
import os
from fastapi import FastAPI
from langgraph.graph import StateGraph, MessagesState
from langchain_openai import ChatOpenAI
from langchain_core.messages import HumanMessage, AIMessage
from ag_ui_langgraph import add_langgraph_fastapi_endpoint
# Ensure OPENAI_API_KEY is set in your environment
os.environ['OPENAI_API_KEY'] = os.environ.get('OPENAI_API_KEY', 'your_openai_api_key_here')
# Define your LangGraph workflow
class AgentState(MessagesState):
pass
def call_model(state):
messages = state['messages']
model = ChatOpenAI(model="gpt-4o-mini") # Using a cost-effective model for quickstart
response = model.invoke(messages)
return {"messages": [response]}
workflow = StateGraph(AgentState)
workflow.add_node("oracle", call_model)
workflow.set_entry_point("oracle")
workflow.set_finish_point("oracle")
graph = workflow.compile()
# Create a FastAPI app
app = FastAPI()
# Integrate LangGraph with FastAPI using ag-ui-langgraph
# The endpoint will be available at /agent
add_langgraph_fastapi_endpoint(app, graph, "/agent")
# To run this:
# 1. Save as, e.g., main.py
# 2. pip install 'fastapi[all]' uvicorn ag-ui-langgraph langchain-openai langgraph
# 3. uvicorn main:app --reload --port 8000
# 4. Access http://localhost:8000/agent with a compatible AG-UI frontend
# or use curl:
# curl -X POST "http://localhost:8000/agent" \
# -H "Content-Type: application/json" \
# -d '{ "thread_id": "test_thread_123", "messages": [{ "role": "user", "content": "Hello!" }] }'
Debug
Known issues
gotchaThe `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.fixMonitor 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.
affects: All versions, particularly when `langchain-core` or `pydantic` update their APIs.
breakingConcurrent 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.fixImplement 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.
affects: All versions up to 0.0.25 (and likely current versions if not addressed).
gotchaWhen 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.fixApply 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`. affects: Versions up to 0.0.25 (and potentially later if not patched).
breakingOlder 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).fixUpdate `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.
affects: Versions depending on `langchain-core` 0.3.x.
Upgrade
Version history
0.0.41latest on PyPI · released Jun 9, 2026
Audit
Dependencies
langgraphrequiredCore dependency for defining agent workflows.
langchain-corerequiredFoundational LangChain components.
langchainrequiredUsed for various LangChain utilities and integrations.
pydanticrequiredData validation and settings management, with some noted deprecation warnings.
ag-ui-protocolrequiredDefines the core AG-UI event types and structures.