Learn AI compute, then follow the market
← Back to Compute College

Compute College

Prompt decomposition and chaining

Break complex AI work into smaller stages and decide which steps belong in code, prompts, or human review.

Plain-English definition

Prompt decomposition divides a complex task into stages with clear inputs and outputs. A chain runs those stages in sequence; parallel branches handle independent subtasks before an aggregation step. Decomposition is useful when one prompt has too many responsibilities, but every added call introduces latency, token cost, failure modes, and state that must be managed.

Memory trick: A chain is a workflow, not a magic prompt. Every link needs an input, output, test, and cost.

Why it matters

A single giant prompt may be difficult to test and may hide which part failed. Smaller stages can use different models, deterministic code, or human approval where appropriate. The tradeoff is that a five-step chain can cost more than one call if the extra structure does not improve accepted-task rate or reduce downstream correction.

  • Separate extraction, transformation, decision, and presentation when each stage has a different success test.
  • Use deterministic code for arithmetic, routing, permissions, and other rules that do not require model judgment.
  • Measure the complete chain, including failed branches, retries, context passed between steps, and aggregation.

Simple example

A contract workflow can extract obligations, normalize dates, check each obligation against policy, and then write a human-readable summary. The extraction step returns structured evidence; code normalizes dates; the policy check identifies exceptions; a final model call explains the result. Each stage has a smaller contract than “review this contract.”

  • Intermediate outputs become inspectable evidence instead of hidden reasoning.
  • Independent checks can run in parallel when they do not depend on one another.
  • A failed stage can be retried or escalated without rerunning every earlier step.

Example figures are illustrative calculations, not current quoted market prices.

Current example

Workflow design reference

Anthropic’s guidance on effective agents recommends starting with simple composable workflows and adding agentic complexity only when it creates clear value. That principle applies to prompt chains: add a stage because it improves a measured outcome, not because more steps sound more capable.

Anthropic: Building effective agents

Primary guidance on prompts, workflows, agents, routing, parallelization, and when simple designs are preferable.

Source discipline: the reference explains the concept or method; it is not a substitute for measuring a production workload under its actual provider, model, and data conditions.

Common mistake

Not every workflow benefits from becoming a chain. If the stages share the same context and have no independent checks, extra calls may add cost without making the result better. Start with the smallest design that can be evaluated.

Practical takeaway

What you can do with this

Draw the workflow as a sequence or graph. For each stage, name its input, output, evaluator, model or code owner, retry behavior, and cost. Remove a stage if you cannot explain what measurable risk or quality problem it solves.

  • Builders: keep intermediate outputs small and typed.
  • Product teams: define where a user can review or correct the chain.
  • Operators: log stage-level latency, tokens, failures, and retries.

Decision check: does each added step have its own acceptance test and a benefit larger than its latency, token, and failure cost?

Compute College track

Prompt & Context Engineering

Step 7 of 18: Prompt decomposition and chaining