← All posts

Guides · Nov 9, 2026

How to stay in control of AI agents

How to set up an AI agent so mistakes stay small and can be undone, the worst steps are blocked, and every run shows how it checked its work.

Built by Simon + Claude

Before the runKeep the reach smallA small folder, a chosen modeDuring the runLock what must never happenA hard stop, and a stop buttonAfter the runCheck what it checkedA check that passes or fails
Control sits in the setup, before, during and after the run.

TL;DR

  • You stay in control through the setup, before the agent starts. Keep the blast radius small, choose how much the agent asks, and block anything that must never happen.
  • An agent that runs on its own needs a clear goal, a turn limit and a check that passes or fails, and a person who approves at the end.
  • Start with one task. Give it a small folder, one rule and a clear goal, and read what it checked before you read its summary.

In What is an AI agent? we described an AI that plans, acts and checks its own work. Once it does more than you can watch, you stay in charge before the run starts. You decide what the agent can reach, what it must ask about, what it can never do and how it shows the work is done.

We use Claude Code for the examples. The same ideas apply to other agentic tools, such as OpenAI's Codex, GitHub Copilot and Google's Gemini CLI, which have their own settings for what the agent may do without asking.

Why approving every step stops working

Once the same approvals keep coming back, it is easy to click yes without reading.

Anthropic's study (Measuring agent autonomy) found that experienced users approve less step by step and step in more often. On complex tasks, Claude stops to ask more than twice as often as people interrupt it.

First roundsApprove each stepYou stand inside the runAfter a whileRead each resultYou check what it hands backLaterSet the goal and the boundariesThen read what it flags
You move from inside the run to the setup.

Give the agent more room one task at a time.

  • Approve each step on a new task to learn what the agent does not know about your work.
  • Move the check from each step to each result, then to a sample.
  • Write every correction into the agent's instruction file, such as CLAUDE.md, so the next run needs less of you.

How much room you give depends on the stakes. The more people rely on the result and the harder it is to undo, the closer you stay.

More rely on itHarder to undoLet it runRead theresultStay close,check twiceA draft inyour folderThe weeklyteam updateRenameevery fileA sharedagent folderA mail toa client
The stakes decide how close you stay.

Keep the blast radius small

Blast radius is how much can go wrong if the agent makes a mistake or is tricked into one. Treat the agent like a new colleague. On day one they get access to what the job needs, not the whole company drive.

  • Work on a copy. Give the agent copies of the files it needs, as in An agent in a folder, and keep the originals out of reach.
  • Give it its own account with only the access the task needs.
  • Turn on the sandbox in Claude Code. The agent's commands can then change files only in the folders you work in, and reach a new website only after it has been approved, by you or, in Auto, by the checking model (sandboxing).
A web page or filewith hidden instructionsAgentIts own folderCan writeShared filesRead onlyOut of reachEmail outPaymentsThe rest of the drivePasswords
The less the agent can reach, the less can go wrong.

A web page or an email can hide text that tries to steer the agent. This is called prompt injection. You cannot always keep an agent away from such content, but you can make the damage smaller. When an agent reads web pages or email, make it ask before it sends or deletes anything (Anthropic Help Center).

In Claude Code the folder you choose is where the agent works, not a wall. It can read files outside it, and asking it not to is no guarantee. Ask what it can reach before the first run.

Ask the agent what it can reach before the first run.

Only a setting turns it into a firm block. In Auto, Claude Code asks the first time it reads outside the folder whether to block it from then on (permissions). Cowork keeps to the folders you connect.

You

Which folders can you read and which can you change? Then set it up so you cannot read or change anything outside this folder, and tell me what you changed.

The lethal trifecta

Simon Willison, a developer who co-created the Django web framework and gave prompt injection its name in 2022, describes the lethal trifecta. An agent becomes dangerous when it has three things at once.

Private dataYour files,email, CRMUntrusted contentWeb pages, emails,shared filesDatacan leakA way to communicate externallyEmail, web requests, posts
The lethal trifecta, after Simon Willison. Never give one agent all three.
  • Access to private data, such as your files, email or CRM.
  • Exposure to content you do not control, such as a web page or an email that can hide instructions.
  • A way to communicate externally, such as email or a web request.

With all three, a hidden instruction can make the agent send your data to someone else. His advice is to never give one agent all three. Check every new agent and every new connector against the list before you switch it on.

Set permissions for each connector

A connector lets the agent read and act in another system, such as email, a CRM or a shared drive. It works with your own access in that system, so it reaches only what your account can reach. A connector that logs in with one shared account reaches whatever that account can see (Anthropic, connectors).

Set each tool on its own. Reading runs freely, sending waits for your yes and deleting is blocked.
  • Set each tool. In the Claude apps, a connector's tools are grouped into read-only tools and tools that write or delete. Each can be set to Always allow, Needs approval or Blocked (Anthropic, connectors). Keep sending on Needs approval, block deleting, and allow a tool always only if you trust it to run unwatched.
  • Check the access. Read what it asks for before you approve, and disconnect what you no longer use.
  • Trust the maker. A connector from an unknown source can hide instructions, and its maker can change how a tool behaves after you add it (Anthropic, custom connectors). The same goes for plugins and skills from others.
  • In Claude Code a connector is called an MCP server, and the same rules can allow, ask about or block a whole server or a single tool (Anthropic, permissions).
  • On Team and Enterprise plans an owner switches each connector on for the company and can limit what it may do, and members cannot override that.

Choose a permission mode

Claude Code offers five permission modes in its mode picker, best read by how often the agent stops to ask you (Anthropic, permission modes).

Stops to ask youManualYou approve every step except readingEdit automaticallyIt edits files on its own and asks youabout the restPlanIt reads and proposes a plan, and youapprove the planAutoStarting modeA separate model checks the riskiersteps instead of youBypass permissionsNothing asks, every step just runs
The modes differ in how often the agent stops to ask you.

In the terminal and in VS Code, it starts in Auto. Reading and editing files in your folder go ahead, and a separate model checks the riskier steps instead of you. Anthropic writes that this does not guarantee safety.

The other tools offer the same range, from asking before every step to approving everything (Codex, Copilot in VS Code, Gemini CLI). Copilot's cloud agent also works on its own branch and waits for a person to merge.

Whatever the tool or mode, sort actions into three groups (Anthropic, Trustworthy agents in practice).

  • Always allow what is easy to undo, such as reading and drafting in the folder.
  • Ask first for anything that leaves under your name, cannot be undone or carries a client's name or number.
  • Never for what must not happen at all, such as deleting the originals.

Hard stops and undo

A line in an instruction file such as CLAUDE.md is guidance, and the agent can miss it on a long task. Claude Code enforces a rule or a hook even when the agent forgets. An instruction is a request, and a lock holds.

RequestAn instructionSend“Ask me before sending anything”Can still go throughThe agent reads it, and can miss itLockA rule or a hookSendStoppedA small automatic check that runsevery time and can stop a step
An instruction is a request. A rule or a hook is a lock.

Anthropic advises a hook, a deny rule or a managed setting for anything that has to happen every time (best practices). A deny rule blocks an action in every mode.

For everything else, make it easy to go back. Press Esc twice to rewind your files and the conversation to an earlier point. It does not undo anything sent or done outside your files, and Anthropic says it does not replace version control (checkpointing).

What a hook is

A hook is a small script that Claude Code runs by itself at a fixed moment in the agent's work, every time, whatever the agent thinks (hooks). Think of it as a smoke alarm. Nobody has to remember to switch it on.

Agent runSend emailBefore a stepStoppedCan stop the step,in every modeUpdate trackerAfter a stepTotals add upRuns a check,cannot undo the stepNeeds youWhen it needs youNotice sentSends you a notice
A hook runs by itself at fixed moments, every time. The one before a step can stop it.

The agent is non-deterministic, so the same instruction can lead to a different step next time. A hook is deterministic. Deterministic and non-deterministic AI explains why that matters.

The agentNon-deterministicSame askRun 1Run 2Run 3A little different each runThe hookDeterministicSend emailSend emailSend emailStoppedThe same answer every time
The agent can take a different path each run. The hook gives the same answer every time.

You do not have to write one yourself. Describe the rule in plain words and Claude Code writes the hook. Codex and Gemini CLI have hooks too.

You

Add a hook that stops any step that sends an email or deletes a file, and tell me what it blocks.

Let it run on its own, safely

Two Claude Code commands keep it working without you. /loop repeats a task at intervals while the session stays open, such as checking a folder for new notes (scheduled tasks). /goal tells Claude what done looks like, and it keeps working turn after turn until it gets there (goal). Codex has a goal command that works the same way (Codex).

After each turn a separate small model checks whether the goal is met. It cannot open files or run anything and judges only what Claude has shown, so ask Claude to show its check.

Each tick is one turnGoalAll figures in the reportmatch the sourceLimitStop after 20 turnsA person approvesCheckerChecked all 14 figures,they match the sourceAfter each turn it sees only whatClaude has shown, never the files
A goal, a limit and a check you can see.

Scheduled tasks can also run in the cloud with your laptop closed (routines).

  • Set a cap in every goal, such as "or stop after 20 turns", since there is no built-in limit.
  • Press Esc to interrupt, and Claude keeps the work done so far. Type /goal clear to end a goal, and ask Claude to cancel a loop.
  • Read the run, then approve. A person sends or publishes the result.

Make it check its own work

When you did not watch the run, the check is how you know the work is right. Three habits make it worth trusting.

  • Define done before the run. Afterwards it is easy to accept whatever came back.
  • Give it a check that passes or fails, something it can run, as Anthropic advises (best practices), such as a script that confirms the totals add up (why scripts help).
  • Let a second agent review in a fresh session, without the first agent's reasoning.
AgentAgent draftsthe reportAgentReviewer agent checksit against your rulesAgentChecker tests everynumber againstthe sourcePersonA personapprovesFix and check again
Agents check agents, and a person holds the last gate.

Take a monthly report. One agent drafts it, a second checks it against your rules, a third tests every number against the source, and nothing goes out until a person approves it.

Three ways to hand work over

Addy Osmani, an engineer at Anthropic who writes widely about working with AI agents, including Anthropic's guide to Opus 5.5, points to a paradox in Critical thinking when agents do the work. The better the agent gets, the fewer obvious errors you see, and the less you check. Over time you go from reading each answer to accepting it.

OffloadingIt does the task.You own the result.DeferralIts answer becomesyour starting point.SurrenderIts answer becomesyours, unchecked.ReadSkimScanAccept
Three ways to hand work over, after Addy Osmani. The drift down happens one small step at a time.

The last step has a name, cognitive surrender, coined by Steven Shaw and Gideon Nave at Wharton (paper). Four questions keep you on the first step before you sign off.

  • What did the check prove?
  • What did it not check?
  • What did it decide for me?
  • Can I explain the result?

You may offload the work and much of the auditing, but not the accountability.

Addy Osmani

Where to start

Pick one task you already give an agent, and set it up this way.

  • One task with a clear result.
  • A small folder with copies of what it needs.
  • A mode that fits how often you want to be asked.
  • One rule that blocks the step that must never happen.
  • A clear goal with a cap, and a check that passes or fails.
Before it starts, ask the agent what it needs, what waits for your yes and when it is done.

For leaders. In Claude Code, IT can set managed settings for the whole company that users cannot change (Anthropic, settings). They can switch off the two modes that ask least and enforce the same rules and hooks for everyone.

When one agent runs safely, How to build a team of AI agents shows how to add more.