← Master Index
Vol. 15 Module 15.1 Lecture

Agentic Workflow

Agent Fundamentals

How This Lesson Fits the Module & Volume

The agent loop is powerful and expensive. An agentic workflow is the production compromise: a mostly explicit pipeline (Vol. 14 Haystack / LangChain / LangGraph) with agentic nodes only where the next hop is genuinely unknown. This lecture is how AI engineers stop turning every FAQ into an unbounded ReAct spiral.

It also sets up the last three lectures: when one single agent node is enough, when a multi-agent subgraph helps, and where HITL gates live on the graph.

Learning Objectives

By the end of this lesson, students should be able to:

  • Define agentic workflow vs fully free agent vs fully deterministic pipeline.
  • Choose the control style using risk, variability, and SLA constraints.
  • Sketch a hybrid graph: retrieve → (optional agent) → validate → write.
  • Explain why most enterprise “agents” should be workflows with agentic pockets.
  • Map Haystack/LangChain DAGs and LangGraph cycles onto this spectrum.
  • Avoid marketing “agentic” as a synonym for “uses an LLM.”
Definition

An agentic workflow is an application whose overall control flow is an explicit graph or pipeline, but one or more nodes may invoke an LLM agent loop (plan, tools, limited steps) before returning structured results to the next deterministic step. Agency is localized, not global.

Three Control Styles

StyleWho routes?PredictabilityExample
Deterministic workflowDeveloper DAGHighestHaystack RAG FAQ
Agentic workflowGraph + local agent nodesMediumRetrieve → research agent → schema check → ticket
Free agentModel + halt rules onlyLowestOpen-ended coding assistant

Hybrid Graph Sketch

Keep writes and schema validation outside the free loop. Let the agent only explore (search, compare, draft). That preserves autonomy bounds while still using tools.

from typing import TypedDict from langgraph.graph import StateGraph, START, END class WFState(TypedDict): question: str context: str draft: str ticket_id: str | None needs_agent: bool def classify(state: WFState) -> dict: q = state["question"].lower() return {"needs_agent": any(w in q for w in ["compare", "why", "investigate"])} def retrieve(state: WFState) -> dict: return {"context": "Refunds 5–7 days. SSO resets via IT."} def agent_research(state: WFState) -> dict: # bounded agent loop: max 3 tool steps, read-only tools return {"draft": "SSO users must contact IT; refunds 5–7 days after approval."} def template_answer(state: WFState) -> dict: return {"draft": f"Based on docs: {state['context']}"} def validate(state: WFState) -> dict: assert state["draft"], "empty draft" return {} def maybe_ticket(state: WFState) -> dict: if "escalate" in state["draft"].lower(): return {"ticket_id": "TCK-100"} return {"ticket_id": None} def after_classify(state: WFState) -> str: return "agent_research" if state["needs_agent"] else "template_answer" g = StateGraph(WFState) g.add_node("classify", classify) g.add_node("retrieve", retrieve) g.add_node("agent_research", agent_research) g.add_node("template_answer", template_answer) g.add_node("validate", validate) g.add_node("maybe_ticket", maybe_ticket) g.add_edge(START, "retrieve") g.add_edge("retrieve", "classify") g.add_conditional_edges("classify", after_classify) g.add_edge("agent_research", "validate") g.add_edge("template_answer", "validate") g.add_edge("validate", "maybe_ticket") g.add_edge("maybe_ticket", END) app = g.compile() print(app.invoke({"question": "Why was my SSO reset denied?", "context": "", "draft": "", "ticket_id": None, "needs_agent": False}))

How to Choose

Stay deterministic

  • Stable FAQ / RAG
  • Hard latency SLAs
  • Regulated exact wording

Agentic pocket

  • Variable research hops
  • Need tools, then a schema
  • Writes stay outside the loop

Free agent

  • Open-ended goals
  • Sandbox only
  • Human watching or tight caps

Strengths

  • Debuggable topology
  • Lower average cost than free loops
  • Fits Vol. 14 skills
  • Natural HITL edges

Tradeoffs

  • More design up front
  • Can over-graph simple chats
  • Agent nodes still need budgets
  • Classification errors route wrong
Common Misconception

“Agentic means we deleted the workflow and let the model run the company.” In serious systems, agentic means the opposite: you kept the workflow and leased a few steps to a bounded loop. If you cannot draw the graph, you do not have a workflow—you have a hope.

Knowledge Check

  1. Short Answer: Define agentic workflow in one sentence. Answer: An explicit pipeline/graph with localized agent loops at some nodes.
  2. True/False: Every LLM app is an agentic workflow. Answer: False.
  3. Multiple Choice: Writes in the sketch happen: (a) inside unbounded ReAct, (b) after validate / maybe_ticket, (c) in CSS. Answer: (b).
  4. Short Answer: When should you stay fully deterministic? Answer: Stable RAG/FAQ, hard SLAs, regulated wording (any fair answer).
  5. True/False: Haystack pipelines are closer to deterministic workflows than free agents. Answer: True.
  6. Multiple Choice: LangGraph is especially useful here because: (a) it themes HTML, (b) it can mix deterministic edges with cyclic agent nodes, (c) it trains CNNs. Answer: (b).
  7. Short Answer: Why classify before the agent node? Answer: Avoid paying for a free loop on simple questions.
  8. Short Answer: Name a risk of hybrid graphs. Answer: Mis-routing, leftover unbounded nodes, or over-engineering (any).
  9. Multiple Choice: Free agents fit best when: (a) goals are open-ended and sandboxed, (b) invoices must match a template exactly, (c) you need 20ms p99. Answer: (a).
  10. True/False: Agentic nodes still need step budgets. Answer: True.

Key Takeaways

  • Agentic workflows localize agency inside an explicit graph—usually the right production shape.
  • Deterministic RAG remains best for stable Q&A; free agents for open sandbox goals.
  • Keep writes and validators outside unbounded loops.
  • Vol. 14 orchestration + Vol. 15 loops combine here.
  • Next: single-agent design for those agentic nodes.
Trainer’s Guide

Whiteboard: Take an internal “research then file Jira” process. Draw deterministic vs agentic vs free. Circle the write.

Lab: Add a classifier feature flag: force needs_agent=False and compare cost/quality on 20 FAQ prompts.

Recap: Prefer workflows with agentic pockets. Continue with Single Agent.