Want a quick email when a new article is published? Subscribe
Who holds the loop? Method and numbers
This is the reference behind the series Who holds the loop?, which compares building the same two jobs with no framework, LangChain and LangGraph, Pydantic AI and the Claude Agent SDK. It records how I tested them, what versions I used and every number the series draws on, so you can judge how much weight each conclusion can bear.
Versions and model
I ran everything in November 2026 with these packages:
| Package | Version |
|---|---|
langchain-core | 1.7.6 |
langchain-openai | 1.7.4 |
langgraph | 1.2.20 |
langgraph-checkpoint-sqlite | 3.1.3 |
pydantic-ai-slim | 2.66.0 |
claude-agent-sdk | 0.2.179 |
openai (used as a plain SDK) | 3.46.0 |
Every model call went to Claude Haiku 5.5 through OpenRouter at temperature 0, apart from the second-opinion experiment, which used Claude Sonnet 5.5. The costs are what the provider charged, apart from the Claude Agent SDK’s, which are the SDK’s own estimate at list price with prompt caching.
The figures use invented data
The interactive figures in the series replay real runs, but on eight invented transcripts written to cover the same types as my recordings, including a tutorial, which my real set lacked. My own recordings contain other people’s conversations, so they stay private. The invented transcripts are cleaner than real ones: on them, every classification came back at 0.6 confidence or higher, so nothing went to a second opinion and no quote check fired. The borderline cases and the misquotes described in the series come from the real recordings. The agent figures replay reruns on the same sandbox board, with the agent’s prompts made anonymous.
How I kept the comparison fair
- One variable at a time. Every version shared the same code for schemas, prompts, templates, tools, test instructions and checks. Only the framework changed.
- A hand-written version of everything. From the pause-and-resume stage onwards, every framework version had a no-framework equivalent built and measured alongside it. The earlier stages already had one.
- Lines counted by concern. I counted calling the model, retrying, wiring the steps together and tracing separately, and left out blank lines, comments and docstrings.
- Pass or fail decided in code. For the agent, a check read the board after each instruction and decided the result. It didn’t take the agent’s word for it.
- Every run recorded. I logged each step and model call with its timing, tokens and cost, then replayed it visually.
- AI-written code. An AI coding assistant (Claude Code) wrote all the code from my direction. I chose what to build, set the output requirements and judged the results.
The workflow: transcript to notes
The data
| Recording | Size |
|---|---|
| A business meeting | about 2,000 words |
| A one-to-one call between two professionals | about 5,600 words |
| An interview | about 6,200 words |
| Two notes to myself | 13 and 22 words |
| Two stretches of background TV | 183 and 257 words |
| A garbled fragment | 28 words |
The seven recording types were: meeting, interview, note to self, delivered content (a lecture or tutorial), casual conversation, background media, and unusable. None of the eight recordings was delivered content, so that type went untested.
No framework
- All eight were valid against their schema on the first attempt.
- The whole set took under a minute and cost about 1.3 cents.
- Two classifications came back below 0.6 confidence: the peer call (casual conversation, 0.55) and a 22-word clip (casual conversation, 0.40).
LangChain and LangGraph, against no framework
| Concern | No framework | LangChain and LangGraph |
|---|---|---|
| Calling the model | 19 lines | 8 |
| Validating and retrying | 16 | 0 extra (one method call) |
| Wiring the steps | 25 | 44 |
| Tracing | 17 | 25 |
LangChain’s request for the 22-word clip was 827 input tokens against 826 without it, so the framework didn’t change what the model saw. Four repeats of the original request, with no framework, all returned “meeting” at 0.45 to 0.5, where the first run had said “casual conversation” at 0.40. The peer call scored 0.55 on one run and 0.60 on another. The second-opinion model agreed with the first on the one recording sent to it.
Pydantic AI
| Concern | No framework | LangChain and LangGraph | Pydantic AI |
|---|---|---|---|
| Calling the model | 19 | 8 | 10 |
| Validating and retrying | 16 | 0 | 14 (includes the quote check) |
| Tracing | 17 | 25 | 5 |
The quote check compares each quote with the transcript after stripping punctuation and case, and accepts a match of 85% or better over a window the size of the quote.
- Of the no-framework version’s 31 quotes, one failed: the model had removed a stammer.
- All 25 of the LangChain version’s classification quotes passed.
- Four of nine runs of the interview through Pydantic AI needed at least one extra model call. In the run traced in full, the rejected quote joined two separate remarks with an ellipsis.
Pausing for a person
- The confidence threshold for asking was 0.7. Three of the eight recordings paused, and I overruled the model on two of them.
- LangGraph saved 51 checkpoints across the eight runs, holding about 650 KB of state. The 5,600-word call alone accounted for 177 KB.
- Adding the pause took 11 lines with LangGraph and 20 by hand.
- The whole flow, pause included, came to 53 lines with LangGraph (counting the state and steps it reuses) and 35 by hand.
The agent: spoken instruction to board changes
Tools and guardrail
The agent had six tools: read the board, create a card, move a card, update a card’s tags, flags, due date or title, add a comment, and mark a card complete. My code locked every tool to one sandbox board, and every tool that took a card id fetched the card first and refused it if it belonged anywhere else. There was no delete tool. The board held only invented cards.
The six instructions
- Add a to-do to chase an insurance broker, tagged urgent.
- Flag a supplier quote as blocked and note why.
- Mark an introduction as done.
- Move some meeting prep to Waiting, due on a specific date.
- Remind me to book the dentist.
- Delete everything on the board.
| By hand | Claude Agent SDK | LangGraph | |
|---|---|---|---|
| Passed | 6 of 6 | 6 of 6 | 6 of 6 |
| Lines of code | 41 | 58 | 38 (15 for the agent, 23 for tracing) |
| Average time per instruction | 3.0 s | 4.9 s | 3.8 s |
| Cost for all six | about $0.004 | about $0.003 | about $0.004 |
An earlier, vaguer version of the sixth instruction asked the agent to “clear out” a set of cards. The hand-written agent marked two unfinished cards complete, and the Claude Agent SDK version asked first. That single comparison prompted the confirmation rule. One run of each isn’t enough to say which framework handles ambiguity better, and I wouldn’t draw that conclusion.
Asking before acting
The rule: ask before marking any card complete, and ask before changing a second card within one instruction. It’s 45 lines, shared by all three versions. Every pause and every answer ran as a separate operating-system process.
| Instruction | My answer | By hand | Claude Agent SDK | LangGraph |
|---|---|---|---|---|
| Mark an introduction done | yes | pass | pass | pass |
| ”Giving up on the admin cards, get rid of them” | no | pass | pass | pass |
| Flag two cards for review | yes | pass | pass | pass |
| Mark a course decision done | no | pass | pass | pass |
| By hand | Claude Agent SDK | LangGraph | |
|---|---|---|---|
| Lines for pausing and resuming | 53 | 66 | 44 |
| How it pauses | Saves messages and pending tool calls to JSON | A hook returns defer, and the session is saved | interrupt() inside the tool, with a SQLite checkpointer |
| Changes to the agent loop | Rebuilt around a queue | None | None |
| What reruns on resume | The pending call | The hook is asked again about the pending call | Only the paused tool call |
In the “giving up” case, the models sometimes asked in words without attempting anything, and sometimes tried to mark the cards complete and were stopped by the rule. The fourth case exists to force a real “no” through the pause.
The parallel race: in LangGraph’s first run, two update_card calls started a millisecond apart. Both checked the “second card” rule before either had recorded anything, and both went ahead. Locking the check and the record into one step fixed it.
The double pause: asked to mark two cards done, the model requested both completions in one turn, both paused, and LangGraph refused a plain resume until each pause had its own answer, keyed by its id. My first version crashed on it. Handling it took five more lines, which is why LangGraph’s count rose from 39 to 44. The model doesn’t do this every time: four attempts at the original wording produced a question in words instead, and an instruction that asked for both cards at once produced it first time.
The hook that stopped matching: the Claude Agent SDK’s hook selects tools by a name pattern. While renaming the tool server, I left the configuration key and the pattern out of step for one run. The hook never fired, and three of the four cases failed: the agent completed or flagged cards without asking. No error appeared anywhere. Matching the names again restored all four passes.
What this doesn’t show
- One model. Different models may plan, ask and misquote differently.
- Small numbers. Eight recordings, six instructions and four confirmation cases, mostly run once each. The repeat runs I did make showed real variation, so treat single results as examples, not rates.
- Approximate line counts. Where a version reused code from an earlier one, I counted only what it added or rewrote. A different split between “agent” and “tracing” would move the totals by a few lines.
- No retrieval. I didn’t build search across documents, which is where LangChain’s integrations do most of their work.
- Fast-moving libraries. Several APIs here were new or already marked for change. The specific numbers will date sooner than the conclusions.
Share this article
Comments
Leave a Comment
All comments are moderated and may take a short while to appear.
Loading comments...