Agent vs. Workflow
When to give Claude autonomy vs. when to pin a fixed sequence.
An agent decides which tool to call next based on a goal. A workflow pins the order of tool calls in code. Pick a workflow when the steps are known and stable; pick an agent when the path branches on data the LLM only sees at runtime.
*Default:* start with a workflow, promote to an agent only when you hit a step that requires LLM judgement to route.
Real-world example: Shopify order webhook vs. support chatbot
A merchant's order-status webhook does four steps every time — verify signature, normalize payload, update inventory, fire confirmation email. The path never branches on the order's contents. Pin it as a workflow:
async function onOrder(event: ShopifyOrder) {
if (!verifySignature(event)) throw new BadRequest();
const normalized = normalize(event);
await inventory.update(normalized);
await mailer.sendConfirmation(normalized);
}The same merchant's customer-service chatbot is a different shape. The user might ask for a refund, dispute a charge, ask for product specs, request a return label, or escalate to a human. The next tool depends on language the model parses at runtime. Use an agent.
Why this matters: wrap deterministic flows in code so they stay debuggable and cheap. Reserve agent autonomy for branches the LLM has to read to decide.
- Workflows pin tool sequence in code
- Agents decide next tool from a goal
- Stable, non-branching steps → workflow
- Branches on runtime data → agent
- Default to workflow, promote only when needed
