Workflow vs Agent with Claude: Choosing the Right Architecture
👋 In plain words: A workflow is a recipe your code follows step by step, calling Claude where needed. An agent lets Claude decide the steps itself, using tools, until the job is done. Agents are more flexible but harder to predict and audit. This lesson helps you choose, one requirement at a time.
“Build an agent” is the most over-used phrase in AI projects. Many tasks are better as workflows: cheaper, faster, easier to test and to audit. The CCDV-F exam asks you to evaluate whether a workflow or an agentic architecture fits given business requirements, error tolerance and audit constraints, and to pick the runtime. In this lesson you will learn the five common workflow patterns, run a routing workflow, and apply a decision checklist to QA scenarios.
🔑 Key terms
- Workflow: a system where your code defines the sequence of steps; Claude performs some of them.
- Agent: a system where Claude chooses the next step (which tool, in what order) in a loop until the goal is reached.
- Orchestrator: the part that splits a task and coordinates workers or subagents.
- Harness: the code that runs an agent’s loop, tools and permissions.
- Audit trail: a record of what was done, by whom and why, that a reviewer can check.
🪜 Step 1: Know the five workflow patterns
Most production Claude systems are one of these, or a combination:
| Pattern | How it works | QA example |
|---|---|---|
| Prompt chaining | Fixed sequence; each step’s output feeds the next | Extract rules → generate cases → review (Lesson 17) |
| Routing | A first call classifies the input; code sends it to a specialised path | Route a failure to the UI, API or environment handler |
| Parallelisation | Independent subtasks run at once, or several votes are combined | Summarise 50 failing tests concurrently |
| Orchestrator–workers | A central call splits the task dynamically and delegates parts | Split a large test plan by feature for separate writers |
| Evaluator–optimiser | One call produces, another critiques, repeat until a bar is met | Generate a test, review it against standards, refine |
In all five, your code decides the flow. That is what makes them predictable.
🪜 Step 2: See a routing workflow
A cheap first call classifies; the code then calls the right specialist. Claude never decides the overall flow:
📄 router.py
import anthropic
client = anthropic.Anthropic()
ROUTES = {
"ui": "You debug Selenium/Playwright UI failures. Suggest the most likely locator or timing fix.",
"api": "You debug API test failures. Point to the request, status code or schema problem.",
"environment": "You debug test environment problems. Name the service and the check to run.",
}
def classify(failure: str) -> str:
r = client.messages.create(
model="claude-haiku-5-5", max_tokens=5, output_config={"effort": "low"},
system="Classify the test failure as ui, api or environment. Reply with one word.",
messages=[{"role": "user", "content": failure}],
)
return r.content[0].text.strip().lower()
def handle(failure: str) -> str:
route = classify(failure)
system = ROUTES.get(route, ROUTES["environment"]) # fall back deterministically
r = client.messages.create(model="claude-opus-5-5", max_tokens=300, system=system,
messages=[{"role": "user", "content": failure}])
return f"[{route}] {r.content[0].text}"
print(handle("POST /api/orders returned 422: field 'qty' must be > 0"))
print(handle("TimeoutError: locator('#pay').click: element is not visible"))⌨️ Terminal
python router.py🖥️ Output (sample run)
[api] The request sends qty = 0 or a negative value; fix the test data so qty is at least 1.
[ui] The Pay button is hidden, likely behind a loading overlay; wait for the overlay to disappear before clicking.
- Haiku at low effort is enough for classification; the specialist call uses Opus.
- Each route can be tested on its own, and an unknown label falls back in code, not by the model’s choice.
🪜 Step 3: Know what makes an agent different
In an agent, Claude receives tools and a goal, and decides which tool to call next based on what it has seen, looping until it judges the job done (Lesson 32 builds one). That gives:
- Flexibility: it can handle paths nobody coded (“the order was delivered but the customer says it wasn’t, so check the delivery photo”).
- Cost and latency: more calls, more tokens, longer runs.
- Less predictability: the same input can take different paths, which makes testing and auditing harder.
- Compounding errors: an early mistake can steer later steps; you need checkpoints and guardrails.
🪜 Step 4: Decide with a checklist
Choose an agent only if all of these are true; otherwise stay with a workflow:
- Complexity: the steps cannot be fully specified in advance (open-ended exploration, varying paths).
- Value: the result justifies the higher cost and latency.
- Viability: Claude is demonstrably good at this kind of task (measure it).
- Cost of error: mistakes can be caught and recovered from (tests, reviews, rollback, approvals).
Then weigh the two constraints the exam names:
- Error tolerance: low tolerance (payments, production changes) → fixed workflow steps, or an agent with deterministic gates and human approval for risky actions.
- Audit constraints: if every decision must be traceable to a rule, a workflow (or an agent with full traces and fixed checkpoints) is easier to defend.
This helper encodes the checklist. It runs locally:
📄 choose_architecture.py
def choose(steps_known_in_advance: bool, value_justifies_cost: bool, model_proven: bool,
errors_recoverable: bool, strict_audit: bool) -> str:
if steps_known_in_advance:
return "workflow"
if not (value_justifies_cost and model_proven and errors_recoverable):
return "workflow (simplify the task or keep a human in the loop)"
if strict_audit:
return "agent with deterministic checkpoints, full traces and human approval for risky steps"
return "agent"
scenarios = {
"Generate pytest cases from a fixed requirement template": (True, True, True, True, False),
"Investigate any red CI build and propose a fix in a PR": (False, True, True, True, False),
"Auto-approve refunds from support chats": (False, True, True, False, True),
"Migrate 400 Selenium tests to Playwright with review": (False, True, True, True, True),
}
for name, args in scenarios.items():
print(f"{name:<58} -> {choose(*args)}")⌨️ Terminal
python choose_architecture.py🖥️ Output
Generate pytest cases from a fixed requirement template -> workflow
Investigate any red CI build and propose a fix in a PR -> agent
Auto-approve refunds from support chats -> workflow (simplify the task or keep a human in the loop)
Migrate 400 Selenium tests to Playwright with review -> agent with deterministic checkpoints, full traces and human approval for risky steps
🪜 Step 5: Decompose before you build
When an agent is right, decide how to split it:
- Single agent with tools for most tasks. Simplest to debug.
- Orchestrator + subagents when subtasks are independent and context-heavy (each subagent reads a lot and returns a short result), or need different tools or permissions (Lesson 34).
- Keep subagent responsibilities narrow, inputs explicit, and outputs structured, so the orchestrator can check them.
🪜 Step 6: Choose the runtime
The exam also asks where the agent runs:
| Option | You host | Choose when |
|---|---|---|
| Self-hosted harness: your own loop, the Tool Runner, or the Claude Agent SDK | The loop, tools and compute | You need full control, run in your network, or your platform lacks managed agents |
| Managed, sandboxed runtime: Claude Managed Agents (beta) | Nothing; Anthropic runs the loop and a per-session container | Long-running or scheduled agents, file-heavy work, and you would rather not operate the infrastructure |
Check data-handling and platform requirements first: managed runtimes keep session data with the provider and are not available on every cloud platform.
🌍 Real-world example: Ravi’s two systems
Ravi’s team first built “an agent” to turn requirements into test cases. Runs varied, cost was high, and reviewers could not tell why a case was included. They rebuilt it as a three-step chain with a review step, and costs fell by 70%. They kept an agent for one job only: investigating red nightly builds, where the path really is different every time, with a hook that blocks any write outside the tests/ folder.
🧪 Practice Questions
Question 1. A team must generate release notes from merged pull requests in a fixed format every week. Steps never change, and compliance requires each line to be traceable to a PR. What architecture fits?
- A. A workflow (prompt chain) with code-controlled steps
- B. A fully autonomous agent with web search
- C. A multi-agent system with five subagents
- D. A managed agent with no tools
Show answer
Answer: A. The steps are known and auditability is required; a workflow is cheaper, predictable and traceable.
Question 2. Which condition most strongly argues for an agent rather than a workflow?
- A. The task needs Claude to classify text
- B. The path to the goal varies by case and cannot be specified in advance
- C. The team wants the newest technology
- D. The output must be JSON
Show answer
Answer: B. Agents earn their cost when the steps depend on what is discovered along the way.
Question 3. Which two are reasons to choose Claude Managed Agents over a self-hosted Agent SDK harness? (Choose 2.)
- A. The team does not want to operate the agent loop and sandbox infrastructure
- B. The agent must run inside a private network with no external access
- C. The agent runs on a schedule and works with files in a per-session container
- D. The cloud platform in use does not support managed agents
Show answer
Answer: A and C. Managed Agents host the loop and a per-session container, which suits scheduled, file-heavy work. Private-network and unsupported-platform constraints point to self-hosting.
Question 4. A routing workflow sends failures to specialist prompts. A new failure type appears that the classifier labels “database”. What should the code do?
- A. Let Claude decide a new route on the fly
- B. Fall back deterministically to a default handler and log the unknown label
- C. Crash so someone notices
- D. Retry the classifier until it returns a known label
Show answer
Answer: B. Routing stays code-controlled: unknown labels go to a defined fallback and are logged for review.
📝 Assignment
- Task 1: List three Claude ideas for your team and run them through
choose_architecture.py.
✅ Done when: each has an architecture and a one-line reason tied to the checklist. - Task 2: Extend
router.pywith adataroute for test-data problems and a unit test for the fallback.
✅ Done when: an unknown label routes to the default and the test passes. - Stretch: Turn one of your workflows into an evaluator–optimiser loop with at most two refinement rounds and a pass/fail rubric.
✅ Done when: the loop stops either on pass or after two rounds, and logs why.
❓ Frequently Asked Questions
🤔 What is the difference between an AI workflow and an AI agent?
In a workflow your code fixes the steps. In an agent, the model decides the next step and which tools to use, in a loop.
🤔 When should I use an AI agent?
When the task is open-ended, valuable enough to justify the cost, something the model is proven good at, and when errors can be caught and recovered from.
🤔 What are agentic workflow patterns?
Prompt chaining, routing, parallelisation, orchestrator–workers and evaluator–optimiser. They structure model calls with code-controlled flow.
🤔 Are agents harder to test?
Yes. Paths vary between runs, so you test outcomes and properties with evaluations and traces, and add deterministic checkpoints for risky steps.
🏁 Summary
- Workflows: code decides the steps (chaining, routing, parallelisation, orchestrator–workers, evaluator–optimiser).
- Agents: Claude decides the steps; use them only for open-ended, valuable, recoverable tasks.
- Low error tolerance and strict audits push toward workflows or gated agents.
- Prefer a single agent; add subagents for independent, context-heavy subtasks.
- Self-host the harness for control; use Managed Agents to avoid running the loop and sandbox.
Next, continue with Build a Claude Agent Loop from Scratch in Python.
Independent study material by SQA Tools. Not affiliated with, endorsed by or sponsored by Anthropic. Claude is a trademark of Anthropic. Practice questions are original, not real exam content. Code outputs marked “sample run” come from running the exact code against a local stand-in for the Claude API, so real replies, IDs and token counts will differ. Exam facts checked against Anthropic’s official CCDV-F exam guide v1.1 on 24 Nov 2026.