AI Agentic Handbook
Volume III

Agents

Models that take actions: tools, loops, memory, multi-agent systems and keeping them safe.

Sections

Interview questions answered at staff level

01

Agent fundamentals

What makes something an agent, tool use, the agent loop, and when a workflow is better.

10 questions
02

Agents in production

Reliability, cost, evaluation, security and human oversight for agents that run for real.

10 questions

Read first

Blog posts for this volume, easiest first

What is an AI agent, really?

A chatbot tells you how; an AI agent goes and does it, deciding each next step from what it just found. A plain-English tour of the loop, the tools, and why limits are part of the design.

Build your first tool-using agent (offline, in pure Python)

A minimal agent loop that speaks the real Messages API shape: tool calls linked to results by id, several calls per turn, argument validation that does not swallow your bugs, a step budget, pytest, and the same loop against Claude.

Workflows before agents: pick the simplest pattern that works

Seven patterns from Anthropic’s taxonomy, from one call to a fully autonomous AI agent, with the cost and latency spread of each and the failure that justifies climbing to the next.

Securing agents: assume the model will be fooled

Prompt injection has no reliable filter, so agent security is architecture: break the lethal trifecta, constrain what a fooled model can do, and test it like any other regression.

Build your first MCP server

What the Model Context Protocol actually standardises, a 30-line Python server with one tool and one resource, how to plug it into a client, and the security rules that matter before anyone else installs it.

Tool design for agents: the interface is the product

Names, schemas, error messages the model can act on, pagination, idempotency keys and confirmation for side effects, with runnable examples of a bad tool, a good one and an idempotent write.

Durable agents: checkpoints, idempotent tools and approvals that wait for days

An agent run is a long-lived workflow that will be interrupted. How to checkpoint each step, make every side effect safe to replay, resume at step 7 after a crash, and park a run for a human without holding a worker, with a runnable stdlib example.

Key terms

31 pages with diagrams and quizzes

AI agentBudding

An AI that is allowed to act, not just write: it picks a tool, reads the result, picks again — until the goal is met or a limit stops it.

Workflow vs agentMid

In a workflow, you write the steps and the model fills them in. In an agent, the model picks the steps. Predictability versus flexibility.

Tool use & function callingBudding

The model asks for something it can't do alone — 'call get_order_status with order 48213' — and your code decides whether to actually do it.

The agent loop (ReAct)Budding

The cycle at the heart of every agent: the model decides, your code runs a tool, the result goes back in, repeat — until done or stopped.

PlanningMid

Having the agent write out its steps before acting — and rewrite them when a result contradicts the plan.

Reflection & self-critiqueMid

The model reviews its own work and tries again. Works well when the review has something real to check against — tests, a validator — and much less without.

Prompt chainingBudding

A fixed sequence of model calls, each feeding the next, with your own checks between the steps.

Multi-agent systemsSenior

Several agents with their own contexts, instructions and tools working one task. Strong for parallel breadth, and roughly 15× the tokens of a chat.

Orchestrator–worker patternSenior

One model looks at the task, decides what pieces are needed, farms them out to workers, and merges what comes back.

Handoffs between agentsMid

One agent passes a task to another — or to a person — with a structured briefing, and the tools and permissions change with it.

MCP (Model Context Protocol)Mid

Model Context Protocol: an open standard for plugging tools and data into AI apps. Rather like USB, but for AI.

Agent memoryMid

How an agent keeps anything beyond one request: working memory in the context, plus a long-term store it writes to and searches later.

Context engineeringSenior

Deciding exactly what goes into the model's context at each step — and what stays out — to get the most signal per token.

Computer use & browser agentsMid

An agent working a screen the way a person does — look at a screenshot, click, type, repeat. The fallback when there is no API.

Code execution sandboxMid

A walled-off space where an agent's code and actions run, with only the files, network and credentials it genuinely needs.

GuardrailsMid

Checks around a model or agent that block, fix or escalate unsafe inputs, outputs and actions — layered, with the important ones in code.

Human in the loopBudding

A person reviews, approves or corrects the AI's work at chosen moments — usually just before anything irreversible.

Stop conditions & step budgetsMid

The rules that end an agent's run: task done, or a cap on turns, tokens, time, spend, repeats or errors — each logged with a reason.

Durable execution & checkpointingSenior

Running agent workflows so progress is saved step by step, and a crash, a deploy or a two-day wait doesn't redo what already happened.

Trajectory evaluationSenior

Judging an agent's whole path — which tools, in what order, how safely, how cheaply — and not just whether the final answer was right.

Tool design (agent–computer interface)Mid

Designing an agent's tools — names, descriptions, inputs, outputs, errors — so the model picks the right one and uses it well.

Agent cost & token budgetsSenior

What a run costs in tokens, money and time. Because the whole history is re-sent each turn, it grows faster than you'd guess.

Multi-tenancySenior

Serving many customers from shared infrastructure while keeping their data, quotas and performance apart. How far you isolate is a cost-versus-risk call.

Noisy neighbourSenior

One customer's heavy load — a bulk import, a runaway agent — making everyone else on the same infrastructure slow.

ACL (access control list)Mid

Who is allowed to see a document. In RAG this has to be checked while searching, or the model will quote files the user cannot open.

Fail closedSenior

If you cannot confirm something is allowed, treat it as not allowed. Fail-open is the opposite: keep serving and skip the check.

Prompt injection (indirect)Senior

Text the model reads as instructions — typed by a user, or hidden in a page, email or document an agent fetches. No filter fully fixes it.

Data exfiltrationSenior

Getting data out of a system without permission. For agents: a tool call, a fetched URL, or a rendered image whose address carries the data.

Least privilegeMid

Give every user, service and agent only the permissions this task needs, only for as long as it needs them.

Blast radiusSenior

How much breaks when one thing fails: how many users, customers, records or actions. Keep it small and known.

Defence in depthSenior

Stacking independent safeguards so that one failing — and each will, sometimes — is not the whole story.