AWS Builder Center

What Is LangGraph? A Beginner's Guide to AI Agents on Amazon Bedrock

LangGraph explained for developers new to the framework. Learn state, nodes, edges, routing, tools, RAG, memory, and human-in-the-loop using one real customer support agent project as the guide. You will utilize AWS Agent Toolkit to set up RAG for the Agent and build out the customer support agent in phases using LangGraph.

Developer Relations Engineer
LangGraph is a Python framework for building AI features that need more than one step. You define your app as a flowchart of boxes and arrows, and LangGraph runs it. Boxes call a model, look something up, do a thing, or wait for a human. Arrows decide what happens next, such as which node runs next or if its the end of the flow.
This post is the written companion to my video,  LangGraph for Beginners (with Bedrock)  , though you do not need to have watched it. If you are completely new to LangGraph and want to know how to get started with it, you are the reader I wrote this for. By the end you will understand the eight terms that gate the whole LangGraph ecosystem: state, nodes, edges, routing, tools, memory, human-in-the-loop, RAG. Then you get the prompts to build a real support agent on Amazon Bedrock.
Every code block below is quoted from a working app: a support agent for a fictional store called AnyCompany Hair Care. It answers product questions from the company's own docs, remembers the conversation, and refuses to issue a refund until a human approves.



What is LangGraph?

LangGraph is an open-source Python framework for building stateful, multi-step AI applications. Instead of one call to a model, you define a graph: a set of steps (nodes) and the connections between them (edges). LangGraph runs the graph, carries a shared piece of data (state) from step to step, saves progress so a conversation can resume, and pauses mid-run when it needs a human. The LangChain team maintains it, and their docs call it a low-level orchestration framework for long-running, stateful agents ( LangGraph overview ).
Basically, think of it as a flowchart for LLMs to run with their AI capabilities. You get to define how they run and move through the flowchart and what information they carry along the way as they run.

Why should a developer learn LangGraph?

Three reasons, in the order that will matter to you.
It turns "I can call an API" into "I can build a product." Calling a model is a fetch request. Building what a business pays for means handling a refund policy, a live order lookup, an approval step, and a conversation that remembers two messages ago.
It shows up on job posts. "Build agents" is a common line in AI engineering listings, and LangGraph is one of the most widely used open-source frameworks for it, with Klarna, Replit, and Elastic among the users its docs name ( LangGraph README ).
The business case writes itself. Published industry estimates put an AI-resolved support ticket between $0.50 and $2.00, against roughly $6.00 to $13.50 for one a human handles ( Fin.ai ). Apply the skepticism any vendor-published number deserves and the shape survives: routine tickets are cheap to automate and they never stop arriving.



What is LangChain, and when do you use LangGraph instead?

LangChain is the library of building blocks. LangGraph is the framework that orchestrates them. LangChain gives you a consistent way to talk to models, define tools, load documents, and parse output, so swapping Claude for Llama does not mean rewriting your app. LangGraph decides which of those blocks runs, in what order, and what happens when a step needs to repeat or pause.
You use both. In this app,  langchain-aws  provides the Bedrock model client and the  @tool  decorator while  langgraph  provides the graph, and they meet on the same line of code.
Reach for LangGraph when the workflow has multiple steps, something has to decide what happens next, you need memory across turns, a human has to approve something, or you need retries and resumability. Skip it when the app is prompt in, response out. For a "summarize this text" endpoint, LangGraph is overhead you don't need.



Fundamental LangGraph Concepts in Metaphors

Put the code down for a minute and think about calling your bank. Someone picks up, and that first person is the receptionist.
  • "What are your hours today?" They answer directly. No transfer.
  • "I want to open a credit card." They route you to a specialist who pulls the offers you qualify for and opens the account.
  • "There's a charge I don't recognize." Same receptionist, completely different path: the fraud team, where a specialist freezes the card and reverses the charge.
Simple questions get handled up front. Anything specialized gets routed to whoever has the right knowledge, the right tools, and the authority to act.
You would not want one receptionist doing all of it. They would need every product manual, credentials for every internal system, and the authority to move money out of your account. That is not a job description. That is an incident report.
AI agents have a name for the same failure: context overload. Give one model too much information and too many tools, and its accuracy drops. Focused specialists stay sharper. That phone call maps onto LangGraph almost one to one.
The difference between those three calls is who you end up talking to and what they are allowed to do.
"What are your hours today?" The receptionist answers and the call ends. One person, one job, no transfer. That person is a node: a single step that does one job and hands back a result. The call ending is an edge, the arrow that says what comes next, and this one always points at the exit.
"I want to open a credit card." The receptionist decides you need a specialist and transfers you. Deciding who gets the call is routing: an arrow with a decision behind it instead of a fixed destination. The specialist does not recite rates from memory. They pull up the current product sheet and read you what it says, which is RAG: answer from the document in front of you, not from recall. Then they open the account in the bank's system, and that system is a tool, something they are authorized to operate that sits outside their own knowledge. Notice the shape of that conversation. They check something, come back with a question, check again. Several round trips with the same person before anything gets opened, which in a graph is an arrow pointing backwards, and it is the reason a flowchart beats a straight script.
"There's a charge I don't recognize." Same receptionist, different transfer. The fraud specialist freezes your card on the spot, another tool, then hits the one thing they cannot do alone: reversing the charge needs a supervisor. They put you on hold, walk the request over, and come back with a yes or a no. That hold is human-in-the-loop. The work stops mid-flow, waits for a person with the authority, then resumes from the same place. Money moves only after the supervisor signs off.
Both specialists read the notes the receptionist logged, so you never repeat your account number, and your file is still there when you call back tomorrow. The notes are state. The file surviving the hang-up is memory.
Seven words, one phone call. The support agent you build in this post has the same shape: a receptionist that sorts the message, specialists with their own documents and their own tools, notes that carry between turns, and one place where a human has to say yes before money moves.



Hands-on: build the agent yourself

Everything above is vocabulary. Now you build the thing, in four phases, each one a single prompt to an AI coding assistant.

What you need

What
Why
An AI coding assistant
It writes the boilerplate so your attention goes to the graph. I used
 Kiro 
. The prompts below work the same in Claude Code, Cursor, or Codex.
The starter code repo
 The AnyCompany Hair Care storefront 
: a working store with a chat widget wired to nothing.
Python 3.10 or newer
The backend is Python. I built and verified this on 3.12.12.
An AWS account
The model and the knowledge base both live on Amazon Bedrock. You will need
 Claude Sonnet access enabled 
in one region, and everything else has to stay in that same region.
The Agent Toolkit for AWS
Gives your assistant today's AWS docs and validated setup procedures instead of whatever it remembers. Setup takes about five minutes:
 Setting up the Agent Toolkit for AWS in Kiro, Codex, Claude Code, and Cursor 
.
The mastering-langgraph agent skill
Gives your assistant validated LangGraph patterns and the specific mistakes assistants make with this framework.
 Install it here 
, then name it in every prompt.
Set an  AWS Budget  before you write a line of code. An agent loops, and a loop pointed at a paid model is how a small bug becomes a large invoice.

Get the storefront running

Clone the repo and follow the README, which walks the setup end to end: the virtual environment, the pinned dependencies,  .env , and serving the site. Give it ten minutes and come back with a store open in your browser. That README is also the long-form version of the four phases below, with the complete  backend/app.py  and a troubleshooting section.
What you are cloning:
  •  index.html ,  styles.css ,  app.js : the storefront and its support chat widget
  •  knowledge-base/ : eleven markdown files. Eight product docs, an FAQ, a hair-type guide, and the current discount. These become your RAG source in Phase 2.
  •  backend/store.py : a thin data-access layer over the order data, written for you so you spend your time on the graph instead of plumbing
  •  backend/mock_data/orders.json : three demo orders.  AC-1001  is refund-eligible,  AC-1002  is outside the 30-day window,  AC-1003  is already refunded.
  •  backend/requirements.txt : pinned versions, so a newer LangGraph release cannot break your build mid-tutorial
  •  backend/.env.example : copy to  .env , then fill in your model id, region, and later your Knowledge Base id. Or better yet, ask your AI coding assistant to update that file for you once you've used AWS Agent toolkit to set up the app with a model and uploaded documents to knowledge base on Bedrock.

Why those last two prerequisites are on the list

Your assistant's knowledge has a cutoff date, and AWS and LangGraph both ship changes weekly. So it hands you a retired model id with total confidence and no warning, and you spend twenty minutes in the IAM console on what turns out to be a naming problem. Current Anthropic models on Bedrock need a cross-region inference profile id, the  us.  prefixed form, and the error you get from the bare id reads exactly like a permissions failure. The knowledge base has the same shape of trap: embedding models get deprecated, and the S3 Vectors index needs two specific metadata keys set at creation or ingestion fails later with an error that points nowhere near the cause. The  Agent Toolkit for AWS  hands your assistant the current docs and the validated procedure for both jobs. The setup guide linked above takes five minutes, and there is  a video version  if you would rather watch it.
The mastering-langgraph skill does the same job for the framework half. Left to memory, assistants reach for patterns that were current two versions ago, and they make the same three mistakes over and over: the missing  add_messages  reducer, forgetting to compile the graph, and losing the  thread_id  so memory silently stops working. The skill carries the validated patterns and those traps. Name it at the start of every prompt below so your assistant loads it instead of improvising.

There is no backend yet

Once the storefront is running, click the chat bubble and send a message. You get a polite placeholder, because  app.js  line 19 says  const CHAT_API_URL = null;  and there is no  backend/app.py  to point it at. The store is real, the widget is real, and nothing is behind it. That empty file is the whole exercise.

Phase 1: get a reply out of the widget

One node, one model, no tools. The point is to see a graph run before it gets complicated.
Using the mastering-langgraph skill, build a LangGraph backend in backend/app.py that
connects this project's chat widget to a Claude Sonnet model on Bedrock and streams
general replies. No tools or retrieval yet, wire app.js up to it, and add four cost
guardrails: a max length on the request, an explicit max_tokens, trimmed history, and a
recursion_limit.
Those four caps are the part worth understanding rather than copying. A max length on the request rejects a pasted novel with an HTTP 422 before a token is billed. An explicit  max_tokens  stops Bedrock reserving the model's full output capacity against your per-minute quota, which throttles an app whose only user is you. Trimming the history bounds the transcript you resend each turn, because with a checkpointer it grows forever. And  recursion_limit  caps steps per run: the  langgraph  default is 10,007, which is not a typo and not a cost guard.
When it works, "hi" comes back as a real streamed reply. Then ask it something real: "Is your Define Curl Cream safe for color-treated hair?" You get a confident, invented answer, ingredients and all. The model has never heard of AnyCompany Hair Care, so it fills the gap with fiction. That is the wall Phase 2 exists to fix.

Phase 2: build the knowledge base

Nothing changes in your code here. You are stocking the library.
Using the mastering-langgraph skill and the AWS Agent Toolkit, create an Amazon Bedrock
Knowledge Base from the markdown files in ./knowledge-base, in the same region as my
Bedrock model access, and put the id in backend/.env.
Worth knowing what your assistant is doing on your behalf. It uploads those eleven markdown files to S3, then Bedrock splits each one into chunks of a few hundred words and sends every chunk through an embedding model, which turns text into a list of numbers that encodes its meaning. Those vectors go into a vector store, and paragraphs that mean similar things end up close together in that space even when they share no words. Later, when the agent searches "safe for color-treated hair," Bedrock embeds the question the same way and returns the nearest chunks, which is how you get a paragraph that only ever says "won't strip your dye." Ask your assistant to run a retrieval test before moving on, and to write down what it created so you can tear it down later.

Phase 3: give the agent the library and the tools to read it

Using the mastering-langgraph skill, add a LangGraph tool that searches my Bedrock
Knowledge Base, and loop the graph so the agent searches before it answers product
questions instead of guessing.
This is the first thing that needs a graph rather than a script. The agent asks for a search, a tool node runs it, an arrow points back, and the agent reads the result and can search again. Ask the same Define Curl Cream question afterwards and the answer comes from your own markdown, with the price from your own file.

Phase 4: orders and the refund gate

Using the mastering-langgraph skill, add intent routing to a returns specialist with
tools over backend/store.py for order lookup and the 30-day policy, and a
human-in-the-loop gate so a refund is only applied after a manager approves it.
This is the phase where a one-liner stops being enough. Routing, a returns procedure, and an approval gate have too many interacting parts, so if your assistant has a planning mode (Kiro calls it spec mode), use it here and read the design before you accept any code. The README carries the full prompt with the correctness properties spelled out, including the one that matters most: the agent gets a tool that requests a refund and never one that issues a refund.
When you get there,  my finished version is here . Diff it against yours.

One more prompt: make your assistant teach you

Walk me through the graph you just built. For each node, tell me which of the four kinds
of work it is (LLM, data, action, user input), what it reads from state, what it writes
back, and which edges lead in and out. Then show me the graph as a mermaid diagram.
Read that answer with your own code open beside it. Highest-return ten minutes in the build.

Before you ship it

What you build is a teaching app with the gaps a teaching app tends to have. The big one:  /chat  and  /resume  have no authentication and CORS is  allow_origins=["*"] . Fine on localhost, a real problem the moment you deploy, because  /resume  is the manager approval endpoint. Anyone who learns a  thread_id  can approve their own refund, which is a business model, though not one you want. The README lists every fix.



Reading the code: state, nodes, edges, and the builder

Those four prompts leave you with a few hundred lines of Python. Four things in that file are worth recognizing, because they are the same four things in every LangGraph app you will open. Every snippet below comes from the finished AnyCompany agent.

State: the notes, in code

The notes the receptionist logged are a  TypedDict : a plain Python dictionary with the key names and their types written down. LangGraph hands it to every step and merges whatever each step gives back.
class AgentState(TypedDict):
# `add_messages` appends and reconciles messages by id — right for a chat
# transcript mixing AI, human, and tool messages.
messages: Annotated[list, add_messages]
iterations: int # per-turn LLM<->tool round-trip counter (guard)
intent: str # product_advice | returns | general
active_flow: str | None # "returns" while a refund conversation is open
Four fields, and reading them tells you what this agent needs to remember.  messages  is the transcript.  iterations  counts model-to-tool round trips this turn, so a confused model cannot loop forever.  intent  is the label the classifier picked.  active_flow  remembers that a refund conversation is open.
 Annotated[list, add_messages]  is where most beginners lose an afternoon. Every node returns a dict of updates, and by default a returned value replaces whatever was in that field. For a counter that is right:  iterations: 3  should overwrite  iterations: 2 . For a transcript it is a disaster, because each node should add to the conversation instead of clobbering it.
A reducer tells LangGraph how to merge a new value with the existing one.  Annotated[list, add_messages]  says "this field is a list, and when a node returns messages, merge them with  add_messages  instead of replacing." That reducer appends, and matches messages by id so a re-sent message does not duplicate.
Leave it off and your agent develops amnesia inside a single turn, because every node cheerfully overwrites the one before it. The bug looks like the model ignoring you. It is one missing annotation.

Nodes: the boxes, one job each

A node is one step, and it is the only place that state ever gets written. In code it is a plain Python function that takes the state, does one job, and returns a dict of updates:
def general_response(state: AgentState) -> dict:
"""General lane: plain reply, no tools (history stripped of tool plumbing)."""
history = _text_only_history(state["messages"])
resp = llm.invoke([SystemMessage(content=GENERAL_PROMPT), *history])
return {"messages": [resp], "iterations": state.get("iterations", 0) + 1}
Three lines of body: take the state, pull out the conversation, call the model with a system prompt in front of it, hand back one message to append and a bumped counter. This node is the receptionist telling you the branch hours without transferring you anywhere.
Notice what it does not do. It does not decide what runs next, and it does not touch anything outside its return value. That constraint is what makes graphs testable: call the function with a dict, check the dict that comes back.
Deciding what deserves its own box is the real skill, and two questions settle it.
What kind of work is this step? There are four kinds, and if your step is one of them, it is a node.
Kind of work
What it does
Example in this app
LLM step
reasons or writes
 classify_intent ,  product_advisor 
Data step
looks something up
 product_tools  (searches the knowledge base)
Action step
changes something
applying the refund
User-input step
waits for a human
 human_approval 
Is there a boundary here? A boundary is a decision, a pause, or a loop. Wherever the answer is yes, cut a new box.

From a function to a node: registering it

Writing the function is only half the job. LangGraph does not know your function exists until you register it, and registering happens on a builder: one object that collects your whole flowchart before anything runs.
You create the builder once:
_builder = StateGraph(AgentState)
 StateGraph  is the class LangGraph gives you for this, imported from  langgraph.graph . You hand it  AgentState , the notepad from earlier, so it knows the shape of the data every step will read and write. What comes back is an empty canvas:  START ,  END , and nothing in between.
 _builder  is only a variable name. The leading underscore is a Python convention meaning "internal to this file." Call it  builder  or  workflow  and nothing changes.
Now register the function under a name:
_builder.add_node("general_response", general_response)
The first argument is a string, the label this step answers to inside the graph. The second is the function to run. From here on the graph refers to your step by that string, which is why a typo there becomes a runtime error rather than something your editor catches.
The node exists now, and it still never runs, because nothing points at it. Arrows are next.

Edges: the arrows, and the ones that decide

An edge is an arrow from one node to the next. You draw them on the same builder, and LangGraph has two kinds. Getting the difference straight is most of the framework.
A fixed edge always goes to the same place:
_builder.add_edge(START, "classify_intent") # FIXED edge: START always -> classify_intent
_builder.add_edge("general_response", END) # FIXED edge
 START  and  END  are built in. No logic, no decision, same path every time.
A conditional edge runs a small function that reads the state and returns the name of the next node:
def route_by_intent(
state: AgentState,
) -> Literal["product_advisor", "returns_agent", "general_response"]:
return {
"product_advice": "product_advisor",
"returns": "returns_agent",
"general": "general_response",
}.get(state.get("intent", "general"), "general_response")
A dictionary lookup with a default. It reads one field,  intent , and returns a node name as a string. If  intent  is missing or unrecognized,  .get()  falls back to  general_response , so an unexpected label degrades into a friendly reply instead of a crash.
This function is the receptionist deciding who to transfer you to. And it returns a string rather than a state update, which is the tell you can use forever: nodes return dicts, routers return node names.
Conditional edges also build loops, because an arrow can point backwards. A router named  product_should_continue  checks the model's last message: if it asked for a tool, return  "product_tools" , otherwise  "__end__"  (the string form of  END ). Pair that with a fixed edge pointing back and you have a cycle, so the model can search, read what came back, and go again inside one user turn. That router also caps  iterations , because without a cap a model that keeps rephrasing an unhelpful search will keep rephrasing it long after you have gone to bed.

The bank call, mapped

On the phone call
In LangGraph
In this app
Answering "what are your hours"
LLM node, no tools
 general_response 
Deciding who to transfer you to
conditional edge + router
 route_by_intent 
Credit card / fraud specialist
separate LLM nodes, own tools
 product_advisor  /  returns_agent 
The policy binder they read from
knowledge base (RAG)
Bedrock Knowledge Base + search tool
The system that reverses charges
tools
 lookup_order ,  request_refund 
Notes logged on your account
state
 AgentState 
Your file still being there tomorrow
checkpointer +  thread_id 
 InMemorySaver 
Supervisor sign-off before a refund
human-in-the-loop
 human_approval  +  interrupt() 
That table is the design. The wiring is what makes it run.



Building the graph

Four pieces are on the table: the state, the node functions, the routers that decide between them, and the builder that collects them all. Assembling it takes one block, and every arrow in the finished graph is one line of it.
_builder = StateGraph(AgentState)

# ---- Register the NODES (name -> the function that runs) ----
_builder.add_node("classify_intent", classify_intent)
_builder.add_node("product_advisor", product_advisor)
_builder.add_node("product_tools", product_tools)
_builder.add_node("returns_agent", returns_agent)
_builder.add_node("returns_tools", returns_tools)
_builder.add_node("human_approval", human_approval)
_builder.add_node("general_response", general_response)

# ---- Connect the NODES with EDGES ----
_builder.add_edge(START, "classify_intent") # FIXED edge: START always -> classify_intent
_builder.add_conditional_edges( # CONDITIONAL edge (router: route_by_intent)
"classify_intent",
route_by_intent,
["product_advisor", "returns_agent", "general_response"],
)
_builder.add_conditional_edges( # CONDITIONAL edge (router: product_should_continue)
"product_advisor", product_should_continue, ["product_tools", END]
)
_builder.add_edge("product_tools", "product_advisor") # FIXED edge (loop back)
_builder.add_conditional_edges( # CONDITIONAL edge (router: returns_should_continue)
"returns_agent", returns_should_continue, ["returns_tools", END]
)
_builder.add_conditional_edges( # CONDITIONAL edge (router: route_after_returns_tools)
"returns_tools", route_after_returns_tools, ["returns_agent", "human_approval"]
)
_builder.add_edge("human_approval", END) # FIXED edge
_builder.add_edge("general_response", END) # FIXED edge

# The checkpointer gives conversation memory AND is required for interrupt().
graph = _builder.compile(checkpointer=InMemorySaver())
You have met  StateGraph  and  add_node  already, so two things here are new.
 add_edge(a, b)  draws a fixed arrow.  add_conditional_edges(a, router, [destinations])  draws a fan-out: after node  a , run  router , jump to whichever name it returns. That final list declares the legal destinations, which documents the branch and lets LangGraph draw the diagram.
 compile()  turns the builder into something runnable, and forgetting it is the second most common beginner mistake, right behind the missing reducer. The  checkpointer  argument does double duty: it gives you memory, and  interrupt()  will not work without it, because pausing needs somewhere to save the paused state.
Seven nodes, four fixed edges, four conditional edges. That is the whole architecture.
Figure 2. The finished graph. Solid arrows are fixed edges. Dotted arrows are conditional edges, where a router reads state and picks the next node. Alt text: Flowchart. START flows to classify_intent, which branches three ways to product_advisor, returns_agent, and general_response. product_advisor loops with product_tools. returns_agent loops with returns_tools, which can branch to human_approval. All three lanes end at END.
Every box earned its place. Sorting a message by meaning is reasoning, so  classify_intent  is an LLM step. Its output is a label, and a label is a decision, so a conditional edge routes to one of three specialists. The product advisor cannot invent details and the returns agent cannot see orders, so each gets a tool node and an arrow looping back. And a refund moves money, so the returns agent never gets a "do the refund" tool. It gets one that requests a refund, and a router sends the flow to  human_approval , which freezes the graph until a manager decides.



Tools, RAG, memory, and the human gate

The last four words from the phone call, each with the code that makes it concrete.

Tools

A tool is a Python function the model is allowed to call. Write a normal function, decorate it, and the docstring becomes the instructions the model reads when it decides whether to use it:
@tool
def search_hair_care_knowledge(query: str) -> str:
"""Search AnyCompany Hair Care's knowledge base for grounded, accurate info.

Use this for ANY product, recommendation, or policy question before answering.
"""
return _kb_retrieve(query, num_results=4)
That docstring is not documentation for your teammates. The model reads it to pick a tool. Vague docstring, wrong tool.
Attach tools with  llm.bind_tools(PRODUCT_TOOLS) , which runs nothing: it tells the model which functions exist and how to ask for them. When the model wants one, its reply comes back carrying  tool_calls  instead of text, and a separate node runs them. That separation is why the tool loop needs two boxes rather than one.

RAG

Retrieval-augmented generation splits in two. Retrieval: find the relevant paragraphs in your own documents. Generation: the model writes the answer from them.
The retrieval half is an  Amazon Bedrock Knowledge Base . You hand it your markdown files, it splits them into chunks, and turns each chunk into an embedding: text converted into coordinates on a map of meaning. Paragraphs that mean similar things land near each other even when they share no words, which is why a search for "color-treated" finds a paragraph that only ever says "won't strip your dye."
The prompt matters as much as the tool. A model holding a search tool will still answer from memory now and then, so the system prompt has to say, in as many words, never invent product names or prices, and state only what the tool results contain.

Memory

Memory in LangGraph is a checkpointer plus a  thread_id , and that is the entire feature. The checkpointer saves a state snapshot after every step. The  thread_id  says which conversation a snapshot belongs to:
config = {"configurable": {"thread_id": thread_id}}
Send the same  thread_id  again and LangGraph loads that conversation's state before running. Send a new one and you get a blank slate. That is why "Are those safe for color-treated hair?" works as a follow-up: the word "those" carries no meaning by itself, and it resolves because the previous turn was reloaded under the same id.
 InMemorySaver  is a dict in your process, so a restart wipes every conversation. For anything real, swap in a Postgres or SQLite saver ( persistence docs ). The rest of your graph does not change, which is the point of the abstraction.

Human-in-the-loop

A refund moves money, and a language model does not get to move money unsupervised. The pattern generalizes to any risky action.
The agent never gets a tool that issues refunds. It gets one that asks, and that tool returns a signal,  PENDING_APPROVAL , rather than doing anything. A router watches for the signal and detours to  human_approval , where:
decision = interrupt( # payload abridged; the repo also passes customer and reason
{
"type": "refund_approval",
"order_number": order_number,
"amount": true_amount,
"question": f"Approve a refund of ${true_amount:.2f} for order {order_number}?",
}
)
 interrupt()  stops the entire graph run. This is a real suspension rather than a blocking wait: state gets checkpointed, the HTTP request finishes, and your process goes back to being idle. The payload becomes what the frontend renders as an approval panel. Later, possibly minutes later,  Command(resume=decision)  restarts the graph from that exact point and  interrupt()  returns the manager's answer ( human-in-the-loop docs ).
Three details separate a demo from something you would trust with money. The amount for the action is recomputed from the order store, never taken from the model's output, because a model's text should never become a financial parameter. Applying the refund is idempotent, since double-clicking Approve without that is a memorable way to learn what idempotent means. And the confirmation is written by code, so nobody is told "your refund is processed" because a model felt optimistic.



Go open the docs

Open the  LangGraph docs  right now.
State, nodes, edges, routing, tools, memory, human-in-the-loop, RAG. Every one of those words now points at something specific you have seen in code. That was the promise of this post, and the docs read well once the vocabulary lands.
Then go wire up that chat box.  Clone the starter , run the Phase 1 prompt, and get a reply out of the dead widget. That first streamed response is where this stops being reading.
If it works, tell me what you would point an agent at first. That is the part I am always curious about.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article