# Designing a kill switch for AI agents: what it should stop, and how to know it works

> Every team running agents needs a way to stop all of them at once. What an organization-wide kill switch should halt, who should be able to pull it, how clients should react, and how to rehearse it.

Every team running agents needs a way to stop all of them at once. What an organization-wide kill switch should halt, who should be able to pull it, how clients should react, and how to rehearse it.

November 23, 2026 · 4 min read · The Sandscale team

Most incident runbooks for software have a step that says “roll back” or “turn off the feature flag”. Agent systems need an equivalent that is faster and blunter: stop every agent in the organization, now, and keep them stopped until a person decides otherwise.

It sounds simple. In practice teams discover during their first real incident that “stop the agents” means a dozen different processes in a dozen places, some of which retry happily when told to stop. This post covers what a kill switch should do, who should hold it, how client code should behave when it is on, and how to test that it works before you need it.

## When you would pull it

You will not use a kill switch often, and that is the point. Typical triggers:

- An agent is doing something harmful at volume: deleting, posting, spending, and you do not yet know why.
- A credential the agents use has leaked, and you need everything that might use it to stop while you rotate it.
- A prompt-injection campaign is hitting a source your agents read, such as a public issue tracker.
- A model or tool update changed behavior in a way you do not understand.

In each case the question “which agent, exactly?” takes time to answer. The kill switch buys that time.

## What it should stop

A useful kill switch is defined by what is still running after you pull it. Aim for nothing. Concretely, it should:

1. **Refuse new work.** New sandboxes, new runs, new tool calls are refused at the platform, not by asking each agent nicely.
2. **Stop work in progress.** Running commands and sessions end, rather than finishing the current step.
3. **Apply everywhere at once.** Every agent, every project, every region the organization uses. A per-project switch is useful too, but the organization-wide one is the one you reach for in an incident.
4. **Stay on.** It does not reset on a deploy, a restart or a timer. Only a person turns it off.

The first point is the important design choice. A switch that relies on each agent checking a flag is only as good as the least careful agent. A switch enforced where the work is executed does not depend on agent code at all.

## Who can pull it, and who can release it

Make it easy to turn on and harder to turn off.

- **Turning it on** should be available to more people than you might expect: on-call engineers, security, team leads. In an incident, the cost of a false alarm is minutes of stopped agents. The cost of waiting for the one person with permission is much higher.
- **Turning it off** deserves more care: a named person, a confirmation step, and a reason recorded with the change.

Both actions should be performed by a person, not an API key in a script, and both should land in an audit log with who did it and when. After the incident, the log of when it went on and off is part of your timeline.

## How clients should react

Your own code that drives agents has to cooperate, or it will fight the switch. The common failure is a worker that sees an error, waits five seconds and retries, forever. Against a kill switch, that worker generates noise and, when the switch is released, a thundering herd of retries.

Rules for client code:

- **Recognize the refusal.** Treat kill switch errors as their own category, distinct from rate limits or outages.
- **Do not retry.** Stop the task, record that it was stopped by the kill switch, and surface it to a person.
- **Do not fail over.** Never respond to a refusal by running the agent’s code somewhere else. The refusal is the control working.
- **Resume deliberately.** After release, restart tasks from a queue at a controlled rate, not all at once.

## Rehearse it

A kill switch you have never pulled is a hypothesis. Rehearse it on a quiet afternoon:

1. Start a few representative agent tasks, including a long-running one.
2. Pull the switch. Note the time.
3. Check that new work is refused, that running work stopped, and how long both took.
4. Check what your workers did. Did they stop, or did they retry in a loop?
5. Check the audit log for the on and off events and the refused actions.
6. Release it, and watch tasks resume at the rate you intended.

Write down the results. Repeat after significant changes to your agent setup.

## How it works on Sandscale

Every Sandscale organization has a kill switch that stops its agents at once, on every plan; the [approvals and policies docs](https://sandscale.dev/docs/concepts/approvals) describe it. Its use is recorded in the hash-chained [audit log](https://sandscale.dev/docs/concepts/audit) along with who did it, when and where.

Turning the organization switch on or off through the API is reserved for a person: the [API reference](https://sandscale.dev/docs/reference/api/approvals-policies) lists `person_required` and step-up confirmation among the answers for that call, and says the change and its audit entry commit together. Code can check the state with `GET /api/v1/sandbox/kill-switch`, which needs the `sandboxes:read` permission and reports whether the switch is engaged and since when.

On the client side, the TypeScript SDK raises a `KillSwitchError` when the switch stops a call, and it never retries that error itself. Our post on [handling sandbox API errors](https://sandscale.dev/blog/handling-sandscale-api-errors-typescript) shows a wrapper that treats it as stop-everything.

The switch is only half the story. The other half is a runbook that says who pulls it, when, and what happens next. Write that before your first incident, not during it.

**On this page**

1. When you would pull it
2. What it should stop
3. Who can pull it, and who can release it
4. How clients should react
5. Rehearse it
6. How it works on Sandscale

**Run your agents in a box of their own**

Each sandbox is a Firecracker microVM. Free includes 100 awake vCPU-hours a month.

[Start free](https://cloud.sandscale.dev/auth/signup)

## Keep reading

- [November 23, 2026 · **A checklist for reviewing a pull request an AI agent wrote** · Agent-written PRs fail in different places than human ones. A practical review checklist: what to read first, the lines that deserve the most suspicion, and what to run before you approve.](https://sandscale.dev/blog/reviewing-an-agent-diff-checklist)
- [November 23, 2026 · **A threat model for AI coding agents: what can go wrong, and where to put the controls** · A practical threat model for coding agents: the assets at risk, the ways untrusted text gets in, the attacker goals, and which control belongs at which layer.](https://sandscale.dev/blog/threat-model-for-ai-coding-agents)

---
Source: https://sandscale.dev/blog/kill-switch-for-ai-agents
