> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# When to Use Each

> Guidance on choosing between single LLM calls, workflows, and agents, outlining trade offs, when to use each, and recommending start simple and combine them as needed.

Lesson 12.

You now understand the technical difference between single LLM calls, workflows, and agents. The practical question remains: which one should you build for a given problem?

Choosing the wrong approach has real consequences — more expensive runs, higher latency, brittle systems, and harder debugging. Use one guiding principle: start with the simplest solution that will do the job, and only add complexity when necessary.

Most tasks do not require an agent. Often a single LLM call or a straightforward workflow is enough. Before you build, ask the simplest question: can a single LLM call handle this? If yes, use that. If you need multiple calls in a fixed sequence, use a workflow. If the LLM must decide its own steps based on discoveries at runtime, consider an agent. Each step up the ladder (single call → workflow → agent) adds cost, latency, and complexity — so justify the upgrade.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/z7NmHsFQN9LCEiD0/images/AI-Agents-for-Beginners-OpenClaw-Case-Study/Tools-and-Workflows/When-to-Use-Each/start-simple-retro-llm-workflow-agent.jpg?fit=max&auto=format&n=z7NmHsFQN9LCEiD0&q=85&s=a08336021f2344ce9e4ddcc2f86b13f1" alt="A retro-style infographic titled &#x22;Start Simple&#x22; that advises adding complexity only when needed. It compares three approaches: &#x22;Single LLM Call&#x22; (one request, one response) on the left, &#x22;Workflow&#x22; (fixed sequence of steps) in the center, and &#x22;Agent&#x22; (decides its own path) on the right." width="1920" height="1080" data-path="images/AI-Agents-for-Beginners-OpenClaw-Case-Study/Tools-and-Workflows/When-to-Use-Each/start-simple-retro-llm-workflow-agent.jpg" />
</Frame>

Only move to a more complex approach when the simpler one genuinely can't do the job.

## When to choose a workflow

Workflows are best when the problem is well understood and the sequence of steps can be defined up front. They are predictable, easy to debug, and cost is easier to control.

Common workflow use cases include:

* Email classification and templated responses
* Daily briefing or report generation
* Structured data extraction pipelines
* Translation chains or other deterministic processing chains

These are repeatable, deterministic tasks: every input follows the same path even if the inputs vary.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/z7NmHsFQN9LCEiD0/images/AI-Agents-for-Beginners-OpenClaw-Case-Study/Tools-and-Workflows/When-to-Use-Each/when-workflows-win-checklist.jpg?fit=max&auto=format&n=z7NmHsFQN9LCEiD0&q=85&s=52b4d78d4cc43465af3560116306aed1" alt="The image is a dark, grid-styled slide titled &#x22;When Workflows Win&#x22; with icons and labels for examples like Email Classification, Daily Briefing, Data Extraction, and Translation Chains. Below are green-highlighted checklist boxes noting characteristics such as &#x22;Steps Known,&#x22; &#x22;Debuggable,&#x22; &#x22;Predictable,&#x22; and &#x22;Cost Fixed.&#x22;" width="1920" height="1080" data-path="images/AI-Agents-for-Beginners-OpenClaw-Case-Study/Tools-and-Workflows/When-to-Use-Each/when-workflows-win-checklist.jpg" />
</Frame>

## When to choose an agent

Use an agent when the correct path cannot be determined ahead of time and the LLM must adapt or explore at runtime. Agents provide flexible orchestration: they decide which tools or steps to use based on what they discover.

Typical agent scenarios:

* Trip planning that requires multi-step research and trade-offs
* Personal assistants coordinating dynamic tasks and contexts
* Complex scheduling where constraints emerge during the interaction
* Coding assistants that iteratively inspect, edit, and rerun code

These tasks are open-ended: different inputs may trigger different paths and the system benefits from on-the-fly decision-making.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/z7NmHsFQN9LCEiD0/images/AI-Agents-for-Beginners-OpenClaw-Case-Study/Tools-and-Workflows/When-to-Use-Each/when-agents-win-open-ended-tasks.jpg?fit=max&auto=format&n=z7NmHsFQN9LCEiD0&q=85&s=aeab5a9707741026f6e8b72197f2877a" alt="The image is a retro-style infographic titled &#x22;When Agents Win&#x22; with icons and labels for open-ended tasks like Trip Planning, Personal Assistant, Complex Scheduling, and Coding Assistant. Below are four highlighted criteria: &#x22;Steps can't be predicted,&#x22; &#x22;Task requires flexibility,&#x22; &#x22;Open-ended problems,&#x22; and &#x22;Environment gives feedback.&#x22;" width="1920" height="1080" data-path="images/AI-Agents-for-Beginners-OpenClaw-Case-Study/Tools-and-Workflows/When-to-Use-Each/when-agents-win-open-ended-tasks.jpg" />
</Frame>

## Trade-offs and costs

Agents introduce additional operational complexity:

* Higher per-request compute costs
* Increased latency due to multiple LLM calls and tool invocations
* Greater surface area for bugs and unexpected behavior
* More effort required to test and debug decision logic

Conversely, forcing a workflow on an open-ended problem leads to brittleness: it will break on unanticipated inputs and require frequent, costly updates.

<Callout icon="warning" color="#FF6B6B">
  Agents add flexibility at the cost of predictability and price. If strict cost or latency constraints exist, prefer workflows or enforce strong guardrails on agents.
</Callout>

## Decision checklist — quick diagnostic

Run through these four questions to guide the choice. Answering “Yes” or “No” points you toward the simpler, more robust option when possible.

| Question | Yes → Use Workflow | No → Use Agent |
| - | -: | :- |
| Can I define all possible paths in advance? | Workflow | Agent |
| Does the LLM need to decide the next step at runtime? | — | Agent |
| Is this a well-defined, repeatable task? | Workflow | Agent |
| Must cost and latency be strictly controlled? | Workflow (or guarded Agent) | Agent (with guardrails) |

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/z7NmHsFQN9LCEiD0/images/AI-Agents-for-Beginners-OpenClaw-Case-Study/Tools-and-Workflows/When-to-Use-Each/retro-decision-checklist-workflow-vs-agent.jpg?fit=max&auto=format&n=z7NmHsFQN9LCEiD0&q=85&s=36da6d032d83cf51c400b7c615c0197a" alt="A retro-styled &#x22;Decision Checklist&#x22; table comparing Workflow vs Agent across four questions (paths defined in advance, LLM decides next step, well-defined/repeatable, cost strictly controlled) using green checkmarks, red Xs and an orange dash. Workflow is checked for most items while the Agent is only checked for &#x22;LLM decides next step,&#x22; with mixed marks elsewhere." width="1920" height="1080" data-path="images/AI-Agents-for-Beginners-OpenClaw-Case-Study/Tools-and-Workflows/When-to-Use-Each/retro-decision-checklist-workflow-vs-agent.jpg" />
</Frame>

<Callout icon="lightbulb" color="#1CB2FE">
  Use the checklist above: if most answers point to a workflow, start there. If answers lean toward openness and runtime decision-making, design an agent — and add guardrails to control cost and behavior.
</Callout>

## Combining workflows and agents

Production systems often need both. A common pattern is a hybrid design:

* Use a workflow to orchestrate predictable, repeatable parts (validation, batching, fixed transforms).
* Insert an agent for sub-tasks that require exploration, adaptive decision-making, or tool usage.
* Start with a workflow; if it hits a limitation, extract the decision-heavy portion into an agent with clear interfaces and safety checks.

This hybrid approach balances predictability and flexibility.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/z7NmHsFQN9LCEiD0/images/AI-Agents-for-Beginners-OpenClaw-Case-Study/Tools-and-Workflows/When-to-Use-Each/flexible-hybrid-workflow-agent-infographic.jpg?fit=max&auto=format&n=z7NmHsFQN9LCEiD0&q=85&s=dd4a1383d861b2be16c9efbba6c9e39a" alt="An infographic titled &#x22;Best Systems Combine Both&#x22; that shows a workflow (predictable parts) plus an agent (flexible parts) equals a &#x22;Flexible Hybrid.&#x22; A caption at the bottom advises to start simple with a workflow and add an agent when needed." width="1920" height="1080" data-path="images/AI-Agents-for-Beginners-OpenClaw-Case-Study/Tools-and-Workflows/When-to-Use-Each/flexible-hybrid-workflow-agent-infographic.jpg" />
</Frame>

## Summary

* Workflows follow a path you design; agents decide their own path.
* Most tasks are best handled by a single LLM call or a workflow.
* Use an agent only when runtime adaptability, exploration, or tool orchestration is required.
* The wrong choice increases cost, latency, and debugging burden.
* Start simple; add complexity only where it provides clear value.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/z7NmHsFQN9LCEiD0/images/AI-Agents-for-Beginners-OpenClaw-Case-Study/Tools-and-Workflows/When-to-Use-Each/neon-infographic-workflows-agents-tips-checklist.jpg?fit=max&auto=format&n=z7NmHsFQN9LCEiD0&q=85&s=26230886f6b8bca93c6abe2b7db82394" alt="A neon-styled infographic titled &#x22;What You Need to Remember&#x22; showing four colored boxes with tips about workflows and agents (e.g., &#x22;Workflows follow a path,&#x22; &#x22;Agents decide their path,&#x22; &#x22;Most tasks need workflows,&#x22; &#x22;Wrong choice costs&#x22;), plus a &#x22;Your Next Steps&#x22; checklist at the bottom." width="1920" height="1080" data-path="images/AI-Agents-for-Beginners-OpenClaw-Case-Study/Tools-and-Workflows/When-to-Use-Each/neon-infographic-workflows-agents-tips-checklist.jpg" />
</Frame>

Further reading and references:

* [OpenAI: Guides — Agents](https://platform.openai.com/docs/guides/agents)
* [LangChain: Agents](https://langchain.readthedocs.io/en/latest/modules/agents.html)
* Patterns for designing workflows and guards: consider search-based agents, function calling, and strict rate/cost controls when moving from workflows to agents.

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/ai-agents-for-beginner-openclaw-case-study/module/5063e430-2631-48f3-b37f-4b3dd0d5c166/lesson/3325aec1-a486-4d83-9a74-b5ba52e2240c" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.