Field notes ยท v3

Laws of AI Agents

Lessons from building AI agents that actually work.

These aren't proven theorems. They're field notes from building real agents, and every one points back to a source you can check. Fifty principles that hold no matter which model you use, covering context, reasoning, retrieval, scope, instructions, evaluation, safety, architecture, operations, and the people in the loop. The format is borrowed from Laws of UX.

50 laws ยท 10 categories ยท Inspired by Laws of UX

Free kit ยท No checkout

AI Agent Audit Kit: 50 Laws Edition

I built this from auditing real agents in production. Install the skill, point it at your repo, workflow export, or transcripts, and it checks prompts, tools, retrieval, evals, security, and handoffs against the 50 laws.

Audit your agent

The Expanded Digital Edition

Every law, in full, with a diagram for each.

For each law you get the mechanism underneath it, the warning signs, a worked example, a recipe for applying it, and the sources. All 50, in one place.

Read every law in full
50 laws
Diagram explaining Law of Context Decay
01

Law of Context Decay

Most agent failures start with the wrong context.

Context & Reliability
Diagram explaining Compounding Error Law
02

Compounding Error Law

Reliability multiplies, it doesn't add.

Context & Reliability
Diagram explaining Position Is Power
03

Position Is Power

Models read the edges. The middle gets lost.

Context & Reliability
Diagram explaining The Model Optimizes for Looking Done
04

The Model Optimizes for Looking Done

Agents declare victory early.

Context & Reliability
Diagram explaining Design for the Worst Case
05

Design for the Worst Case

Plan around the ceiling, not the average.

Context & Reliability
Diagram explaining Think Before You Touch
06

Think Before You Touch

Spend reasoning tokens before you spend actions.

Reasoning & Planning
Diagram explaining Don't Bet on One Chain
07

Don't Bet on One Chain

Sample many reasoning paths and let them vote.

Reasoning & Planning
Diagram explaining Branch When the First Step Matters
08

Branch When the First Step Matters

For decisions you can't take back, explore before you commit.

Reasoning & Planning
Diagram explaining Stop Tuning, Start Scaling
09

Stop Tuning, Start Scaling

Build scaffolding you would gladly delete.

Reasoning & Planning
Diagram explaining More Thinking Can Hurt
10

More Thinking Can Hurt

Extra reasoning past the answer is wasted, or a wrong turn.

Reasoning & Planning
Diagram explaining Retrieval Is the Ceiling
11

Retrieval Is the Ceiling

Missing evidence becomes a missing answer.

Retrieval & Memory
Diagram explaining Grounding Is Not a Guarantee
12

Grounding Is Not a Guarantee

Retrieval reduces hallucination. It doesn't eliminate it.

Retrieval & Memory
Diagram explaining Relevant Beats Plenty
13

Relevant Beats Plenty

Near-misses poison context worse than random noise.

Retrieval & Memory
Diagram explaining Keyword Still Carries Weight
14

Keyword Still Carries Weight

Pure semantic search quietly loses to a 40-year-old baseline.

Retrieval & Memory
Diagram explaining Memory Is a System, Not a Window
15

Memory Is a System, Not a Window

Give the agent a hierarchy, not just a bigger prompt.

Retrieval & Memory
Diagram explaining Narrow Beats General
16

Narrow Beats General

Three sharp tools beat thirty dull ones.

Scope & Design
Diagram explaining Determinism at the Edges
17

Determinism at the Edges

Model in the middle, code at the boundaries.

Scope & Design
Diagram explaining Observability Precedes Autonomy
18

Observability Precedes Autonomy

You can't grant autonomy you can't trace.

Scope & Design
Diagram explaining Decompose Before You Scale
19

Decompose Before You Scale

When it's unreliable, split it. Don't supersize it.

Scope & Design
Diagram explaining The Cheapest Fix First
20

The Cheapest Fix First

Reach for the prompt before the platform.

Scope & Design
Diagram explaining The Tool Description Is the Prompt
21

The Tool Description Is the Prompt

An agent is only as capable as its tools are legible.

Instruction & Output
Diagram explaining Show, Don't Tell
22

Show, Don't Tell

When prose fails, stop writing prose.

Instruction & Output
Diagram explaining Confidence Is Not Calibrated
23

Confidence Is Not Calibrated

A model's certainty is not evidence.

Instruction & Output
Diagram explaining Surface Ambiguity, Don't Resolve It
24

Surface Ambiguity, Don't Resolve It

When the data is unclear, don't guess confidently.

Instruction & Output
Diagram explaining Averages Lie
25

Averages Lie

97% overall can hide a 60% segment.

Evaluation & Measurement
Diagram explaining Vibes Don't Scale
26

Vibes Don't Scale

Eyeballing outputs feels like progress until you can't tell if a change helped.

Evaluation & Measurement
Diagram explaining Look at Your Data
27

Look at Your Data

The highest-ROI activity in AI is the one teams skip first.

Evaluation & Measurement
Diagram explaining The Judge Is Biased
28

The Judge Is Biased

An LLM grader reacts to length and position, not just substance.

Evaluation & Measurement
Diagram explaining Goodhart's Trap
29

Goodhart's Trap

When your eval becomes the goal, it stops measuring what you cared about.

Evaluation & Measurement
Diagram explaining Regress or Repeat
30

Regress or Repeat

Every fixed bug is a future regression unless it becomes a test.

Evaluation & Measurement
Diagram explaining The Lethal Trifecta
31

The Lethal Trifecta

Private data, untrusted content, and a way out. Pick at most two.

Safety & Security
Diagram explaining Tokens Don't Wear Badges
32

Tokens Don't Wear Badges

Untrusted text can sound like instructions.

Safety & Security
Diagram explaining The Confused Deputy
33

The Confused Deputy

An agent with your privileges will wield them on an attacker's behalf.

Safety & Security
Diagram explaining Quarantine Untrusted Tokens
34

Quarantine Untrusted Tokens

Let the privileged planner orchestrate, but never let it read the poison.

Safety & Security
Diagram explaining Sandbox the Blast Radius
35

Sandbox the Blast Radius

Assume the agent gets compromised, then contain what it can reach.

Safety & Security
Diagram explaining Don't Build an Agent When a Workflow Will Do
36

Don't Build an Agent When a Workflow Will Do

Agents buy flexibility with latency, cost, and unpredictability.

Architecture & Operations
Diagram explaining Cascade Before You Escalate
37

Cascade Before You Escalate

Try the cheap model first. Only the hard cases deserve the expensive one.

Architecture & Operations
Diagram explaining The Multi-Agent Tax
38

The Multi-Agent Tax

Every extra agent multiplies your token bill, so make sure the task can pay it.

Architecture & Operations
Diagram explaining Your Architecture Mirrors Your Org Chart
39

Your Architecture Mirrors Your Org Chart

You ship a system shaped like your teams, so design the teams first.

Architecture & Operations
Diagram explaining Retries Demand Idempotency
40

Retries Demand Idempotency

If an action can run twice, a retry will eventually run it twice.

Architecture & Operations
Diagram explaining Trip the Breaker
41

Trip the Breaker

Stop calling the thing that's already failing.

Architecture & Operations
Diagram explaining The Ironies of Automation
42

The Ironies of Automation

The more you automate, the harder the leftover human job becomes.

Humans & Autonomy
Diagram explaining Automation Bias
43

Automation Bias

People will trust the machine over their own eyes.

Humans & Autonomy
Diagram explaining Match the Level to the Stakes
44

Match the Level to the Stakes

Full autonomy is a setting, not a default.

Humans & Autonomy
Diagram explaining Mind the Mode
45

Mind the Mode

Most automation surprises start with 'what mode is it in?'

Humans & Autonomy
Diagram explaining The Handoff Is the Hard Part
46

The Handoff Is the Hard Part

In multi-agent systems, failures live in the seams.

Trust & Coordination
Diagram explaining Trust Is Calibrated, Not Granted
47

Trust Is Calibrated, Not Granted

Autonomy is earned in proportion to track record.

Trust & Coordination
Diagram explaining The Escape Hatch Law
48

The Escape Hatch Law

No clean exit means a fabricated one.

Trust & Coordination
Diagram explaining Don't Let the Author Be the Judge
49

Don't Let the Author Be the Judge

The thing that made it shouldn't grade it.

Trust & Coordination
Diagram explaining Preserve Provenance
50

Preserve Provenance

Don't lose where a fact came from.

Trust & Coordination

Further reading

The thinking these laws lean on: foundational essays, papers, and docs worth your time.

  1. 01 Building Effective Agents Anthropic Engineering The foundational map of agent patterns: when a workflow beats an agent, and when to add complexity at all. Underpins Narrow Beats General, Determinism at the Edges, and Don't Build an Agent When a Workflow Will Do.
  2. 02 How We Built Our Multi-Agent Research System Anthropic Engineering Coordinator and sub-agent design, the 15x token tax, and why the hard bugs live in the handoffs. Backs The Handoff Is the Hard Part and The Multi-Agent Tax.
  3. 03 Effective Context Engineering for AI Agents Anthropic Engineering Curating the context window: what to keep, what to drop, and why more context often hurts. Backs Context Decay and Preserve Provenance.
  4. 04 Writing Tools for Agents Anthropic Engineering Why tool descriptions are the real interface the model reasons over. Backs The Tool Description Is the Prompt.
  5. 05 Lost in the Middle: How Language Models Use Long Contexts Liu et al., 2023 The empirical basis for Position Is Power: models reliably use the start and end of long inputs and lose the middle.
  6. 06 The Bitter Lesson Richard Sutton, 2019 Seventy years of AI distilled: general methods plus compute beat hand-crafted cleverness. Backs Stop Tuning, Start Scaling.
  7. 07 Chain-of-Thought & Self-Consistency Wei et al. 2022 / Wang et al. 2022 Reasoning emerges when you ask for it, and sampling many paths to vote beats one greedy chain. Backs Think Before You Touch and Don't Bet on One Chain.
  8. 08 Retrieval-Augmented Generation (RAG) Lewis et al., 2020 The original RAG paper: retrieval supplies the facts the generator reasons over. Backs Retrieval Is the Ceiling.
  9. 09 MemGPT: Towards LLMs as Operating Systems Packer et al., 2023 Treats the context window as RAM and pages memory in and out. Backs Memory Is a System, Not a Window.
  10. 10 Your AI Product Needs Evals Hamel Husain, 2024 The case for evals as the central discipline of building with LLMs. Backs Vibes Don't Scale and Averages Lie.
  11. 11 Judging LLM-as-a-Judge (MT-Bench) Zheng et al., 2023 Position, verbosity, and self-enhancement biases in LLM graders, with mitigations. Backs The Judge Is Biased.
  12. 12 The Lethal Trifecta for AI Agents Simon Willison, 2025 Private data plus untrusted content plus exfiltration equals exploitable. The defining agent-security heuristic. Backs The Lethal Trifecta and Quarantine Untrusted Tokens.
  13. 13 OWASP Top 10 for LLM Applications OWASP Gen AI Security Project, 2025 The industry-standard catalog of LLM application risks and mitigations. Backs Sandbox the Blast Radius and the safety laws.
  14. 14 FrugalGPT: Reducing LLM Cost Chen, Zaharia, Zou, 2023 Model cascades match top-tier quality at a fraction of the cost. Backs Cascade Before You Escalate.
  15. 15 Release It! / CircuitBreaker Nygard 2007 / Fowler 2014 Distributed-systems resilience patterns: circuit breakers, bulkheads, and fail-fast. Backs Trip the Breaker.
  16. 16 Ironies of Automation Lisanne Bainbridge, 1983 The foundational human-factors paper: automating the easy work leaves humans the hardest residual role. Backs The Ironies of Automation.
  17. 17 Trust in Automation: Designing for Appropriate Reliance Lee & See, 2004 The two-sided model of trust: misuse from over-trust, disuse from under-trust. Backs Trust Is Calibrated, Not Granted.
  18. 18 Laws of UX Jon Yablonski The format that inspired this deck: durable principles, one card each, named and memorable.

The story

Why I wrote these

I've built a lot of AI agents. Along the way I read the papers, the engineering write-ups, and watched more YouTube deep-dives than I'd like to admit. But the thing that actually taught me these laws was shipping agents and watching the same failures show up over and over.

Different platform, different model, different harness, same handful of problems. Context going stale. Tools the model couldn't read. Retrieval that missed the one passage that mattered. Evals that didn't exist until something broke in front of a user. Permissions that were far too broad. No clean handoff when the agent got stuck.

My background is software engineering, and that turned out to matter more than I expected. Most of these failures aren't really AI problems. They're reliability, distributed-systems, and interface problems wearing a new coat. The research gave me the why. Years of writing software gave me the instinct for the fix.

So I built this as my own reference: one place that pulls together what the research says and what actually holds up in production, written as 50 laws I can point to whenever I'm designing an agent.

Every law is backed by a real source, whether a paper, an essay, or hard-won engineering experience. And they're deliberately model-agnostic. The models change every few months. These failure modes don't, because they live in the architecture of agent systems, not in any one model. Internalize them and you'll build agents that are more reliable, more secure, and easier to trust, no matter what you build them with.

Sabir Moglad

Principal Software Engineer. I build AI agents and workflow automations, and I wrote Laws of AI Agents.

Connect on LinkedIn