Kolkata ·  
AI engineering
workflows
deep · 6 min

LLM workflows

LLM calls wired together by code you wrote. Your code picks the next step, not the model.

updated 29 Sept 2026

Say we're building a docs assistant, and someone asks it: "How is reranking different from hybrid search?"

The simplest thing we can build is one call to the chat API. A system prompt, the question, some retrieved text, and the model writes an answer. For a lot of products that's enough, and it's where we should start.

But say the answers aren't good enough. Comparison questions come out lopsided, or the model makes a claim the articles don't back up. What would we change?

Growing it one step at a time

Here's a version we might try:

  1. Ask a small, cheap model what kind of question this is. It says "comparison".
  2. Because it's a comparison, pick the comparison prompt and fetch both articles, not just one.
  3. Write the answer.
  4. Send the answer and the articles to a second call that checks every claim. If something fails, send the draft back.

Look at what's new here. Each model step is still one plain call, the same as before. What we added is the code around them: an if that picks the prompt, a check, a loop that can send the draft back. That code is the workflow. The model does the language work inside each step, and our code decides which step comes next and when we're done.

So an LLM workflow is model calls (and tools) strung together along paths we wrote ahead of time. The model fills the paths in. It doesn't choose them.

Who picks the next step

That last line is the whole difference from an agent. In an agent, the model decides what to do next: which tool to call, whether to call another, when it's finished. Our code just keeps the loop running.

So the question to ask of any system is who holds the control flow. In a workflow, our code does. In an agent, the model does.

Everything else follows from that. A workflow takes the same path for the same kind of input, so it behaves predictably and we can test each step on its own. When it breaks, we can point at the step that broke. An agent can take on tasks where nobody knows the number of steps in advance (a code change that touches who knows how many files), but it costs more, and its mistakes pile up over many turns.

The rough rule is workflows for tasks we can describe well, agents when the model really has to make the decisions. Picking between them gets its own article, when not to use agents.

Why more calls would help at all

This is the part that feels odd at first. The model can read the whole prompt. Why would splitting the job into four calls beat one good call?

Mostly because each call gets an easier job. A prompt that only labels the question, or only checks claims, can be short and specific. One giant prompt has to serve every kind of input, and tuning it for comparisons can quietly make it worse at everything else.

The clearest measured case is from coding contests, back in the GPT-4 days (2024). With one carefully written prompt, GPT-4 solved about 19% of the problems in five tries. Then the same model was run through a fixed flow: reflect on the problem, reason about the example tests, draft a few solutions, rank them, write extra tests, then write code and keep fixing it against the tests. That got 44%.

That's the same model both times. Only the code around it changed.

Now check the bill. That flow made 15 to 20 model calls per solution, so five tries cost around 100 calls. That's the trade every workflow makes: more calls, more time, more tokens, in return for better answers. Sometimes it's worth it. Often one call is.

There are a couple of other reasons people reach for workflows, and they have nothing to do with accuracy:

  • Control. A step in code can filter what the model wrote, or refuse to show a user files they aren't allowed to see. The model can't enforce that on its own.
  • Cost per step. A cheap model can do the labelling and a strong one the writing. One model is one price; a system lets us mix.

The usual shapes

Most workflows turn out to be one of five shapes, or a couple of them stuck together.

  • Prompt chaining runs calls in a fixed line, each one working on the last one's output, with checks in code between them.
  • Routing labels the input first and sends it down the path made for that kind of input. Step 1 in our docs assistant was a router.
  • Parallel calls run at the same time, either on different parts of the job or on the same job several times so we can vote.
  • Orchestrator-workers has one call decide the subtasks at run time and hand them out. Since the subtasks aren't fixed, this is the one closest to an agent.
  • Evaluator-optimizer has one call write and another grade against clear criteria, looping until it passes. Step 4 was this.

None of this needs a framework. Chaining is a for loop that feeds each result into the next prompt. Parallel calls are a thread pool. Routing is "ask the model for a label, look the label up in a dictionary of prompts". Frameworks add layers that hide the prompts and responses, which are exactly what we need to see when something goes wrong. So it's worth starting on the API directly, and if we do pick up a framework, knowing what it sends.

Where it gets harder

Every step we add is a step that can fail, and with a few of them, "the answer was bad" stops telling us much. Which step did it? That's why we log every step's input and output (tracing). The upside of fixed steps is that, once we can see them, the failure usually points to one place.

And every step comes with choices. Even our small assistant has them: how much of a latency budget goes to fetching articles and how much to the model? If we want an answer in 100 ms, is it 20 for retrieval and 80 for the model, or the other way round? We settle those by measuring, with evals, not by guessing.

The advice has moved

Here's where it's worth slowing down. In mid-2024, splitting a big prompt into smaller ones was treated as common knowledge, and teams were told to prefer fixed workflows over agents because agents failed step by step. The coding-contest numbers above are from that same era.

Two things changed since. Reasoning models now do a lot of the step-by-step work inside a single call. Anthropic's current prompting guide (as of 2026-09) expects its models to handle most multistep reasoning internally, and keeps explicit chaining for when we need to inspect the in-between outputs or force a pipeline. And during 2025, agents started being useful in practice, mostly for coding and search.

So in 2026 the reason to build a workflow is less often "the model can't do it in one go" and more often "I need to see, test and control each step". Our docs assistant fits that. Part of the point of the checker in step 4 is that we can log what it flags and test it on its own.

What we don't have is a fair rematch: one call against a chain, on the models people use now, on the same tasks. We couldn't find one published. So the 19% to 44% jump is history, and whether step 2 or step 4 earns its place in our assistant is something we'd have to measure on our own questions.

Further reading