What is LangGraph?

LangGraph is a framework for building stateful, multi-step AI workflows and AI agents that can make decisions, execute tools, maintain state, and control their execution flow.

It is part of the LangChain ecosystem and is designed for applications where AI needs to do more than simply receive a prompt and return an answer.

For example, you could build an AI banking agent that:

  • Understands a customer’s request.
  • Decides which API to call.
  • Retrieves account or transaction information.
  • Performs calculations.
  • Decides whether another action is required.
  • Requests human approval for sensitive actions.
  • Continues execution and generates a final response.

LangGraph lets you define these workflows as a graph of nodes, edges, state, and conditional transitions.

1. Why do we need LangGraph?

With a simple LLM application, the flow is usually straightforward:

But real-world AI applications can have much more complicated flows.

For example, a banking AI assistant receives:

Transfer ₹5,000 to Rahul.

The application might need to:

  1. Understand the transfer request.
  2. Identify the recipient.
  3. Verify the recipient account.
  4. Check the customer’s balance.
  5. Validate transfer limits.
  6. Ask for customer confirmation.
  7. Execute the transaction.
  8. Verify the transaction result.
  9. Return a response.

This is no longer just a prompt and an LLM call. It is a workflow with decisions, multiple steps, state, and potentially loops.

Features - LangGraph4j
一文彻底说清:企业级Human-in-the-Loop AI Agent系统架构与实践!看到就是赚到!!_人工智能_datian1234-ModelEngine社区
Using Function Tools with Human-in-the-Loop Approvals | by Sai Nitesh Palamakula | Medium

LangGraph is designed to manage this kind of complex AI workflow.

2. Core concepts of LangGraph

LangGraph is built around five important concepts.

1. Nodes

Nodes are the individual steps of your workflow. Each node executes a task, such as calling an LLM, invoking an API, validating data, or processing a result.

2. Edges

Edges connect nodes and define where execution goes next. They can represent fixed transitions or conditional routing.

3. State

State is shared information carried across workflow steps. Nodes can read and update it, allowing the application to keep track of the question, tool results, decisions, and progress.

4. Conditional Edges

Conditional edges decide which node should execute next based on the current state or output.

5. Graph Execution

The graph executes the workflow, including branching, looping, pausing, resuming, and completing tasks.

3. LangGraph architecture

A graph is composed of nodes and edges.

How this graph works

ComponentResponsibility
StartBegins workflow execution
Understand RequestProcesses the user request
LLM DecisionDecides the next step
Conditional EdgeSelects the execution path
Execute ToolCalls an API or function
Update StateStores results from the tool
LoopSends results back to the LLM for another decision
Generate ResponseCreates final answer
EndCompletes the workflow

The key feature is the loop. After a tool executes, the graph can send the results back to the LLM. The LLM may decide to call another tool, or it may decide it has enough information to answer.

4. What is State in LangGraph?

State is one of the most important concepts in LangGraph.

Imagine the AI agent is processing the following request:

What is my account balance, and how much did I spend on groceries last month?

During execution, the state may contain:

{
“user_question”: “What is my balance and grocery spending?”,
“account_balance”: null,
“transactions”: [],
“grocery_total”: null,
“next_action”: null,
“final_answer”: null
}

The state allows different nodes to share information without having to manually pass every value through a separate chain of arguments.

5. How LangGraph handles decisions and loops

This is where LangGraph becomes powerful.

Suppose the customer asks:

Check my balance and my last 5 transactions.

The AI Agent can decide which tools it needs.

The LLM can determine what action is required, while LangGraph manages execution, transitions, and state updates.

Unlike a traditional fixed chain, a graph can revisit nodes, branch into different paths, and end when its completion condition is met.

6. Human-in-the-loop

LangGraph can pause a workflow and wait for human input before continuing.

This is especially important for banking, financial, healthcare, and enterprise applications.

For example:

Transfer ₹50,000 to Rahul.

The workflow can validate the transfer and then pause for approval before executing the payment.

Human approval can help prevent an agent from automatically executing high-impact actions without proper authorization.

LangGraph supports interrupting workflows, persisting state, and resuming after human input.

7. Persistence and Checkpointing

A normal program often loses its in-memory workflow state when it stops.

LangGraph can use checkpointers to save graph state at execution steps.

This helps support:

  • Resuming interrupted workflows
  • Recovering after failures
  • Persistent conversations
  • Long-running tasks
  • Human approval workflows
  • Tracking workflow progress
How LangGraph's Checkpointer Revolutionizes AI Workflows | SWAPNANIL SHARMAH ~ GenAI and Machine Learning Engineer posted on the topic | LinkedIn
LangGraph State, Checkpointing, and Resumable Agents | TURION.AI
LangGraph と Amazon DynamoDB で耐久性のある AI エージェントを構築する | Amazon Web Services ブログ

Example:

A customer starts a loan application.

  1. AI collects customer details.
  2. AI validates documents.
  3. Workflow saves state.
  4. Application waits for a missing document.
  5. Customer uploads it hours later.
  6. Workflow resumes from its saved state.

The application doesn’t necessarily need to restart the entire workflow from the beginning.

8. Simple LangGraph code example

Let’s build a very simple graph with two nodes.

Workflow:

Start → Greeting Node → Response Node → End

from typing import TypedDict
from langgraph.graph import StateGraph, START, END

# 1. Define shared state

class ChatState(TypedDict):
message: str
response: str

# 2. Define a node

def greeting_node(state: ChatState):
return {
“response”: f”Hello! You said: {state[‘message’]}”
}

# 3. Create graph
builder = StateGraph(ChatState)

#4. Add nodes
builder.add_node(“greeting”, greeting_node)

# 5. Define edges
builder.add_edge(START, “greeting”)
builder.add_edge(“greeting”, END)

# 6. Compile graph
graph = builder.compile()

#7. Execute graph
result = graph.invoke({
“message”: “What is LangGraph?”,
“response”: “”
})

print(result[“response”])

Output:

Hello! You said: What is LangGraph?

What happened internally?

StepCodeMeaning
1StateGraph(ChatState)Define graph state structure
2add_node()Register a workflow step
3add_edge()Define execution path
4STARTEntry point
5ENDExit point
6compile()Build an executable graph
7invoke()Execute the graph with initial state

This is the foundation of building more complex LangGraph applications.

9. LangChain vs LangGraph

This is the most important distinction to understand.

FeatureLangChainLangGraph
Primary purposeBuild LLM applicationsBuild stateful AI workflows and agents
StructureComponents and runnable pipelinesGraph-based execution
WorkflowOften sequential or composedBranching, looping, dynamic
State managementApplication / runnable contextExplicit graph state
Decision-makingCan integrate tools and agentsAdvanced agent workflow control
PersistenceIntegrations availableCheckpoint-based state persistence
Human approvalCan be implementedNative workflow interrupt patterns
Best suited forRAG, prompts, model integrationsComplex agents and multi-step processes

Simple way to remember

LangChain = Build the AI application using reusable AI components.

LangGraph = Control how the AI application thinks through tasks, moves between steps, makes decisions, and manages state.

LangGraph does not replace LangChain entirely. They complement each other, and LangGraph can use LangChain models, tools, prompts, and other integrations.

Write a Reply or Comment

Your email address will not be published.