Workflow vs Agent: How to Choose the Right AI Architecture
Subham Chand
Sep 4, 20266 min read6 views
Learning outcome: By the end of Day 16, you will be able to choose ordinary code, a predefined workflow, or an AI agent for a task—and explain why.
This lesson is part of the AI Agents in 30 Days roadmap. In Days 1–15, you learned how agents work, use tools, remember context, and answer from trusted documents. Today, the question changes from “Can I build an agent?” to “Do I actually need one?”
Advertisement
The shortest useful answer
Use this three-part mental model:
Fixed input + fixed rule → ordinary code
Fixed sequence of steps → workflow
Flexible decisions during execution → agent
This is not a contest where an agent is always the most advanced or desirable answer. The best design is usually the simplest system that can complete the task reliably.
Anthropic draws a useful architectural distinction: workflows follow predefined code paths, while agents dynamically direct their own process and tool use. It also recommends increasing complexity only when simpler approaches fall short. OpenAI similarly describes agents as systems in which a model manages execution, makes decisions, and selects tools within guardrails.
Option 1: Ordinary code for a predictable rule
Ordinary code is the right starting point when the input and transformation are predictable.
Imagine a Study Planner that receives a list of study sessions and calculates the total number of hours. The calculation does not need judgment. It does not need to choose a tool or invent a new plan. A normal function is faster, cheaper, easier to test, and easier to explain.
Input: 1.5 hours + 2 hours + 45 minutes
Rule: convert to minutes, add, convert back
Output: 4 hours 15 minutes
Adding an agent would introduce uncertainty without adding useful capability.
Option 2: A workflow for known steps
A workflow is useful when a task has several steps, but those steps are known before execution begins.
For example, a weekly Study Planner workflow might:
collect upcoming deadlines;
rank subjects by urgency;
assign study blocks to available time;
validate that no deadline was missed; and
send the completed timetable.
Some steps might call an AI model. The ranking step could ask a model to classify difficult notes, for example. That still does not automatically make the whole system an agent. If your application controls the order and chooses what happens next, it is a workflow.
Workflows are attractive when predictability, repeatability, auditability, and stable cost matter more than flexible decision-making.
Option 3: An agent for a path that can change
An agent becomes useful when you cannot completely specify the path in advance.
Suppose a learner misses a study session. A Study Planner Agent could:
inspect the learner’s remaining topics;
compare them with upcoming deadlines;
notice that one high-priority topic has not been covered;
choose whether to read the calendar, revise the timetable, or ask the learner a question;
update the plan; and
check whether the new plan is realistic.
The important difference is not that the task has many steps. The difference is that the system must decide which step or tool is appropriate from the current state.
That flexibility has a cost. Agents can require more model calls, take longer, and create more opportunities for errors to compound. They need clear tools, guardrails, stopping conditions, testing, and human approval for sensitive actions.
Code vs workflow vs agent
Question | Ordinary code | Workflow | Agent |
|---|---|---|---|
Is the main logic known in advance? | Yes: one rule or transformation | Yes: an ordered process | Only partly |
Who chooses the next step? | The code | The workflow definition | The model within guardrails |
Best fit | Calculations, validation, formatting | Repeatable multi-step processes | Ambiguous tasks with changing paths |
Predictability | Highest | High | Variable |
Typical cost and latency | Lowest | Moderate | Usually higher |
Main risk | Incorrect rule | Incorrect process design | Poor decisions or compounding errors |
These are architecture choices, not rigid product labels. Real systems can combine them. An agent may call ordinary functions, and a workflow may include one model-powered classification step.
A three-question decision guide
Ask these questions in order:
1. Is this one predictable rule or transformation?
If yes, start with ordinary code.
2. Can I list the required steps before the task starts?
If yes, use a workflow and make each step observable and testable.
3. Must the system choose its next action from changing information?
If yes, an agent may add value. Define the allowed tools, success condition, boundaries, and points where a person must approve an action.
The order matters. Do not jump directly to Question 3 just because an AI model is available.
Try this today
Choose one task you perform repeatedly. It could be preparing a weekly report, planning study time, reviewing support requests, or organizing meeting notes.
Write down:
Rule: Is there one predictable transformation?
Steps: Can the full sequence be listed in advance?
Decisions: Could new information change what should happen next?
Then classify the task as ordinary code, a workflow, or an agent.
Completed example you can copy
Task: Create a weekly study plan.
Rule: Total the learner’s available hours.
Steps: Collect deadlines → rank subjects → assign study blocks → validate the schedule → send the plan.
Decisions: If the learner missed a topic, the system may need to inspect progress, compare deadlines, ask a question, and choose which part of the plan to revise.
Choice: Begin with a workflow for the normal weekly plan. Add an agent only for exception handling when the next action cannot be safely predetermined.
Why: Most runs remain predictable and testable, while flexible decision-making is reserved for the cases that need it.
Common mistakes
Mistake 1: Calling every model-powered application an agent
A single model call that summarizes text is not automatically an agent. Look at who controls execution and chooses the next action.
Mistake 2: Using an agent because the task has many steps
Many steps can still form a deterministic workflow. Step count alone does not require autonomy.
Mistake 3: Treating workflows and agents as mutually exclusive
They can be combined. A workflow can invoke an agent for one uncertain branch, while keeping the rest of the process deterministic.
Mistake 4: Ignoring the operational trade-off
Greater flexibility can mean higher latency, cost, and testing effort. Add autonomy only when it improves the outcome enough to justify those trade-offs.
Mistake 5: Giving an agent unlimited freedom
Flexible does not mean unrestricted. An agent still needs limited tools, clear instructions, stopping conditions, and approval gates for consequential actions.
Knowledge check
1. A system converts minutes into hours using a fixed formula. What should you use?
Ordinary code. The transformation is fully predictable.
2. A system always collects deadlines, ranks subjects, creates a timetable, and emails it. What should you use?
A workflow. The steps and their order are known in advance.
3. A system must inspect progress and decide whether to revise a timetable, retrieve notes, or ask the learner a question. What may be appropriate?
An agent, because the next action depends on changing context.
4. Can a workflow contain an AI model call?
Yes. The architectural distinction depends on how execution is controlled, not simply on whether a model is present.
Download the handwritten notes
day-16-handwritten-notes.pdfUse the one-page notes as a quick reference whenever you are choosing between code, a workflow, and an agent.
Continue learning with Korshub
If you want to go deeper, explore Korshub learning resources on AI engineering, tool-connected agents, retrieval, and Model Context Protocol. Check the current course pages for availability and enrolment details rather than relying on temporary offers.
Navigation
Previous: Day 15 — Build a Notes Q&A Agent
Roadmap: AI Agents in 30 Days
Next: Day 17 — State and Orchestration