Guides

In-depth practical guides on AI/ML engineering, agentic systems, and production deployments

Series overviews

Each series has a landing page with the full arc and where to start.

GenAI Architectures

There are eight architectures and seven boundaries between them. Every boundary is a yes-or-no question about the task — not a judgment call about the design.

Chat Templates

A chat template is the contract between your messages and the exact token stream the model was trained on. Get it wrong and nothing raises — the model just gets quietly worse.

Agentic AI with LangGraph

An eight-part guide to the part of agent engineering nobody demos: making the thing survive a restart, a concurrent write, a bad tool call, and a Tuesday deploy.

Harness Engineering

AI systems do not fail at the model layer. They fail in the code around it — and that code is a designable layer with its own architecture.

Harness Engineering: The Book

The harness is a control system. Every component in it is a sensor, a comparator, a gate, or a bound — and anything else is application code.

RAG Engineering

Most RAG failures happen upstream of the LLM, accumulate invisibly, and only surface as an incident. This series names each one.

Claude Code Playbook

Claude Code has four layers — context, skills, subagents, hooks — and the variable that decides which one you need is enforceability, not capability.

AI Control Plane

A fleet of agents needs a layer that is not itself an agent — observability, policy, orchestration, versioning, cost, and audit, built as infrastructure.

Agentic AI in the Data Center

In physical infrastructure, an agent’s autonomy is capped by reversibility and jurisdiction — not by how good the model is.

Codebase to Architecture Doc

A three-pass methodology for compressing any codebase into validated diagrams and decisions — and then a LangGraph pipeline that runs it for you.

Federated AI Agents

Every call that crosses from one owner to another is a seam, and a seam has five properties — contract, authority, state, failure, and accountability — that are free inside one deployment and have to be built across it.

Part1
Guide

A2A, MCP, or Subgraph? 'Deployed Separately' Is the Wrong Reason

The usual A2A rule feeds its own output back in as its input. The Federation Test asks who owns the other side first, and a CI check over the compiled graph catches the mistake in both directions.

Part2
Guide

LangGraph interrupt() Re-Sends Your A2A Task on Resume

LangGraph re-runs an interrupted node on resume, and every standard fix assumes the side effect is yours. At an A2A seam the partner's question is the reply to your send, so the fix is a record of the partner's task, and where you keep it decides who can read it.

Part3
Guide

A2A Agent Card Versioning: a Version Bump Is Not a Contract

A version bump tells callers that something changed, and a dated notice tells every caller the same thing. From the caller's side, only dated terms checked against what each caller depends on warn the right caller early.

Part4
Guide

A2A Idempotency: Your Retry Key Lives in Partner Memory

A resend under the same messageId is safe only while the partner reads the key and still remembers it. The duplicate it lets through leaves your own ledger clean, and nothing you read back from the partner except its task list shows it.

Part5
Guide

A2A Saga Compensation: Your Undo Outlives Its Authority

Across an owner line, an undo is a new task the partner may refuse, sent long after the authority that took the step has expired or been revoked. It needs authority of its own, and only the owner that took the step may send it.

Part6
Guide

A2A Contract Testing: Check the Task, Not the Call

On an A2A seam whose send returns at once, the answer is SUBMITTED whatever the task does next. A partner refactor that turns your refusals into its failures passes every check keyed to the call. Key the contract test to the task, and have the partner run it.

Part1
Guide

Harness Engineering Without an Oracle: What Transfers

The famous harness results were scored by tests your agent does not have. The hook transfers once you move it in front of the action. The oracle its check read stays behind.

Part2
Guide

LLM Trust Boundaries: Draw Them by Reach, Not by Author

Your system prompt, your runbook and your own tool results reach the model the same way a customer's ticket does. A rule written there is a measured habit of the model, not a control.

Part3
Guide

LLM Guardrails That Stop Nothing: The Role Test

A guardrail counts only if the action can fail because of it. Classify every component by that power, then make CI fail when a verdict has nothing that can refuse on the other end.

Part4
Guide

LLM Input Validation: Judge the Record, Not the Clean Input

The input failure no detector is built for needs no attacker: your own words come back under a customer's label. Split the entry point into a sensor that records what it changed and a gate that never cleans.

Part5
Guide

LLM Context Window Management: The Policy Nobody Wrote

Every fit-to-window loop runs a policy nobody wrote, and its quietest failure is a constraint summarised into a sentence that constrains nothing. Give the context budget a floor, and refuse below it before the model is called.

Part6
Guide

AI Agent Decision Logs: Catch the Refund No Control Decided

Traces and decision logs record the checks that ran. Neither can show the check that should have run and never did, until the harness declares which decisions each action is owed.

Part7
Guide

LLM Output Repair: A Re-ask That Passes Can Still Be a Guess

Re-asking with the validation error is safe for a broken JSON shape. Send a content correction back and the model learns what passes, so the next pass no longer says the answer is right.

Part8
Guide

LLM Fallback Models Inherit Authority They Never Earned

One gateway can check that the prompt fits the fallback model. None I found checks whether that model may issue the refunds your agent was allowed to make on the primary, or counts the requests it spends while it does.

Part9
Guide

AI Agent Approval Gates: Failed Checks Must Never Widen

Send every failed guardrail check to a human, and in a mode with no reviewer the suspicious refund becomes one somebody may approve while its clean twin is refused.

Part10
Guide

Strict Tool Schemas Aren't Enough: Narrow LLM Tool Calls

A strict schema makes a refund call well-formed. It does not stop the model from choosing the account and the amount, and every check after it is judging those choices.

Part11
Guide

Indirect Prompt Injection: Tool Calls Don't Say Who Asked

Once a tool is narrowed, an injection no longer needs a wrong value. It needs a real one that someone other than the customer chose, and no check that reads only the proposal can tell who chose it.

Part12
Guide

LangGraph Interrupt Resume: Approvals Run on Stale Facts

A human approval is a checkpoint resume. It restores what the agent read before the pause, and the world kept moving while the reviewer was away.

Part13
Guide

AI Agent Spend Limits Pay for the Call That Crosses Them

A budget checked against what the run has already spent fires one unit late. Reserve the declared worst case of the next call, refund or fan-out before it runs, and settle the real cost after.

Part14
Guide

Earned Autonomy for AI Agents: What a Track Record May Widen

A clean month tells you how often the agent is wrong, not what being wrong costs. Let good behaviour widen throughput, and hold the two numbers that consequence sets.

Part15
Guide

Testing AI Agent Guardrails: Green Suites Hide Dead Controls

An adversarial suite proves that something refused each bad output. It does not prove that the control claiming that output works, and two ordinary things hide the difference.

Part16
Guide

AI Agent Failure Attribution: Why the Model Gets the Blame

My book's attribution protocol never clears a layer on a missing record. It convicted the model with four questions unanswered, and its own test suite pins the behaviour.

Part17
Guide

AI Agent Guardrail Monitoring: A Refusal Is Not Proof of Life

My book's readiness check says GO on both of its own incidents: a gate that refused 406 tickets in one night, and a ceiling that a reviewed refactor stopped counting.

Part18
Guide

LangGraph Guardrails: A Node That Skips the Executor

The same refund, on an invoice the customer does not own, is refused by my book's executor and paid by its LangGraph graph, and neither an import test nor a tool-name grep can see why.

Part1
Guide

Context Engineering: The Skill That Separates Production Agents from Demos

Prompt engineering tells the model what to do. Context engineering determines whether it can actually do it.

Part2
Guide

Agent Skills Are Not Prompts. They Are Production Knowledge Infrastructure.

Every team is re-teaching their agent the same workflows on every call. Skills are how you stop paying that tax.

Part3
Guide

Subagents: How to Run Parallelism Inside a Single Agent Session Without Poisoning the Parent

Every subagent burns its own context so the parent doesn't have to. That's the entire architecture.

Part4
Guide

Hooks: The Enforcement Layer That Turns Agent Policy Into Agent Fact

Prompts suggest. Hooks enforce. Until you know the difference, your agent's safety guarantees are probabilistic.

Part5
Guide

Which Claude Code Layer Solves Your Problem? A Diagnostic Guide for AI Engineers

Reaching for a subagent when you needed a skill is the most common mistake teams make. Here is how to stop making it.

Part6
Guide

Four Habits from the Creator of Claude Code That Will Change How You Ship

Boris Cherny runs 10-15 parallel sessions, ships 20-30 PRs a day, and calls his setup 'surprisingly vanilla.' The gap is not configuration. It is operating model.

Part7
Guide

You Can't Debug What You Can't See: Observability for Claude Code Sessions

Most Claude Code failures leave no trace. Here is how to build the audit trail that tells you exactly what happened, why it went wrong, and how to stop it happening again.

Part8
Guide

How to Know Your Claude Code Setup Actually Works: Testing Beyond the Skill Level

Skill evals tell you a skill works in isolation. They do not tell you whether your agent produces consistently good code. That requires a different kind of test.

Part9
Guide

Skills vs Hooks in Claude Code: Enforceability Is the Design Variable

A skill is a suggestion the model may follow. A hook is a gate it cannot see and cannot argue with. Most production agent failures come from confusing the two.

Part10
Guide

Checkpoint Complacency: Claude Code /rewind vs Git Commits

Checkpointing feels like git. It covers a fraction of what git covers - and that gap is exactly where real work gets lost.

Part11
Guide

Headless Claude Code: When the Human Leaves the Loop, Hooks Are All You Have Left

Running Claude Code in CI strips away every safety net that needs a human - approval, rewind, reading the output. What's left is what you enforced in advance.

Part12
Guide

Claude Code Subagent Token Cost: The Preamble Never Stops

I measured 856 Claude Code subagent spawns. The preamble is not a one-time fee. It recurs on every turn, and it comes to about a quarter of the bill at every scale.

Part1
Guide

LangGraph or a While Loop? You Already Have a Runtime

A checkpointer makes the run's past readable and leaves its next-step space exactly as wide as it was. Production agents fail in that gap.

Part2
Guide

LangGraph Reducers Are a Concurrency Policy

Rename a node and the answer changes. The code that decides how concurrent writes merge lives inside a type annotation, appears on no diagram, and the docs decline to guarantee its order.

Part3
Guide

LangGraph create_agent: The Graph Isn't the Runtime

The rendered diagram now lists your tools. It still says nothing about which one may run from which state - the constraints that decide the next step live in middleware nobody draws.

Part4
Guide

LangGraph Checkpoints Restore Your Limits, Not Just Your State

Every bound the runtime gives you is re-derived from checkpointed state on entry. Resume, retry, or just take a second turn, and it arrives at full - by working exactly as designed.

Part5
Guide

LangGraph Compaction Deletes the View, Not the Record

Your summarizer removed the message from state. Seventeen checkpoints on disk still have it, and an ordinary fork puts it back.

Part6
Guide

LangGraph's recursion_limit Bounds Depth, Not Width

A limit of 4 let 1,000 workers run. The bound is real, it is enforced, and it counts the one axis the runtime knows how to count.

Part7
Guide

LangGraph Evals Test the Answer, Not the Thread

One approval decision fired the charge three times. Both output assertions passed, and every checkpoint on the thread recorded nothing about it.

Part8
Guide

LangGraph Names the Guarantee, Not the Unit

Seven parts of measurement found one recurring shape: the bound is real, it is correctly enforced, and it is scoped to something you did not assume.

Part1
Guide

Why Your RAG System Is Using the Wrong Retrieval Strategy

A practitioner's guide to vector-based, vectorless, hybrid, corrective, and agentic retrieval architectures.

Part2
Guide

Why Your RAG Chunks Are Lying to Your Retriever

Chunking strategy is the upstream failure that no retrieval optimization can fix - a practitioner's guide to fixed-size, recursive, semantic, hierarchical, late, and contextual chunking and when each one silently breaks.

Part3
Guide

Why Your Embeddings Are the Wrong Shape for Your Domain

Your embedding model was trained on the internet. Your documents are not the internet. Here is what that mismatch costs in production and how to fix it.

Part4
Guide

Why Your Reranker Is the Last Line You Forgot to Build

Retrieval gets you recall. Reranking gets you precision. Skipping it means your LLM reads the wrong documents with complete confidence - and you will not know until production.

Part5
Guide

Why Your RAG System Cannot Tell When It Is Wrong

Most RAG pipelines measure answer quality and ignore retrieval quality - which means the Retrieval Tax, Chunking Debt, and Precision Gap from Parts 1 through 4 are accumulating invisibly, query by query, until a production incident forces the question.

Part6
Guide

Why Your Agentic RAG System Costs 10x More Than It Should

Wrapping a well-built RAG pipeline in an agent loop multiplies every cost in the stack by the number of retrieval iterations - and most teams have no budget ceiling, no per-session spend tracking, and no circuit breaker.

Part7
Guide

Why Your RAG Knowledge Base Is Lying About What It Knows

The vector index is a snapshot of your documents at ingestion time. Semantic similarity has no relationship to temporal validity. A document from 18 months ago can score 0.94 cosine similarity and still be completely wrong today - and nothing in the standard RAG pipeline raises a flag.

Part8
Guide

Why Your RAG Pipeline Assembles Context Wrong

Retrieval finds the right document. Context assembly decides whether the LLM reads it. Most teams treat this as a pass-through - and pay for it in accuracy, cost, and latency.

Part1
Guide

Agent Fleet Observability: Why Dashboards Miss Running Loops

Every agent-level signal in the OpenTelemetry GenAI spec is recorded when the agent exits. An agent stuck in a loop never exits, so the agent-level dashboard stays green while it burns tokens.

Part2
Guide

Agent Policy Enforcement: Why Copied Guardrails Fail

A guardrail copied into every agent is enforced at the strength of its oldest copy, so revoking a host takes as long as your slowest release train. One policy source on the one path every tool call takes brings it down to the policy polling interval.

Part3
Guide

Multi-Agent Pipeline Orchestration and Failure Propagation: Designing for Blast Radius

Retry logic tells an agent what to do when it fails. A pipeline halt protocol tells the entire fleet what to do. Most production systems only have one of these.

Part4
Guide

Agent Versioning and Deployment Strategies: Shipping Agent Updates Without Breaking Running Pipelines

Deploying a new agent version into a live multi-agent pipeline is not a software deployment. It is a distributed state migration - and most teams treat it like the former.

Part5
Guide

Cost Governance and Budget Allocation Across Agent Types: Token Spend Is Infrastructure Spend

Most teams discover their agent fleet's true cost on the invoice. By then, three budget cycles of misconfigured pipelines have already run.

Part6
Guide

Compliance, Audit Trails, and Regulatory Requirements for Agentic Systems

EU AI Act transparency obligations are in force now. High-risk enforcement lands December 2, 2027. The gap between running agents and running auditable agents is not a documentation problem. It is an architectural one.

Part1
Guide

Harness Engineering: The Missing Layer Between LLMs and Production Systems

Why AI systems don't fail at the model layer - and how designing the right execution harness turns brittle prompts into reliable infrastructure

Part2
Guide

Normalization and Input Defense: Hardening the Entry Point of Your LLM System

Every unreliable LLM system has a porous entry point. Here's how to build the layer that shrinks what the model can see, and why it still can't be your only defense against prompt injection.

Part3
Guide

Context Engineering: What the Model Sees Is What the Model Does

Lost in the Middle and context rot aren't model bugs to wait out. They're context design failures - and fixing them requires treating the context window as managed infrastructure, not a dump bucket.

Part4
Guide

Gated Execution: Why Your Agent Should Never Act Without Permission

Valid output is not safe output. The Gated Execution layer is the firewall between what the model proposes and what the system actually does - default-deny policy, dry runs, and approvals that survive a restart.

Part5
Guide

Validation Layer Design: Building the Reflex That Catches What the Model Gets Wrong

Provider strict mode now fixes the shape of model output. It doesn't fix the meaning. The Validation Layer is what stands between a well-formed wrong answer and your downstream systems.

Part6
Guide

Retry, Fallback, and Circuit Breaking: Building LLM Infrastructure That Survives Outages

Your LLM provider will have an incident. The question is not whether your system fails when that happens - it's whether your retries, breaker and fallback were designed for it, and tested, beforehand.

Part7
Guide

State Management for Agentic Systems: How to Build Agents That Don't Start Over

A long-running agent without state management is a gamble. Checkpoints keep its work, keys written before each side effect keep it from repeating, and something outside the process has to restart it.

Part8
Guide

Deterministic Constraint Systems: Building Tool Registries That Keep Agents in Scope

The model will try to use tools it doesn't have, with parameters that don't exist. A closed, fail-closed registry is how you make every one of those calls fail in code instead of in production.