Chapter 14: Agent Frameworks & Orchestration
The 2026 Framework Landscape
The early generation of autonomous-agent demos has given way to production-grade orchestration frameworks. The ones that matter:
* LangGraph - stateful, graph-based workflows with durable execution and human-in-the-loop checkpoints
* CrewAI - role-based multi-agent collaboration
* OpenAI Agents SDK - lightweight agents, handoffs, guardrails, and tracing
* Claude Agent SDK - build custom agents on the same harness that powers Claude Code
* Google Agent Development Kit (ADK) and Microsoft Agent Framework - vendor-aligned orchestration with enterprise integration
Choose frameworks based on what delivers production reliability, not what is trending. The connective tissue is the same regardless: MCP for governed tool access, A2A for agent-to-agent handoffs, and evals to gate the whole thing.
Not Every Agent Needs an LLM
A trap worth naming early: "agentic" does not mean "LLM." Agentic software is software that autonomously takes actions to achieve a goal without step-by-step human instruction - and that predates LLMs by decades. A Roomba, a trading bot, a CI/CD pipeline, and a spam filter are all agentic, and none use a language model. Three technologies can drive an agent, and the best systems mix them:
* Rules engines - precise, auditable, fast. Best for financial calculations and compliance checks ("if price variance exceeds 10%, escalate").
* ML models - learn patterns from data. Best for anomaly detection, prediction, and risk scoring.
* LLMs - interpret natural language and reason through ambiguity. Best for unstructured text and documents.
Reaching for an LLM when a rules engine would be precise and auditable is a common and expensive mistake - you trade determinism and a clean audit trail for flexibility you did not need. Watchdog (Chapter 25) is a concrete example of the hybrid done right: rules for compliance scoring, ML for anomaly detection, and an LLM only where it earned its place - extracting terms from contract PDFs. Each component is agentic; the LLM is one ingredient, not the whole dish.
A Stateful Workflow with LangGraph
import { StateGraph, START, END } from "@langchain/langgraph";
import { ChatAnthropic } from "@langchain/anthropic";
const model = new ChatAnthropic({ model: "claude-sonnet-5-5" });
const graph = new StateGraph(State)
.addNode("analyze", analyzeCode)
.addNode("plan", createPlan)
.addNode("implement", implementChanges)
.addNode("verify", runTestsAndEvals)
.addEdge(START, "analyze")
.addEdge("analyze", "plan")
.addEdge("plan", "implement")
.addEdge("implement", "verify")
// Loop back if verification fails; otherwise finish
.addConditionalEdges("verify", (s) => s.passed ? END : "plan")
.compile();
const result = await graph.invoke({
task: "Refactor the authentication module to use OAuth2"
});
The Plan-Act-Verify Loop
Effective agent architectures share a shape: analyze the current state, generate a plan, execute each step, and verify - then self-correct on failure. The critical addition in 2026 is that verification is not the agent's self-report. It is an independent check: tests, evals, and constraint enforcement defined by the intent spec.
// Conceptual agent loop with intent and verification
async function runAgent(task, intentSpec) {
const plan = await planFrom(task, intentSpec);
for (const step of plan.steps) {
if (intentSpec.requiresApproval(step)) await escalate(step);
const result = await execute(step);
if (overBudget(intentSpec) || tooManyRetries(step)) return abort();
if (!result.ok) await correctAndRetry(step, result.error);
}
// Independent verification - not the agent's own claim
const evals = await runEvals(task, intentSpec.successCriteria);
return evals.passed ? finish() : escalate("eval failure");
}
Custom Agent Configuration
export const agentConfig = {
role: "Senior Full-Stack Developer",
model: "claude-opus-5-5",
capabilities: ["code_generation", "refactoring", "test_creation", "docs"],
tools: [
{ name: "filesystem", mcp: "filesystem", scope: "/src" },
{ name: "git", mcp: "git", permissions: ["commit"] },
{ name: "tests", command: "npm test" }
],
constraints: {
max_iterations: 10,
cost_ceiling_usd: 5.0,
require_human_approval: ["delete_files", "git_push", "deploy"]
}
};
Notice that the constraints block is an intent spec in miniature. Orchestration without intent is how a multi-agent system turns a small task into a large incident.