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

ParameterTypeDefaultDescription
namestrNoneDisplay name for the agent.
idstrNoneUnique identifier. Auto-generated from name if unset.
graphCompiledGraphNoneCompiled LangGraph graph (graph.compile()).
input_keystr"messages"Key in the graph state used for input messages.
output_keystr"messages"Key in the graph state used for output messages.
configDict[str, Any]NoneOptional LangGraph config dict passed to invoke / stream.
dbBaseDbNoneDatabase for session persistence.

Examples

Developer Resources