{"slug": "designing-a-kill-switch-for-ai-agents-what-it-should-stop-and-how-to-know-it", "title": "Designing a kill switch for AI agents: what it should stop, and how to know it works", "summary": "Sandscale detailed how organizations should design a kill switch for AI agents, arguing the stop mechanism must be enforced where work is executed rather than by each agent checking a flag, so it doesn't depend on the least careful agent's code. The company said its platform gives every organization a kill switch that halts all agents at once, with on/off changes reserved for a person, recorded in a hash-chained audit log, and surfaced to client code as a non-retryable KillSwitchError in its TypeScript SDK. Sandscale also urged teams to rehearse the switch and write a runbook naming who pulls it and when, before the first incident.", "body_md": "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.\n\nIt 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.\n\nYou will not use a kill switch often, and that is the point. Typical triggers:\n\nIn each case the question \"which agent, exactly?\" takes time to answer. The kill switch buys that time.\n\nA useful kill switch is defined by what is still running after you pull it. Aim for nothing. Concretely, it should:\n\nThe 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.\n\nMake it easy to turn on and harder to turn off.\n\nBoth 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.\n\nYour 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.\n\nRules for client code:\n\nA kill switch you have never pulled is a hypothesis. Rehearse it on a quiet afternoon:\n\nWrite down the results. Repeat after significant changes to your agent setup.\n\nEvery 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.\n\nTurning 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.\n\nOn 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.\n\nThe 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.\n\n*Originally published on the [Sandscale blog](https://sandscale.dev/blog/kill-switch-for-ai-agents).*", "url": "https://wpnews.pro/news/designing-a-kill-switch-for-ai-agents-what-it-should-stop-and-how-to-know-it", "canonical_source": "https://dev.to/sandscale/designing-a-kill-switch-for-ai-agents-what-it-should-stop-and-how-to-know-it-works-7fe", "published_at": "2026-11-23 01:07:19+00:00", "updated_at": "2026-11-23 01:11:38.299392+00:00", "lang": "en", "topics": ["ai-agents", "ai-safety", "ai-infrastructure", "developer-tools"], "entities": ["Sandscale", "KillSwitchError", "TypeScript SDK"], "also_reported_by": [], "takeaway": "Enforce the agent kill switch at the execution layer rather than via a flag each agent checks, make it person-only to toggle with audit logging, and have client code treat the resulting KillSwitchError as non-retryable to avoid a thundering herd on release.", "recommendation": {"advice": "Enforce your agent kill switch where work executes, not in agent code, and make your SDK treat the stop signal as non-retryable so workers don't hammer the switch or stampede when it's released.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/designing-a-kill-switch-for-ai-agents-what-it-should-stop-and-how-to-know-it", "markdown": "https://wpnews.pro/news/designing-a-kill-switch-for-ai-agents-what-it-should-stop-and-how-to-know-it.md", "text": "https://wpnews.pro/news/designing-a-kill-switch-for-ai-agents-what-it-should-stop-and-how-to-know-it.txt", "jsonld": "https://wpnews.pro/news/designing-a-kill-switch-for-ai-agents-what-it-should-stop-and-how-to-know-it.jsonld"}}