Agent Architecture
Intermediate 13 min read Agent Architecture

Orchestration

Who runs next

Orchestration is the runtime that decides which agent runs next, with what context, and when it's done — via fixed graph, router, or adaptive planner. Orchestrators turn patterns into products.

orchestratorroutergraphworkflowdecisioncontrol flow
Before we start

What you will learn

  • Distinguish graph, router, and adaptive control flow
  • Pass context and results between stages
  • Add approval and error nodes to graphs
Introduction

What is this?

Orchestration defines control flow over agents: deterministic graphs (fixed stage order), routers (choose next stage by classify), or adaptive planners (model decides dynamically). Context passes as state between nodes; error handling and approval gates attach to specific edges. Choose determinism proportional to reliability needs.

Motivation

Why do you need it?

  • Control flow is where reliability is engineered — before model layers.
  • Routers formalize 'pick the right specialist' behavior.
  • Graphs give teams reviewable, testable pipelines.
  • Noding errors, retries and approvals at edges = operational reality.
Think about it

Mental model

Imagine

Airport baggage routing

Think of

Orchestration

Baggage (task) goes from ticket (input) along a fixed route with scans (nodes), diverting at marks (router), rerouted on system hiccups (error edges), and finally gated at the gate (approval). Nobody improvises the plane-side; the conveyor is the choreographer.

Mechanics

How it works

  • Define stages (nodes) and state contract between them.
  • Choose edges: fixed, conditional (router), or model-decided.
  • Attach retries, timeouts, approval gates per edge.
  • Emit trace/state for each node.
  • Evaluate end-to-end in evals; tweak edges by failure pattern.

Stages and edges.

In
Classify
Specialist
Verify
Out
Real world

In production

  • Multi-destination support flows route by classification.
  • Data pipelines chain extract→validate→patch→review stages.
  • Deployment agents approve, then execute per-env.
Guidelines

Best practices

  • Make state flow explicit and typed between nodes.
  • Fail edges loudly: retry, degrade, or abort.
  • Put approval nodes exactly where consequences live.
  • Trace node → node for debugging and evals.
Watch out

Common mistakes

  • Implicit state that stages improvise.
  • Router with fuzzy criteria (routes everywhere).
  • No error edges — a node failure strands the task.
Root cause analysis

Common issues

Error
Node inputs stale
Root cause

State contract violated

Fix

Enforce typed state; validate at node boundaries.

Error
Orchestration brittle to change
Root cause

Edges hard-coded everywhere

Fix

Define edges in one config/graph the team reads and evals cover.

When things break

Debugging tips

  • Router misrouting → classify node needs fewer, sharper classes.
  • Stuck stage → missing error edge or timeout.
  • State divergence → version the state schema between nodes.
Interviews

Interview checkpoint

Practice

Hands-on lab

Orchestrator With Fallback Workers
25 min · intermediate
In progress
Objectives
  • Register workers as callable functions
  • Dispatch a task to the right worker
  • Fail over to a backup worker on error

Orchestrator With Fallback Workers

25 min · intermediate

0/3 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/2
1

A router node's job is to…

2

Approval gates belong exactly where consequences live.

Go deeper

Official documentation