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.
Save the following as langgraph_agent.py. After the Install step, start it with python langgraph_agent.py. Later snippets are alternatives or fragments using the same imports.
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
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
Serve a compiled LangGraph through AgentOS.
Standalone usage
Call the agent directly with .run() and .print_response().
Graphs with tools
Tool nodes that surface as Agno tool events.
Sessions
Resume conversations across runs with session_id.
Time travel
Replay and fork runs from LangGraph checkpoints.