Want a quick email when a new article is published? Subscribe

What LangChain actually replaced in a real pipeline

6 min read • 9 Nov 2026

Part 2 of 3 of Who holds the loop?, a series that builds the same jobs with no framework, LangChain, LangGraph, Pydantic AI and the Claude Agent SDK, and compares them line by line.

ailangchainlanggraphpydantic aiframeworksllm

LangChain cut the code that calls the model from 19 lines to 8. The pipeline still got longer. If you’re weighing a framework for a job with a fixed set of steps, the useful question isn’t whether it saves lines, it’s which lines it saves and what it adds in their place.

The job here is turning a recording’s transcript into structured notes: classify the recording, fill in a schema for that type, render a document from a fixed template. I built it with no framework first, then with LangChain and LangGraph, then with Pydantic AI, then again with a pause for a person. All of them shared the same schemas, prompts and templates, so only the framework changed, and I counted lines by concern rather than in total. The first article in this series sets out the comparison and shows why consistent output comes from the schema whichever framework you use.

LangChain shrinks the plumbing and grows the structure

The LangChain version used LangChain for the model calls and LangGraph for the flow, plus one new branch: when the classifier’s confidence fell below 0.6, a stronger model gave a second opinion.

Some of it was a genuine saving. Calling the model went from 19 lines to 8, and switching the second opinion to a stronger model took one model name and nothing else. Retrying went from 16 lines to a single method call.

But the retry is worse. My hand-written version sent the model its own invalid answer along with the error and asked it to fix it. LangChain’s with_retry sends the identical request again. That helps with a network blip and does nothing for a bad answer.

The structure cost more, too. Wiring the steps went from 25 lines to 44, because LangGraph wants a declared state, each step wrapped as a node and the edges wired explicitly. In return, the routing shows up in a diagram LangGraph draws for you and in every trace. Tracing went from 17 lines to 25, because LangChain’s callback hooks fire for everything, including runs nested inside other runs, and you have to filter out the noise.

This figure is interactive and needs JavaScript. The text around it describes what it shows.

What each framework replaced, concern by concern. Open a row to compare the code.

The branch itself is four lines of plain Python:

c = classify(transcript)
if c.confidence < 0.6:
    c = classify(transcript, model=SECOND_MODEL)
data = extract(c.kind, transcript)

A graph is a heavy way to write an if. And the second opinion didn’t help: the stronger model agreed with the first, at about the same confidence, on a recording that was a few seconds of near-nonsense. The low score was correct. What that recording needed was a person, not a bigger model.

Temperature 0 is not a determinism switch

Setting temperature to 0 is supposed to make a model give the same answer every time. It doesn’t.

The first run called a 22-word clip a casual conversation at 0.40. Four identical requests afterwards, with no framework in between, all called it a meeting at around 0.5. A peer call between two professionals scored 0.55 on one run and 0.60 on the next, either side of my cut-off. I checked whether LangChain was sending something different: it wasn’t, the requests differed by one token.

So a fixed confidence threshold will flip on exactly the borderline cases you most want to catch. Treat a low score as “ask someone”, and expect the set of recordings that trigger it to change slightly from run to run.

Check meaning, not just shape

The Pydantic AI version came next. Pydantic AI comes from the team behind Pydantic, the Python validation library my schemas were already written in. It handles the model call and validation and leaves the flow to plain Python.

Its best feature showed up when I added a check that a schema can’t express. A schema can guarantee that a quote field contains text. It can’t guarantee that the text is something anyone said. So I added a plain-code check that every quote really appears in the transcript, allowing for punctuation and small slips. When a quote fails, Pydantic AI sends the model the reason and asks again, which is exactly the behaviour LangChain’s retry lacked.

The check earned its place. Across nine runs of a 6,000-word interview, four needed at least one extra call. In the case I traced fully, the model had joined two separate remarks into one quote with an ellipsis, which reads as something the speaker never said. An earlier run had smoothed out a stammer. For notes you might rely on months later, a quote that only sounds right is worse than no quote.

Tracing took five lines. Pydantic AI reports its model calls through OpenTelemetry, the industry standard for tracing, so the same data can go to whatever monitoring tool you already use.

For structured extraction, this was the framework I’d choose.

With one pause point, write it yourself

The last version is where LangGraph is supposed to shine: when the classifier is unsure, the run stops and asks me, the process exits, and later a fresh process picks up exactly where it stopped. LangGraph does this with a checkpointer, which saves the run’s state after every step, and an interrupt() call, which saves a question and stops. Three of the eight recordings paused, and I overruled the model on two of them. The peer call, for one, came back as a meeting, with an actions table and owners.

My first verdict was that LangGraph had replaced a save-and-resume system I’d otherwise have to build. I hadn’t built that system to check. When I did, the hand-written version simply wrote the classification and the question to a JSON file, and a separate command read it back and finished the run. It took 20 extra lines to LangGraph’s 11. But the whole flow, pause included, came to 35 lines by hand against 53 for LangGraph, and its save file was something I could open in a text editor. LangGraph’s checkpoints, by contrast, held the full state after every step: 177 KB for a single 5,600-word call, because LangGraph copied the transcript into each one.

With a single, known pause point, the hand-written version was the better choice. I’d written up the opposite conclusion without measuring it, and every comparison after that point had a hand-written version built alongside it.

Measure the version you’d write yourself before you credit a framework with replacing it.


Next: When the model holds the loop

Who holds the loop? Series index

Share this article

Email LinkedIn X

Comments

Loading comments...

Leave a Comment

All comments are moderated and may take a short while to appear.