Want a quick email when a new article is published? Subscribe
Who holds the loop? The question that sorts every AI framework
Part 1 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.
Every time an AI pipeline comes up in conversation, someone asks why it isn’t built on LangChain. For a long time I didn’t have a good answer either way, so I built the same two jobs four or five times each: with no framework, with LangChain and LangGraph, with Pydantic AI and with the Claude Agent SDK. If you’re deciding whether a framework belongs in your stack, this series is what each one actually did for me, measured line by line on real data.
One question predicted almost every result: who holds the loop. Either your code decides the next step, or the model does.
Ask who holds the loop before you ask which framework
There are a lot of LLM frameworks and “agent SDKs”, and they aren’t all competing for the same job.
In a workflow, your code fixes the steps and the model fills in blanks inside each one. Take a transcript, classify it, extract the fields for that type, render a document. The path is the same every time, which makes it cheap to run and easy to test.
In an agent, you hand the model a goal and a set of tools, and it chooses what to call and in what order. You can’t know the path in advance. That’s the point of an agent, and it’s also the risk.
The tools then sort themselves into layers. At the bottom sit the model providers’ own SDKs, which make the API call and leave the control flow to you. Above them come app frameworks such as LangChain, the Vercel AI SDK and Pydantic AI: one interface across many model providers, answers checked against a schema, and tool definitions. Then orchestration runtimes such as LangGraph, which run your steps as an explicit graph and save state so a run can pause and resume. At the top are agent harnesses such as the Claude Agent SDK, which is the engine behind Claude Code packaged as a library: the whole agent loop, with tools, permissions and sessions built in.
This figure is interactive and needs JavaScript. The text around it describes what it shows.
Knowing which side of the loop a tool was built for tells you most of what it will and won’t do for you.
I built everything at least twice
I picked two jobs from software I already run. The first, a workflow, turns a recording’s transcript into structured notes. My app records audio, transcribes it and writes notes, but it assumes every recording is a meeting, and plenty aren’t. The second, an agent, carries out a spoken instruction (“mark that one done”, “remind me to book the dentist”) on a kanban board through its API.
For the workflow I used eight real recordings from my own archive: a business meeting, a long call between two professionals, an interview, two short notes to myself, two stretches of TV picked up in the background and a garbled fragment. Real transcripts are messy. Speakers get mislabelled, words get misheard and people stammer, and all of that turned out to matter. For the agent I set up a sandbox board holding only invented cards, and the agent’s tools couldn’t reach anything else.
Each version shared the same schemas, prompts, templates, tools and tests, so only the framework changed. I counted the lines each version spent on each concern (calling the model, retrying, wiring the steps together, tracing), and I recorded every step of every run with its timing, tokens and cost so I could replay exactly what happened. Every model call went to Claude Haiku 5.5 at temperature 0.
I didn’t write the code myself. An AI coding assistant wrote all of it from my direction, along with a visual replay of each stage. My job was choosing what to build, deciding what the output should contain and judging the results. The replays show exactly where each framework sits in the flow, and the figures in this series are those replays, rerun on invented transcripts so they can be published. The full method, versions and every number are on a separate reference page.
Consistent output comes from the schema, not the framework
The first version used no framework at all: two calls to the model and four steps of plain code. One call classifies the recording into one of seven types. A second call fills in a schema for that type: purpose, decisions and actions with owners for a meeting, or the key points and steps for a tutorial. Plain code then renders the result through a fixed template.
The model never writes the document. It fills in fields that the API forces to match the schema (most model APIs now offer this, under the name structured output), and the template decides the headings, their order and their wording. Same data in, same document out. All eight real recordings came back valid on the first attempt, in under a minute and for about 1.3 cents in total.
This figure is interactive and needs JavaScript. The text around it describes what it shows.
The hard part had nothing to do with code. The first schemas were my assistant’s guesses at what each type of note should contain, and the interview ones were wrong for me. After an interview I want to know what landed, what didn’t, and how likely a next round is, with the evidence quoted. Changing four field definitions changed the notes more than any framework did in the rest of the project.
The type list was hard too. A peer call between two professionals swapping advice and introductions fit none of my seven types, and the model said so: it called it a casual conversation, with a confidence of 0.55. It was right to be unsure. My code ignored the score completely.
Choosing those fields is your job, and no framework will do it for you.
Share this article
Comments
Leave a Comment
All comments are moderated and may take a short while to appear.
Loading comments...