> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# LangGraph

> Wrap a compiled LangGraph graph as an AgentOS agent.

`LangGraphAgent` wraps a compiled LangGraph graph so it can be served through AgentOS or used standalone.

```python theme={null}
from agno.agents.langgraph import LangGraphAgent
from agno.db.sqlite import SqliteDb
from agno.os import AgentOS
from langchain_openai import ChatOpenAI
from langgraph.graph import MessagesState, StateGraph


def chatbot(state: MessagesState):
    return {"messages": [ChatOpenAI(model="gpt-5.4").invoke(state["messages"])]}


graph = StateGraph(MessagesState)
graph.add_node("chatbot", chatbot)
graph.set_entry_point("chatbot")
compiled = graph.compile()

agent = LangGraphAgent(
    name="LangGraph Chatbot",
    graph=compiled,
)

agent_os = AgentOS(
    agents=[agent],
    tracing=True,
    db=SqliteDb(db_file="tmp/agentos.db"),
)
app = agent_os.get_app()

if __name__ == "__main__":
    agent_os.serve(app="langgraph_agent:app", reload=True)
```

## Install

```bash theme={null}
uv pip install "agno[os]" langgraph langchain-openai
export OPENAI_API_KEY=sk-...
```

## Parameters

| Parameter | Type | Default | Description |
| - | - | - | - |
| `name` | `str` | `None` | Display name for the agent. |
| `id` | `str` | `None` | Unique identifier. Auto-generated from `name` if unset. |
| `graph` | `CompiledGraph` | `None` | Compiled LangGraph graph (`graph.compile()`). |
| `input_key` | `str` | `"messages"` | Key in the graph state used for input messages. |
| `output_key` | `str` | `"messages"` | Key in the graph state used for output messages. |
| `config` | `Dict[str, Any]` | `None` | Optional LangGraph config dict passed to `invoke` / `stream`. |
| `db` | `BaseDb` | `None` | Database for session persistence. |

## Examples

> **[AgentOS deployment](https://github.com/agno-agi/agno/blob/main/cookbook/frameworks/00_quickstart/langgraph_agent.py)**
>
> Serve a compiled LangGraph through AgentOS.

> **[Standalone usage](https://github.com/agno-agi/agno/blob/main/cookbook/frameworks/langgraph/langgraph_basic.py)**
>
> Call the agent directly with `.run()` and `.print_response()`.

> **[Graphs with tools](https://github.com/agno-agi/agno/blob/main/cookbook/frameworks/langgraph/langgraph_tools.py)**
>
> Tool nodes that surface as Agno tool events.

> **[Sessions](https://github.com/agno-agi/agno/blob/main/cookbook/frameworks/langgraph/langgraph_session.py)**
>
> Resume conversations across runs with `session_id`.

> **[Time travel](https://github.com/agno-agi/agno/blob/main/cookbook/frameworks/langgraph/langgraph_time_travel.py)**
>
> Replay and fork runs from LangGraph checkpoints.

## Developer Resources

* [Cookbook examples](https://github.com/agno-agi/agno/tree/main/cookbook/frameworks/langgraph)
* [LangGraph documentation](https://langchain-ai.github.io/langgraph/)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.