Zenaique

What signal tells you to use a fixed LCEL chain instead of an agent loop?

Short answer·Medium·4.0 · 0·~3 min·Asked atAnthropicBasetenSnap·Relevant atAdobeAi21AmazonAnduril
Attempt it

Describe when a fixed LCEL chain (DAG pipeline) is the better choice over an agent loop. State the single most important question to ask when choosing between them.

Free · 2 AI evals / day
TL;DR

Prefer a fixed chain unless the execution path must change based on intermediate results; the decisive question is whether all steps are known at design time.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Think of it like two ways to cook dinner. A chain is a recipe card you follow top to bottom every time: chop, fry, plate. You always do the same steps in the same order, so you know exactly how long it takes and what it costs. An agent is a chef with no recipe who tastes the food, decides what to do next, and keeps adjusting until it is right. The chef is more flexible, but you cannot predict how long they will take or how much they will spend. If your dinner is always the same dish, the recipe card wins every time. You only need the improvising chef when you genuinely do not know the steps in advance, because what you find halfway through changes what you do next.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

The choice between a fixed chain and an agent loop is one of the most common architecture decisions in LLM engineering, and one of the most over thought. A chain is a directed acyclic graph wired at design time: the same nodes execute in the same order on every request. An agent loop hands control to the model, which inspects each result and decides the next action at runtime. The two architectures sit at opposite ends of a control flow spectrum, and most real systems land somewhere between them.

The word "agent" carries a halo. It sounds smarter, more autonomous, more modern. That halo is exactly what leads teams astray. They reach for a loop because it feels capable, then spend weeks fighting unpredictable cost, latency spikes, and runs they cannot reproduce, all for a task whose steps were fixed from the start.

The entire decision reduces to one question: does the execution path need to change based on intermediate results? Everything else, latency, cost, debuggability, follows from how you answer it. The default should always be the simplest thing that works, and a chain is almost always simpler than a loop. The sections below unpack why that default holds, what the agent actually buys you, and how to apply the rule when an interviewer pushes on edge cases.

Who owns control flow

The cleanest way to frame the distinction is by asking who decides what runs next. In a chain, the engineer owns control flow. You draw the graph, and the runtime walks it the same way every time. PDF in, extract text, chunk, embed, upsert. There is no decision to make at runtime because the structure is baked into the code. The LLM, if it appears at all, is just one node doing one bounded job, like summarising a chunk; it never decides what happens after it.

In an agent loop, the model owns control flow. After every observation, the LLM chooses the next tool call or declares the task done. The path is emergent. Two runs of the same task can take different routes, call different tools, and use a different number of steps. The engineer no longer specifies the trajectory; they specify the tools, the budget, and the stopping rules, then hand the steering wheel to the model.

This is the line that the agents concept file draws between a chain and an agent: dynamic, model driven control flow versus a deterministic, hand wired DAG. A chain that merely happens to call a tool is still a chain. The presence of an LLM does not make a system agentic. What makes it agentic is that the model, not the code, decides the order and number of steps.

This single difference is the root of every tradeoff that follows. Static control flow is predictable and cheap to reason about. Dynamic control flow is flexible but variable. Naming this distinction explicitly, and refusing to conflate a tool call with agency, is what separates a confident answer from a hand wavy one in an interview.

The cost and latency tradeoff
Reliability and debuggability
A decision rule you can apply under pressure
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
DimensionFixed chain (LCEL / DAG)Agent loop
Control flowEngineer decides at design timeModel decides at runtime
Execution graphStatic, same every runDynamic, depends on observations
LatencyBounded and predictableUnbounded, scales with step count
CostFixed LLM call countCompounds super linearly with steps
DebuggingReproducible, flat failure surfaceEmergent, hard to reproduce
Use whenSteps known up frontPath depends on intermediate results

Real products, models, and research that use this idea.

  • A document ingestion pipeline (extract, chunk, embed, upsert to a vector store) is a textbook chain: the same nodes run every time, so LangChain LCEL or a plain DAG gives bounded cost and latency.
  • LangGraph models both ends of the spectrum: a linear StateGraph is effectively a chain, while adding loop back edges and a model driven router turns the same graph into an agent.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QYour pipeline has one branch that depends on a classification step. Chain with a conditional edge, or agent?
A

Distinguish fixed branching from dynamic control flow. A known set of branches selected by a router is still a static graph, so a conditional edge in a chain suffices. You only need a loop when the number and order of steps cannot be enumerated up front.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Reaching for an agent by default because it sounds powerful. Most production tasks have a fixed graph, so a chain is cheaper, faster, and far easier to debug.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • State the one decisive question that settles the chain versus agent choice.

  • Explain why a fixed graph gives predictable latency and bounded cost.

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is the Model Context Protocol (MCP) and what problem does it solve?
MCQ·Easy