Skip to content
/

Agents and workflows

ConceptsChapter 3 of 142 min read

The difference between a prompt, a workflow, and an agent comes down to one question: who decides what to do next?


Prompts, workflows, and agents#

  • Single prompt: Input text goes in, output text comes back. One call, zero branching.
  • Workflow (e.g., RAG): Code executes predetermined steps in a fixed sequence.
  • Agent: An LLM evaluates a goal, inspects tool outputs, and dynamically chooses the next action in a loop.
Drawing diagram…
A workflow executes a predetermined sequence; an agent loops dynamically.

Comparison#

ArchitectureControl flowLLM calls per runAdaptabilityCost & latency
PromptUser1NoneLowest
WorkflowApplication codeFixedHandles anticipated edge casesPredictable
AgentLLMVariableHandles unexpected formats & outputsHigher

Why agents?#

Use an agent when the steps required to complete a task cannot be predicted upfront:

  • Handling unstructured inputs: Contract formats vary widely across vendors—Word files, scans, custom clauses.
  • Dynamic recovery: If an initial search returns incomplete terms, an agent can re-query with modified parameters instead of failing.
  • Task specialization: Complex jobs are divided among specialized personas (e.g., term extraction, risk analysis, fact-checking).

When not to use agents#

Agents introduce non-deterministic execution paths, higher token costs, and longer latency.

Decision Checklist#

  1. Can every step be defined at build time? Build a deterministic workflow.
  1. Can a single prompt return the required output? Use a single prompt.
  1. Do next steps depend on unpredictable runtime findings? Build an autonomous agent.