How do you stop a runaway AI agent? Why kill -9 isn't enough, measured
CrowdStrike shipped an AI agent kill switch and OpenAI reportedly can stop research model output within 35 seconds. I measured why: a tiny agent loop makes 204,311 tool calls in 35 seconds, kill -9 left its child running, a supervisor brought it back in 0.55 s, and a revoked self-contained token kept working until it expired. Here's what actually stops an agent.
On this page
- What an agent is, from the operating system’s point of view
- The lab
- How many tool calls fit in 35 seconds?
- Try 1: kill -9 the agent
- Try 2: it runs under a supervisor
- Try 3: kill the whole process group
- Try 4: kill the control group
- Revoke the credential instead
- The token that couldn’t be revoked
- Calls already in flight
- A layered off switch
- Try it yourself
Two “off switches” for AI agents made news this month.
On November 3, CrowdStrike announced an AI Kill Switch in its Falcon Guardian product. In CrowdStrike’s words, a defender can “terminate it where it runs, block it from launching again, and cut off its enterprise network access”. The detail worth reading twice: “The Falcon sensor stops the agent from executing, first at the Gateway, and soon on the endpoint.” The launch blog says the switch “directs connected AI gateways to block access to the AI models that power agents’ decisions and actions”.
This week, OpenAI described Control Room, a system its research inference workloads check in with. As reported by ai-tldr.dev, CryptoBriefing and others (OpenAI’s own page refused my fetcher, so I’m relying on coverage here): the inference engine checks with Control Room before serving each request, a job marked as stopped gets no more model output, it can halt output within 35 seconds of a decision to stop, and it fails closed: if Control Room is down, requests are denied.
Notice where both switches sit: in front of the model, at a gateway or in the inference engine, not only on the process. I built a small lab to see why that matters.
What an agent is, from the operating system’s point of view
An agent is a loop: the model picks a tool, the tool runs, the result goes back to the model, repeat. Around that loop there’s more than one process:
- child processes that run the tools (a shell command, a browser, a script);
- something that restarts it: a service manager set to restart, a cron job, a queue that retries failed jobs;
- credentials: API keys and tokens, which work from any process that holds them;
- calls already in flight, which the server is busy executing.
“Stop the agent” has to deal with all four.
The lab
Everything ran on one generic Linux machine, on 8 CPUs at low priority, and nothing left 127.0.0.1:
- a tiny tool server that checks a bearer token on every call and writes every call to an audit log;
- a scripted agent: a loop of tool calls as fast as it can go, with no model in it. Real agents wait for the model between steps, so treat this as the upper bound for one worker, the speed of a loop of tool calls that no longer needs to think (a retry storm, a script the agent wrote, a fan-out);
- a supervisor that restarts the agent 0.5 s after it dies, the way
Restart=always, cron or a job queue would.
The scripts are short Python; there’s a sketch of the key part at the end.
How many tool calls fit in 35 seconds?
| Setup | Successful tool calls in 35 s |
|---|---|
| 1 loop | 204,311 (≈ 5,831 per second) |
| 8 loops in parallel | 346,464 |
| 1 loop, server rate limit of 10 calls/s | 358 (and 174 rejected with 429) |
A confession: my first run said 848. My tiny server was waiting about 40 ms before every reply: Python’s HTTP server wrote the headers and the body separately, Nagle’s algorithm held the second write back until the first was acknowledged, and the client was delaying its acknowledgement. 100 calls took 4.07 s; with disable_nagle_algorithm = True on the handler they took 0.017 s. The table above is the fixed run.
So “35 seconds” is fast for a human process and slow for a machine one. A stop that takes 35 seconds is only safe if the thing being stopped can’t do much damage per call, which is the job of rate limits and narrow permissions.
Try 1: kill -9 the agent
My agent started a background worker as a child process, the way agents commonly run tools. I sent SIGKILL to the parent.
The parent died at once. The child didn’t notice: 28,022 more tool calls in the next five seconds. Killing a parent doesn’t kill its children on Linux; they’re re-parented and keep running.
Try 2: it runs under a supervisor
With the supervisor, I killed the agent again. It was back 0.55 s later, with a new process ID, the same token and the same job, and made 25,835 calls in the five seconds after the kill. That restart is exactly what you want from a normal service. For a runaway agent it means the kill switch must stop the relauncher first.
Try 3: kill the whole process group
kill(2) with a negative PID signals a whole process group: “If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.” That took out the parent and its child together: zero calls afterwards.
Then the twist. A child can leave its parent’s process group with a single setsid() call, which daemons do routinely. I made the child do that. The group kill missed it entirely: 28,143 calls in the five seconds after.
Try 4: kill the control group
What does catch everything is the cgroup. The kernel puts every process a service starts into the service’s control group, and setsid() doesn’t change that. I ran the agent in a systemd scope and killed the scope: the parent and the escaped child both stopped, zero calls. That’s what systemd does by default when it stops a unit, and its documentation describes the alternative, KillMode=process, as “only the main process itself is killed (not recommended!)”.
So process-wise, the right tool is a cgroup, a container or a sandbox, not a PID. But processes are only half of an agent.
Revoke the credential instead
I left the escaped setsid() child running and didn’t touch the process at all. I revoked its token on the server, which looks the token up on every call.
The last successful call landed 0.7 ms after the revoke; after that every call got 401. The process kept running and retrying (25 rejected calls in five seconds with a 0.2 s back-off) but it couldn’t do anything. It doesn’t matter how many copies exist, where they run or what restarts them: a credential the server checks on every call stops all of them at once.
This is the shape of Control Room: the serving side checks “is this job still allowed?” on every request, and fails closed.
The token that couldn’t be revoked
Not every token works like that. A self-contained token, like a JWT, carries its own expiry and signature, and the server can validate it without asking anyone. I issued one that expired in 15 seconds and revoked it after 3 s. Because my server only checked the signature and the expiry, it kept working for 12 s more: 61,062 successful calls after the revocation, until it expired on its own.
RFC 7009, the OAuth token revocation standard, says exactly this: with self-contained access tokens, immediate revocation needs “some (currently non-standardized) backend interaction between the authorization server and the resource server”. If agents get long-lived self-contained tokens, your kill switch is the expiry time.
Calls already in flight
Two last traps, both measured:
- I started a slow tool call (the server works for 3 s, then records a side effect) and killed the client 0.5 s in. The server finished anyway: the side effect was recorded 3.0 s after the start. Killing the agent doesn’t cancel what the tools are already doing.
- I revoked the token 0.5 s into a slow call. The token had been checked when the call began, so it still came back
200 OKafter 3.0 s.
| What I did | Tool calls that still succeeded |
|---|---|
kill -9 the agent (child worker) |
28,022 in 5 s |
kill -9 under a supervisor |
25,835 in 5 s (back after 0.55 s) |
kill the process group (child had called setsid) |
28,143 in 5 s |
| kill the cgroup | 0 |
| revoke a token the server checks every call | 0 after 0.7 ms |
| revoke a self-contained token (15 s expiry) | 61,062, until it expired |
A layered off switch
There isn’t one button. There’s an order of operations, and each layer covers a hole in the one before:
- Credentials the server checks on every call, short-lived, scoped to the job. Revoking them is the switch that works no matter where the agent runs. If you must use self-contained tokens, keep their lifetime short.
- Cut network egress. Agents should reach the world through an allow-listed proxy or gateway you control. Blocking the gateway is how CrowdStrike’s switch starts, and it also cuts the agent off from its model.
- Stop the relaunch before killing anything: the service, the cron entry, the queue consumer, the retry policy.
- Kill the whole cgroup, container or sandbox, not a PID. Run each agent in its own sandbox so that is possible.
- Rate limits per credential, so the time it takes to stop costs hundreds of calls, not tens of thousands.
- An audit log of every call, so you know what it did before you stopped it, and make side-effecting tools cancellable or idempotent so in-flight work can be undone or safely retried.
Try it yourself
The heart of the lab is a few lines: a server that checks the token on every request, and a revoke that flips it.
REVOKED = set()
def check(token): # called before serving every tool call
return token in ISSUED and token not in REVOKED
def revoke(token): # the kill switch: every copy of the agent stops at its next call
REVOKED.add(token)
How would you stop your agent right now, and how long would it take? Tell me; I’m curious which layer most setups are missing.