LangGraph is a framework from the LangChain team for building AI agents as explicit state graphs rather than linear prompt chains. Instead of a fixed sequence of steps, you define nodes (units of work, often LLM calls or tool calls) and edges (including conditional branches and loops) so the agent can retry, backtrack, or pause for human approval. It sits at #13 among trending AI tags at roughly 3% usage share, reflecting the shift from simple chatbots toward more controllable, production-grade agent systems.
A LangGraph agent is defined as a StateGraph β you add nodes (functions) and edges (the flow between them), then compile it into a runnable graph.
from langgraph.graph import StateGraph, END
from typing import TypedDict
class AgentState(TypedDict):
question: str
answer: str
def answer_node(state: AgentState) -> AgentState:
state["answer"] = llm.invoke(state["question"])
return state
graph = StateGraph(AgentState)
graph.add_node("answer", answer_node)
graph.set_entry_point("answer")
graph.add_edge("answer", END)
app = graph.compile()
result = app.invoke({"question": "What is LangGraph?"})
Install the package alongside LangChain and any LLM integration, then build your first graph.
# install LangGraph and a model integration
pip install langgraph langchain-openai
# then define a StateGraph, add nodes/edges, and call .compile().invoke()