Home / Question bank / Coding with AI APIs
When would you use a workflow (chained prompts) instead of an autonomous agent?
30-second answer
When the steps are known in advance. Workflows are predictable, cheaper, faster and easier to test and debug. Use an agent only when the path genuinely depends on intermediate results and can't be enumerated, and accept the extra cost, latency and risk.
Try answering out loud before reading on. The walkthrough below is paced for a 40-minute interview round.
0–5 min Clarify and frame
Ask about the task: are the steps known? How variable are inputs? What are the latency, cost and risk tolerances? Framing: "The real question is how much control over the sequence of steps to give the model. More autonomy handles open-ended problems, but costs predictability, latency, money and safety. I'll define the spectrum, give decision criteria and show hybrids."
5–15 min Core explanation: the spectrum
From least to most autonomous:
- Single augmented call: one LLM call with retrieval and maybe a tool.
- Prompt chaining: fixed sequence, each step's output feeds the next (outline → draft → edit). Gates between steps can validate.
- Routing: classify the input, send it to a specialized prompt or model.
- Parallelization: run independent subtasks concurrently (sectioning) or the same task several times and vote.
- Orchestrator–workers: a model breaks the task down dynamically and delegates to workers, then synthesizes.
- Evaluator–optimizer: one model generates, another critiques against criteria, loop until acceptable.
- Autonomous agent: the model chooses tools in a loop until it decides it's done.
Patterns 2–6 are workflows: code owns the control flow. Pattern 7 is an agent: the model owns it.
15–25 min Deep dive: decision criteria
| Question | Favors workflow | Favors agent |
|---|---|---|
| Are steps known in advance? | Yes | No, they depend on findings |
| Variation across inputs | Low | High |
| Latency/cost budget | Tight, predictable | Flexible |
| Auditability needs | High | Moderate (with tracing) |
| Error impact | High, hard to undo | Recoverable or verifiable |
| Feedback available? | — | Yes: tests, tool results, environment state |
Agents shine when the environment gives clear feedback each step (code tests pass/fail, search results, API responses) so the model can correct course.
Guidance: start with the simplest pattern; add complexity only when evals show the simpler version fails.
25–32 min Hybrids and costs
- A workflow with an agentic step: fixed intake and output formatting, with an agentic research step in the middle under step and budget limits.
- An agent with checkpoints: autonomous until a consequential action, which requires approval.
- Orchestrator with deterministic workers: the model plans; workers are tested code paths.
Agent costs to plan for: variable latency (seconds to minutes), token use growing with each step's history, harder testing (scenario-based evals), and larger security surface (tool misuse, injection).
32–37 min Production example
A "weekly business report" agent sometimes skipped data sources and took 2–4 minutes. Rewritten as a workflow (fetch four sources in parallel → summarize each → combine → format), it became consistent, ran in 25 seconds and cost far less. The company's "investigate this production incident" feature stayed agentic because each investigation follows a different path, with read-only tools and a 15-step cap.
37–40 min Likely follow-ups
- How do you test each? Workflows: unit-test steps with fixtures plus end-to-end evals. Agents: scenario suites in sandboxed environments, measuring success, steps, cost and safety.
- Should agents be multi-agent? Only when sub-tasks benefit from separate contexts or parallelism; multi-agent systems multiply cost and coordination failures.
What interviewers listen for
- Knowing the spectrum of patterns, not just "agent vs. not".
- Clear criteria and a bias toward simplicity backed by evals.
Red flags
- Choosing agents because they sound more advanced.