Short version: Prompt chaining splits a task into a fixed sequence of steps, where each model call works on the output of the last. Anthropic calls it prompt chaining, and Google calls it the sequential pipeline. It trades speed for accuracy, and it is the easiest agent pattern to debug because you always know where the data came from.
What is prompt chaining?
Prompt chaining decomposes a task into a sequence of steps, where each LLM call processes the output of the previous one (Anthropic). Google frames the same shape as a sequential pipeline: specialized agents run in a fixed, linear order, and the output of one agent is the direct input to the next (Google Cloud).
Think of an assembly line. A parser turns a raw PDF into text, an extractor pulls out structured fields, and a summarizer writes the synopsis (Google Developers). Each station does one job well.
The gate: your cheapest safeguard
Anthropic adds one detail that makes chaining reliable: a gate. Between steps you can add a programmatic check that confirms the process is still on track before it continues (Anthropic). If the outline fails a criterion, you stop before wasting a call on a bad draft.
A gate is not a model call. It is plain code: a length check, a schema validation, a regex, a test. That is why chaining is cheap to make safe.
How it actually works
State is the whole trick. In Google ADK, each step writes its result to a shared session state with an output key, and the next agent reads from that key (Google Developers). A sequential workflow agent runs the steps in order and does not consult a model to decide what comes next, which keeps it predictable and cheap (Google Cloud).
# Google ADK, sketch
parser = LlmAgent(name="Parser", output_key="raw_text")
extractor = LlmAgent(name="Extractor", instruction="Use {raw_text}", output_key="fields")
summarizer = LlmAgent(name="Summarizer", instruction="Use {fields}")
pipeline = SequentialAgent(sub_agents=[parser, extractor, summarizer])
When to use it
Use prompt chaining when the task splits cleanly into fixed subtasks and you want higher accuracy per step (Anthropic). Classic examples: write marketing copy, then translate it. Or write an outline, check it against criteria, then write the document from the approved outline.
It shines for highly structured, repeatable processes where the order never changes, such as a data extraction, cleaning, and loading pipeline (Google Cloud). The payoff is that each call is an easier task, so the model makes fewer mistakes.
When not to use it
Do not chain when the steps are not known in advance. If the number and nature of subtasks depend on the input, the rigid pipeline cannot adapt, and you want orchestrator-workers instead. Do not chain when latency is the priority and the subtasks are independent. Run them in parallel. And if a single call already produces a good answer, chaining just adds round trips for nothing.
Known problems
The trade-off is rigidity. Google is explicit: the fixed structure makes it hard to adapt to dynamic conditions or to skip unneeded steps, which can cause inefficient processing or push up cumulative latency if a step that was not needed is slow (Google Cloud).
There is also error propagation. Because each step consumes the last step's output, a mistake early in the chain flows downstream. Gates catch some of this, but a step that produces plausible-but-wrong output can still poison everything after it. And every extra step adds latency, so a long chain feels slow even when each call is fast.
Three things to know before you start
- Put a gate after any risky step. A cheap code check beats an expensive bad draft.
- Name your state clearly. Downstream steps read named outputs, so a vague key becomes a silent bug.
- Keep the chain short. Each link adds latency and one more place to fail. If you need branching, you have outgrown a straight chain.
FAQ
Is prompt chaining the same as a sequential pipeline?
Yes. Anthropic uses "prompt chaining" and Google uses "sequential pipeline" for the same fixed, linear flow where each step feeds the next.
Does chaining need multiple agents?
Not necessarily. It can be several prompts to one model or several specialized agents. What defines it is the fixed order and the handoff of output to input.
What is a gate in prompt chaining?
A programmatic check between steps that confirms the work is on track before continuing. It is code, not a model call.
When should I switch to orchestrator-workers?
When you cannot predict the steps ahead of time. Chaining is for fixed sequences. Orchestrator-workers decides the subtasks at runtime.
Sources
- Anthropic, Building Effective Agents: https://www.anthropic.com/engineering/building-effective-agents
- Google Developers Blog, Developer's guide to multi-agent patterns in ADK: https://developers.googleblog.com/developers-guide-to-multi-agent-patterns-in-adk/
- Google Cloud Architecture Center, Choose a design pattern for your agentic AI system: https://docs.cloud.google.com/architecture/choose-design-pattern-agentic-ai-system

Top comments (0)