Skip to content

AI agents & tool use

What an agent actually is once you strip the marketing off it: a loop, a set of tools, and a budget — plus everything that goes wrong when you run one against production.

An agent is a while-loop around a model that can call functions. That is not a deflation, it is the useful description: everything that makes agents hard follows from the loop, not from the model. A loop can fail to terminate. A loop re-sends its entire history every iteration, so cost grows faster than step count. A loop that touches the outside world can do something it cannot undo, twice.

These pages start from the loop and work outward — tool schemas, memory, topologies, stopping conditions, budgets, sandboxes, tracing and MCP. Where a page can show working code instead of an architecture diagram, it does. Where the honest answer is that you probably do not need the thing the page is about, it says that too.

What Is an AI Agent? A Definition That Excludes Things

A three-part test for whether a system is an agent, applied to six real systems — including the ones that fail it.

5 min read

The Agent Loop: Plan, Act, Observe, Repeat

The whole loop in about eighty lines of Python with no framework, and the four bugs that show up when you write it yourself.

5 min read

Tool Calling: How the Model Picks a Function

One tool call followed from the schema you send to the JSON you get back, with a clear line drawn between what the model does and what the SDK does.

5 min read

Writing Tool Descriptions the Model Actually Understands

Three before/after rewrites of real tool descriptions, plus the evaluation harness that tells you whether your own rewrite helped.

6 min read

How Many Tools Is Too Many?

The token arithmetic of a large tool catalogue, why it bites hardest in a loop, and the four architectures that fix it.

5 min read

Parallel Tool Calls and When They Break Things

What the API actually gives you when a model requests several tools at once, and the ordering and idempotency conditions that decide whether you may run them concurrently.

5 min read

Agent Memory: Short-Term, Long-Term and What's Just a Database

Three concrete memory patterns with a schema for each, and the reason the third one — plain files — outperforms the vector store most of the time.

5 min read

Multi-Agent Systems: When Two Agents Beat One

A token-accounting model for splitting a task across agents, showing exactly which assumption decides whether it saves money or triples it.

5 min read

Orchestrator-Worker vs Peer Agents

Four ways to wire multiple agents together, compared on where state lives, who owns the budget, and the specific way each one fails.

4 min read

Error Recovery: What an Agent Should Do When a Tool Fails

A decision procedure that maps each error class to one of retry, repair, replan, escalate or halt — with the classifier as code.

6 min read

Stopping Conditions: Preventing Infinite Agent Loops

Six independent halt conditions, implemented as one class you can drop into a loop, plus the termination handshake that stops silent give-ups reading as success.

5 min read

Agent Cost Control: Capping Spend Per Task

Why an agent's cost grows faster than its step count, how to check the budget before the call rather than after, and how to abort without leaving half-finished work.

5 min read

Human-in-the-Loop: Where to Put the Approval Gate

Placing approval gates by blast radius rather than by nervousness, and designing them so the approver is actually looking at something.

5 min read

Sandboxing an Agent That Executes Code

A concrete container configuration, what it does and does not stop, and the six escapes that get forgotten because they are not kernel bugs.

5 min read

MCP: The Model Context Protocol, Explained

What MCP specifies, the three primitives and who controls each, and an honest account of when a plain function in your own process is the better answer.

6 min read

Building an MCP Server: A Complete Walkthrough

A complete stdio server in one file, shown alongside the raw JSON-RPC frames it exchanges, plus the stdout mistake that breaks half of all first attempts.

6 min read

Computer-Use Agents: The State of Clicking Things

How a screenshot-and-click agent actually works, the token arithmetic that makes long runs expensive, and why per-step accuracy compounds into the success rates you read about.

6 min read

Evaluating an Agent: Trajectory vs Outcome

What end-state grading cannot see, the trajectory metrics that see it, and a test-case format that asserts on both.

5 min read

Observability for Agents: Tracing a 40-Step Run

A span layout for agent runs using the OpenTelemetry GenAI conventions, and the specific attributes that make a failed forty-step run debuggable instead of merely visible.

5 min read

Agent Frameworks vs Writing the Loop Yourself

The five things a framework genuinely does that are hard to write, the four places the abstraction costs more than it saves, and one test that decides it.

4 min read

AI agents & tool use · Multigrid