Coding Now – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 9667708830
Back to Agentic AI Notes
Topic #106

Agent vs Workflow

A workflow follows a predetermined sequence of steps — the path is fixed by the developer, even if an LLM performs individual steps. An agent lets the LLM itself decide the sequence of steps dynamically, based on what happens along the way.

Side-by-Side

WorkflowAgent
Who decides the next step?The developer, in code, ahead of timeThe LLM, dynamically, at runtime
PredictabilityHigh — the same input roughly follows the same pathLower — the path can vary based on the model's decisions
Easier to test?Yes — fixed steps are straightforward to unit testHarder — requires evaluating decision quality across varied scenarios
Good forWell-understood, repeatable processesTasks where the right steps can't be fully predetermined

Example — Same Task, Both Approaches

# Workflow: fixed sequence, LLM used only for the "extract" and "summarize" steps
def process_document(doc):
    text = extract_text(doc)              # fixed step
    entities = llm_extract_entities(text)  # LLM used, but always runs, always this order
    summary = llm_summarize(text)          # fixed step
    return {"entities": entities, "summary": summary}

# Agent: LLM decides what's needed based on the document
def process_document_agentically(doc, agent):
    # Agent might decide: this doc needs OCR first, then extraction, then a
    # follow-up entity lookup — or skip straight to summarization for a short doc.
    # The exact steps are NOT fixed in code; the LLM chooses them at runtime.
    return agent.run(goal="Process this document", input=doc)

When to Prefer a Workflow

If you can write down the correct sequence of steps ahead of time and it rarely needs to change, a workflow is almost always the better engineering choice — more predictable, cheaper (fewer LLM calls making decisions), easier to debug, and easier to test exhaustively. Reach for an agent specifically when the right sequence of steps genuinely depends on information only available at runtime.

Practical Use Case

Generating a weekly sales report from a fixed data source is a workflow — the steps never change. Investigating "why did sales drop last week?" is a better fit for an agent — the right sub-questions to explore depend entirely on what the data shows at each step.

Common Mistakes

  • Defaulting to an agent for tasks that are actually well-defined, fixed sequences — adds cost, latency, and unpredictability with no real benefit
  • Building a rigid workflow for a task that genuinely needs dynamic branching, resulting in constant special-casing in code as new scenarios appear

Interview Relevance

"When would you choose a deterministic workflow over an agent?" is one of the most practically important agentic AI interview questions — a good answer focuses on predictability, testability, and whether the task's steps can genuinely be known ahead of time.

Practice Question

Decide workflow vs agent for: (1) converting an uploaded CSV to a fixed report format, (2) diagnosing why a specific customer's payment failed by checking multiple systems.

Related Notes

Want to go beyond the notes?

Join CodingNow's Agentic AI course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →