Skip to content

AI agents 8 min read

LangGraph: when a Python script is no longer enough

An agent chaining twelve steps over three days isn't a loop around a model call. What LangGraph actually adds, and when it's overkill.

Most of the agents you come across in businesses are loops: call a model, look at the answer, call a tool, call the model again. As long as the process lasts a few seconds and fits inside one execution, that is entirely sufficient, and any framework would be over-engineering.

The problem shows up when the process stretches out. A file that stays open six weeks, a human approval that arrives the next day, a step that fails because an API is down. At that point the loop no longer holds — and that is LangGraph’s territory.

The four questions a script cannot answer

Where exactly has Mr Muller’s file got to? A running script keeps its state in memory. If nobody asks it, nobody knows. And if the process is stopped, the information is gone.

What happens if step seven fails? In a script the exception propagates and everything halts. Resuming means redoing everything from the start, including the six steps that had succeeded — with the inference cost that implies, and sometimes duplicated side effects.

How do you wait for an approval that will come tomorrow? A script that waits consumes a resource to do nothing. Working around it with a queue and a second script amounts to reimplementing a workflow engine, badly.

Why was this decision taken? Six months later, facing an unhappy client or an inspection, you need to be able to show the reasoning. A script leaves log lines, not a usable trail.

What LangGraph changes

LangGraph describes the process as a graph: nodes, conditional transitions, and a state travelling from one to the next. Three practical consequences.

State is saved at every node

That isn’t an implementation detail, it is what makes the rest possible. State is persisted to a database — PostgreSQL in our deployments — after every step. A server restart, an update or a network incident doesn’t lose the thread.

The design work in fact consists mostly of deciding what that state contains: what the system must remember between steps, what it can forget, and what must survive a restart. That choice is what determines whether the system can be resumed at all.

Execution can pause and resume

A node can suspend the graph, notify a person, and wait. Waiting consumes nothing: the graph is in the database, not in memory. It can last three minutes or three weeks.

That is the mechanism that lets you place human approvals exactly where they matter, without degrading the rest. In processes carrying professional liability, it is the only honest way to do it.

Every run is traceable

Every pass through every node is recorded with its inputs and outputs. A run can be replayed, the branch taken can be understood, and it can be shown to someone.

An example that genuinely justifies the graph

An accountancy practice, on document collection. Three hundred client files, a monthly cycle, staggered chasing.

The graph starts for each file at the beginning of the month and loads the list of expected documents. It compares that against what has arrived, identifies the gaps and drafts a chase adapted to the client’s history. The accountant approves in one click — the graph pauses until they answer.

When a document arrives, the graph resumes exactly where it stopped, files it, updates the state and recalculates what is still missing. After three chases with no reply, it escalates to the portfolio manager with the full history.

A file can stay open six weeks, survive a server restart and a dependency update, and never lose the thread. A script would have had to be relaunched by hand after every incident — and nobody would have known which ones to restart.

When it is overkill

LangGraph costs design time. Modelling a process properly takes one to two weeks before the first line of code, and that phase cannot be compressed: that is where the value is.

If your process fits in one execution of a few seconds, if there is no deferred human approval, and if nobody will ever ask you to justify a decision, a well-written Python script will do the job for a tenth of the effort. We say so regularly during scoping, and it is one of the rare moments when we are pleased to sell less.

The switch happens on three signals: the process outlasts a single execution, a person has to intervene partway through, or traceability is a requirement rather than a comfort. Any one of the three is enough.

And the lock-in question?

It comes up often and it is fair. LangGraph is open source and runs on your infrastructure. The nodes are ordinary Python: your API calls, your database queries, your business rules. The framework orchestrates, it does not take ownership of your logic.

If you wanted to move away, what you would rewrite is the orchestration — the skeleton — not the content of the steps. That is a real cost but a bounded one, and nothing like a closed platform hosting your process on its own servers.

Let's talk

Got a concrete case for us?

Describe the process that costs you most. We'll come back with what an agent could take over, what is better handled by a plain automation, and what should be left alone.

Your choices

Cookies & privacy

You can accept, refuse or change optional tracking. Your choice is kept for six months on this browser.

No analytics or advertising tool is currently enabled.

Read the privacy policy →