By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
A compliance team automated a monthly report. The agent gathered the figures, drafted the summary, and skipped the reviewer because the data looked clean. The report went out unsigned. When an auditor asked who approved it, nobody could answer.
The requirement was never review usually happens. It was nothing is published without a reviewer. A prompt cannot promise that. A branch can.
A workflow has fixed steps owned by code. An agent chooses its steps at run time. Both can call the same tools and use the same model. The difference is who owns the control flow.
| Question | Choose the workflow | Choose the agent |
|---|---|---|
| Is the path known in advance? | Yes, and it repeats | No, it depends on what you find |
| Must the run be auditable? | Yes: the same steps produce the same log | No, or you log the decisions instead |
| Is the cost per run predictable? | Yes, by design | No, but you cap it |
| How costly is a skipped step? | High: the code should refuse | Low: the model can adapt |
| Is the task open-ended? | No | Yes |
The exam asks you to pick, not to admire. Choose the workflow when the path is known and auditable. Choose the agent when the path depends on what you find, and put gates around the parts that cannot fail.
The branches are if statements in your program. When validation fails, the run stops. No prompt can talk it out of stopping, and no retry can turn a rejected input into an accepted one.
A workflow you can audit has four code-owned moves, in this order.
Validate the input against the schema before a model call or a tool call.
Run the fixed steps in order and record each one as it completes.
Gate each handoff with a condition that can fail and an owner who can refuse.
Store the approval beside the artifact, with an id you can look up later.
A handoff is the moment one step passes work to the next. The contract says what may cross and what must stay behind.
| Handoff | What moves | What must not move |
|---|---|---|
| Request to gather | The fields the schema requires | Free-text wishes the schema cannot check |
| Gather to draft | Validated facts and their source ids | Raw tool payloads and retry noise |
| Draft to reviewer | Draft, citations, open questions | The model's internal reasoning |
| Reviewer to publish | Approval id and reviewer id | Partial or implied approval |
A handoff contract is what makes a workflow debuggable. When the output is wrong, you can ask which boundary passed the wrong thing.
The next snippet is a workflow with two gates. The first checks the required facts. The second waits for a reviewer. Both are ordinary Python, so both are unit-testable without a model.
class GateError(Exception):
"""Raised when a code-owned step refuses to hand off."""
def gather(request):
return {"revenue": 1240, "headcount": 38}
def draft(facts):
return f"Revenue {facts['revenue']}, headcount {facts['headcount']}."
def approve(text):
# A real reviewer decision. The model is not consulted here.
return {"approved": True, "reviewer": "sam"}
def publish(text, reviewer):
return f"published by {reviewer}"
def run_report(request, gather, draft, approve, publish):
done = []
facts = gather(request)
missing = [key for key in request["required"] if key not in facts]
if missing:
raise GateError(f"missing facts: {missing}")
done.append("gather")
text = draft(facts)
review = approve(text)
if not review["approved"]:
raise GateError("reviewer declined")
done.append("review")
publish(text, review["reviewer"])
done.append("publish")
return done
for required in (["revenue", "headcount"], ["revenue", "churn"]):
try:
print(run_report({"required": required}, gather, draft, approve, publish))
except GateError as err:
print("blocked:", err)Read the output in two parts. The valid request completes three steps. The request missing churn never reaches the draft. That is the property worth testing: not that the model usually behaves, but that the code cannot publish without approval.
Key takeaways
A workflow owns its steps in code; an agent chooses its steps at run time.
Choose the workflow when the path is known and auditable; choose the agent when it depends on what you find.
Enforcement belongs in code. A prompt is a hint, not a gate.
Every handoff has a contract: what moves, and what must not.
A gate you cannot unit-test is not a gate.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.