Skip to main content

Anatomy of Agentic Workflows

Workflow patterns, critic loops, routing, and execution.

Agentic Workflows

Orchestrating multiple AI agents, tools, and humans to ship real outcomes โ€” reliably.


TL;DRโ€‹

  • An agentic workflow chains plans, tools, sub-agents, and humans to complete a goal.
  • Core building blocks: Planner โ†’ Executor โ†’ Critic โ†’ Memory โ†’ Tools โ†’ Human Gate.
  • Patterns: sequential, parallel fan-out, router, reflect-and-retry, plan-and-act.
  • Add observability and kill-switches before scaling.

Why this mattersโ€‹

A single LLM call is a calculator. An agentic workflow is an assembly line โ€” predictable, observable, and tunable. It's how AI moves from "demo" to "production".

Bottom line: The workflow, not the model, is the real product.


The Big Pictureโ€‹

Bottom line: Plan โ†’ act โ†’ check โ†’ (loop) โ†’ ship.


Core Rolesโ€‹

RolePurpose
PlannerDecomposes the goal into steps
ExecutorRuns steps; calls tools
Critic / ValidatorChecks each step's output
MemoryShort-term + long-term context
Tools / MCPExternal capabilities
SubagentsSpecialists for sub-tasks
Human GateApproval before risky actions

Workflow Patternsโ€‹

1. Sequential pipelineโ€‹

goal โ†’ step1 โ†’ step2 โ†’ step3 โ†’ done

2. Parallel fan-outโ€‹

โ”Œโ”€ analyze
goal โ”€ plan โ”ผโ”€ test
โ””โ”€ document

3. Router (pick the right agent)โ€‹

goal โ†’ router โ†’ @code-reviewer | @security-auditor | @docs-writer

4. Reflect-and-retryโ€‹

attempt โ†’ critic โ†’ (fail) โ†’ reflect โ†’ retry โ†’ critic โ†’ done

5. Plan-and-act (ReAct)โ€‹

Loop of Thought โ†’ Action โ†’ Observation until done.


Step-by-Step Setupโ€‹

1. Define the goal in plain Englishโ€‹

"Ship a tested, reviewed fix for issue #1234."

2. Decompose into a plan (plan.yml)โ€‹

goal: "Fix issue #1234"
steps:
- id: triage
agent: bug-triage
output: triage_report
- id: tests
agent: test-writer
depends_on: [triage]
- id: implement
agent: claude-code
depends_on: [tests]
- id: review
agent: code-reviewer
depends_on: [implement]
- id: human_gate
type: approval
depends_on: [review]
- id: ship
type: merge_pr
depends_on: [human_gate]

3. Wire memoryโ€‹

"memory": {
"short_term": { "type": "in_session" },
"long_term": { "type": "vector_store", "index": "project-memory" }
}

4. Add critics / validatorsโ€‹

critics:
- name: tests_pass
rule: "exit_code == 0"
- name: coverage
rule: "coverage >= 0.8"
- name: no_secrets
rule: "secret_scan == clean"

5. Run & observeโ€‹

claude workflow run plan.yml --observe

Variants for Different Team Settingsโ€‹

๐Ÿ‘ค Soloโ€‹

Sequential, no human gate. Critic = your own eyes.

๐Ÿ‘ฅ Small teamโ€‹

Add a @code-reviewer critic + Slack notification on completion.

๐Ÿข Enterpriseโ€‹

  • Human gates on every risky step.
  • Full audit trail to SIEM.
  • Kill-switch env var (CLAUDE_WORKFLOW_STOP=1).
  • Rate limits + budget caps.
limits:
max_tokens_per_run: 200000
max_cost_usd: 5.00
max_runtime_minutes: 30

๐ŸŒ Open-sourceโ€‹

  • Publish workflows as templates in a community repo.
  • Document expected inputs/outputs.

Bottom line: Same skeleton, escalating governance.


Anatomy of a Single Stepโ€‹

- id: review
agent: code-reviewer
input: { branch: feature/fix-1234 }
tools: [Read, Bash, Grep]
timeout: 120s
retries: 2
critics: [no_high_severity_issues]
on_fail: rollback
on_success: notify_slack

Common Patterns & Recipesโ€‹

Pattern 1 โ€” Self-check loopโ€‹

- id: write_code
agent: claude-code
- id: critique
agent: code-reviewer
on_fail: { goto: write_code, max: 3 }

Pattern 2 โ€” Parallel subagentsโ€‹

- parallel:
- { agent: security-auditor }
- { agent: docs-writer }
- { agent: test-writer }

Pattern 3 โ€” Human-in-the-loopโ€‹

- type: approval
message: "Approve deploy to prod?"
approvers: ["@milind", "@vamsi"]

Pattern 4 โ€” Budget guardrailโ€‹

limits: { max_cost_usd: 2.00 }
on_exceed: pause

Pattern 5 โ€” Observabilityโ€‹

"observability": {
"trace": true,
"metrics_endpoint": "https://otel.corp/v1/traces",
"log_level": "info"
}

Best Practices โœ…โ€‹

  • Decompose big goals into โ‰ค 7 steps.
  • Add a critic to every risky step.
  • Persist memory for multi-session work.
  • Set budgets (tokens, $, time).
  • Human gates before destructive actions.
  • Observe everything (traces, metrics, logs).
  • Idempotent steps โ€” safe to retry.

Anti-Patterns โŒโ€‹

  • One giant prompt that "does everything".
  • No critics โ€” blind trust in LLM output.
  • No budget caps โ€” runaway costs.
  • Skipping human gates on prod actions.
  • Tightly coupled steps โ€” hard to debug.
  • No retries / error handling.

Troubleshootingโ€‹

SymptomCauseFix
Workflow loops foreverNo retry capSet max: on goto
Steps run out of orderMissing depends_onAdd explicit deps
Critic always passesRule too laxTighten rule + test
Costs spikeNo budgetAdd limits block
Hard to debugNo tracingEnable OpenTelemetry
Race conditionsShared mutable memoryUse scoped memory per step

Starter Templateโ€‹

goal: "<one line>"
limits: { max_cost_usd: 2.00, max_runtime_minutes: 15 }
memory: { short_term: in_session }
steps:
- { id: plan, agent: planner }
- { id: act, agent: claude-code, depends_on: [plan] }
- { id: review, agent: code-reviewer, depends_on: [act] }
- { id: gate, type: approval, depends_on: [review] }
- { id: ship, type: merge_pr, depends_on: [gate] }

๐Ÿ’ก Tip: Start with a 3-step linear workflow. Add parallelism only when you measure a bottleneck.


Glossaryโ€‹

  • Agentic workflow โ€” A multi-step process orchestrating agents, tools, and humans.
  • Planner / Executor / Critic โ€” The three core roles.
  • ReAct โ€” Reason + Act loop pattern.
  • Human gate โ€” Manual approval step.
  • Memory โ€” Short-term (session) and long-term (vector store) context.
  • Kill-switch โ€” A flag that halts all running workflows.

Further Readingโ€‹

  • Search: "agentic workflows patterns 2026"
  • Search: "ReAct paper Yao et al."
  • Search: "LLM orchestration LangGraph CrewAI AutoGen"
  • Search: "AI workflow observability OpenTelemetry"