04. Agentic Workflows
Understanding Agentic Workflows
An agentic workflow is a controlled multi-step process that uses an LLM policy, tools, and state to move from a goal to a verified outcome — with branching, retries, and stop rules when the path is uncertain.
What you will learn
- Define an agentic workflow clearly
- Contrast workflows with fixed pipelines and plain chat
- Name the core building blocks of a workflow
- Sketch a simple workflow for a real task
- Answer interview questions with short, solid answers
Definition
An agentic workflow is the operational design of how an agent runs over time: which steps exist, how state is stored, when tools fire, how branches and loops work, and what counts as finished or failed.
It sits above a single model call and below a whole product. Frameworks (LangGraph, CrewAI flows, Temporal + LLM workers, custom orchestrators) implement workflows — they are not the definition.
Introduction
This lesson opens Module 04 (Agentic Workflows). Module 03 covered components (LLM, prompts, memory, tools). Workflows assemble those components into repeatable runs.
Later lessons detail Observe–Think–Act, ReAct, scheduling, patterns, HITL, and error recovery.
Why workflows matter
- Make agent behavior inspectable and testable
- Encode retries, approvals, and budgets as first-class steps
- Support production ops: replay, metrics, SLAs
- Prevent “giant prompt” systems with hidden control flow
Workflow vs pipeline vs chat
Not every automation needs an agentic workflow. Choose the lightest control style that works.
- Chat turn - one LLM response; little durable state
- Fixed pipeline - predetermined A→B→C (ETL, CI stages)
- Agentic workflow - next step chosen from state + policy + tools
- Hybrid - fixed outer pipeline with an agentic step inside
Building blocks
Name the pieces before you draw boxes in a vendor UI.
- Trigger - user message, cron, webhook, queue job
- State - goal, memory, variables, step cursor
- Steps - LLM calls, tool calls, pure code transforms
- Router - choose the next edge from conditions or model output
- Gates - policy checks and human-in-the-loop approvals
- Loops - retry, replan, or iterate until verifier passes
- Sink - success, failure, alert, or handoff
Properties of a good agentic workflow
- Explicit goal and done check
- Typed state you can log and resume
- Bounded loops (max steps / cost / time)
- Idempotent or safely retryable side effects
- Observable traces per run id
- Clear ownership of secrets and tool authz
Example: support triage workflow
Trigger: new ticket. State: ticket id, customer tier, draft. Steps: classify → retrieve policy → draft reply → (if refund) HITL gate → send → verify status. Sink: closed or escalated.
- Router after classify - billing vs tech vs spam
- Loop - regenerate draft if tone check fails (cap 2)
- Gate - human approve refunds over a threshold
- Done - ticket status updated and message sent logged
Mapping to Agentic AI stacks
- LangGraph / state machines - explicit graphs and checkpoints
- Crew / multi-agent flows - steps owned by roles
- Serverless queues - each step a worker; state in DB
- Notebook demos - fine for learning; add sinks and budgets for prod
Program / implementation notes
Start with a thin state schema and three steps. Add routers and HITL only when a real branch appears. Version workflow definitions like code.
- Give every run a correlation id from trigger to sink
- Prefer verifier steps after mutate steps
- Fail closed on unknown router outputs
- Next: Observe – Think – Act Cycle
Advantages and limitations
- Advantage: adaptive paths under uncertainty
- Advantage: production controls (gates, budgets, traces)
- Advantage: reusable patterns across products
- Limitation: more moving parts than a script
- Limitation: bad state design makes resume/debug hard
- Limitation: over-agentic designs where a pipeline would do
Key points
- Agentic workflows are stateful, goal-seeking control designs with tools and stop rules.
- They differ from fixed pipelines by choosing next steps from observations.
- Building blocks: trigger, state, steps, router, gates, loops, sink.
- Always bound loops and verify done.
- Frameworks implement workflows — design the graph first.
- Hybrid pipelines + agentic steps are a common sweet spot.
FAQs
Is a chatbot an agentic workflow?
Usually not by itself. It becomes one when you add durable state, multi-step tool use, routing, and explicit completion/failure paths.
Do I need LangGraph to have a workflow?
No. Any orchestrator with state and step transitions can implement one. Graphs help when branching gets complex.
When should I keep a fixed pipeline?
When the sequence is stable, validators are deterministic, and runtime LLM decisions would add cost without quality gains.
What is the difference between a workflow and a single agent loop?
A single loop is one pattern inside a workflow. A workflow can include multiple loops, parallel branches, HITL gates, and fixed stages.
Interview questions
- What is an agentic workflow?
Answer A controlled multi-step process where an agent uses state, tools, and a policy to pursue a goal with branching, retries, and clear stop conditions.
- How does it differ from a traditional pipeline?
Answer Pipelines follow a predetermined path; agentic workflows choose or adapt next steps based on observations and goals.
- What are the main building blocks?
Answer Triggers, state, steps (LLM/tool/code), routers, gates (policy/HITL), loops, and sinks (done/fail/escalate).
- Why do workflows need explicit state?
Answer So runs can resume, audit decisions, bound progress, and share context across steps without relying on a hidden chat blob.
- When would you use an agentic workflow?
Answer When tasks need tool use under uncertainty — triage, research+act, coding fixes — with approvals and verifiers along the path.
- How do you keep workflows safe?
Answer Allowlisted tools, HITL on risky writes, step/cost budgets, fail-closed routing, and full run traces.
- Give a one-line example.
Answer “On new bug ticket: reproduce → locate → patch → run tests → (fail? replan : open PR) with a human gate before merge.”
Related topics
Practice task
Complete each numbered practice step in a notebook or doc before opening the next lesson.
- Write a one-paragraph definition of agentic workflow vs fixed pipeline.
- List trigger, state fields, steps, gates, and sink for a “weekly report” agent.
- Mark which steps are LLM, tool, code, or HITL.
- Add two loop bounds (max retries, max cost) and one verifier.
- Answer interview questions 1, 2, and 3 in two sentences each.