Resources / Architecture

Design a stop control that survives retries and restarts

Stopping a session is not the same as stopping its future work. Design scope, freshness and recovery around the complete workflow.

In short
  • A kill switch is the control that works when every other control has already failed.
  • Three containment scopes — agent, tool and namespace — plus an account-wide flag.
  • A TTL matters as much as the switch: a stop you cannot release becomes an outage.

Why Kill Switches Matter

Autonomous AI agents can go wrong fast. An agent with access to external APIs, databases, or financial systems can cause real damage in the time it takes a human to notice something is off. The feedback loop between “agent misbehaving” and “operator intervenes” is measured in minutes at best. In that window, an agent making one tool call per second can execute dozens of actions that are expensive, irreversible, or both.

A kill switch is the last line of defense. It is the mechanism that halts agent execution when all other controls — policy enforcement, rate limiting, approval workflows — have failed or been bypassed. Every production AI system needs one. The question is not whether to build a kill switch, but how to design one that actually works under pressure.

This post covers the design patterns GovernorAI uses to implement kill switches that are fast enough, granular enough, and reliable enough for production autonomous systems.

Design Requirements

A kill switch that waits for a deploy to take effect is not a kill switch. It is a suggestion. The design requirements for a production-grade kill switch are non-negotiable.

  • Fast propagation — From activation to every gateway rejecting requests, without waiting for a deploy or a policy reload. This is a network engineering problem, not an application logic problem.
  • Multi-scope targeting — Operators need to stop a specific agent, a dangerous tool, an entire namespace, or everything at once. Killing everything when only one agent is misbehaving is collateral damage that erodes trust in the system.
  • API-triggered activation — Kill switches must be activatable via API, not just through a dashboard button. SOC teams, SIEM systems, and automated detection pipelines need programmatic access. A kill switch that requires a human to click a button in a web UI is too slow for automated response.
  • Idempotent and safe — Activating a kill switch that is already active must be a no-op. Deactivating one that is already inactive must also be a no-op. Operators under pressure will double-click. The system must handle that gracefully.

Scope Hierarchy

GovernorAI kill switches contain at three scopes — agent, tool and namespace — and an orthogonal account-wide flag applies a switch across a whole account rather than acting as another scope. A session-scoped switch also exists, but the caller supplies the session id, so it is not containment.

Agent Scope

Denies governed calls that carry a specific agent ID until the kill switch is deactivated. Use this when you suspect the agent’s configuration, model, or permissions are the root cause.

Namespace Scope

Kills all agents within a namespace. A namespace typically maps to a team, an environment, or a deployment. This is the right scope when the problem might affect multiple agents that share the same configuration or access patterns — for example, all agents in a staging namespace that was accidentally pointed at production credentials.

Tool Scope

Kills a specific tool across the agents entitled to call it. Use this when the danger is the capability rather than the caller — a destructive API that should stop being reachable while an incident is understood, even though the agents invoking it are otherwise behaving.

Account-wide

Separately from the scopes, a switch can be marked account-wide. This is the emergency stop: it does not enumerate agents or sessions, it sets a flag every gateway checks before processing any request. It is a property of the switch, not a fifth target.

Propagation Architecture

The kill switch is not stored in a database that gateways poll. Polling introduces latency proportional to the poll interval, and in a kill switch scenario, every millisecond matters.

GovernorAI uses a push-based propagation model. When a kill switch is activated, the control plane publishes the kill switch state to all connected gateways over a persistent connection. Gateways maintain an in-memory cache of active kill switches and check it synchronously on every tool call evaluation. There is no network round-trip at evaluation time.

The propagation flow works as follows: the operator or automated system calls the kill switch API. The control plane validates the request, persists the kill switch record, and publishes the state change to all gateways. Each gateway updates its local cache and begins rejecting matching requests. No step in the sequence from API call to gateway enforcement waits for a deploy.

A customer-managed gateway that takes its kill switches from a signed policy bundle denies every call when that bundle is missing or expired: it cannot confirm which switches are active, so in the absence of information it denies. A gateway that reads kill switches from the database does not depend on a bundle.

SIEM and SOC Integration

Kill switches are most effective when they can be activated by your existing security infrastructure. GovernorAI exposes the kill switch API as a standard REST endpoint that integrates with SIEM platforms, SOAR playbooks, and SOC runbooks.

# Activate a kill switch scoped to a specific agent
curl -X POST https://api.governorai.ai/api/v1/killswitch \
  -H "Authorization: Bearer $GOV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "scope": "agent",
    "target": "agent-4f9a",
    "reason": "Anomalous tool call pattern detected by SIEM",
    "ttl": "1h"
  }'

# Response
# {
#   "kill_id": "ks-7721",
#   "scope": "agent",
#   "target": "agent-4f9a",
#   "status": "active",
#   "propagation_ms": 47,
#   "created_at": "2025-03-10T14:22:08Z",
#   "expires_at": "2025-03-10T15:22:08Z"
# }

Note what the request does not carry: the actor. The server derives it from the authenticated JWT subject and deliberately ignores any client-supplied identity, so a caller cannot attribute its own kill switch to someone else. During post-incident review the recorded actor is the authenticated one, which is the property you want when the question is who triggered the response.

# Check current kill switch status
curl -s https://api.governorai.ai/api/v1/killswitch/status \
  -H "Authorization: Bearer $GOV_API_KEY" | jq '.kill_switches[]'

# Deactivate a kill switch
curl -X DELETE https://api.governorai.ai/api/v1/killswitch/ks-7721 \
  -H "Authorization: Bearer $GOV_API_KEY"

TTL-Based Auto-Recovery

Not every kill switch should stay active forever. GovernorAI supports an optional time-to-live (TTL) on kill switch activations. When the TTL expires, the kill switch is automatically deactivated and the affected agents resume normal operation.

TTL-based recovery is designed for two scenarios. First, precautionary kills: you suspect an issue, kill the agent while you investigate, and set a TTL so it automatically recovers if you get pulled into something else. Second, automated response: your SIEM triggers a kill switch based on a heuristic that has a known false positive rate. The TTL limits the blast radius of false positives without requiring manual intervention to restore service.

When a TTL expires, GovernorAI records the deactivation in the audit log with trigger_source: ttl_expiry. This is distinct from manual deactivation, so you can track how often automated kills resolve themselves versus requiring human follow-up.

If the TTL is omitted, the kill switch remains active indefinitely until explicitly deactivated. For global scope kill switches, GovernorAI requires explicit deactivation by default — there is no auto-recovery for a global kill. This is a safety constraint to prevent a situation where a global emergency resolves itself before the operator has confirmed the root cause.

Testing Kill Switches

A kill switch that has never been tested is not a kill switch. It is a hope. GovernorAI supports dry-run activation that validates the propagation path without actually blocking any tool calls. The dry run reports which gateways received the signal, how long propagation took, and which agents would have been affected.

Run dry-run kill switch tests as part of your regular operational readiness checks. Verify propagation time. Verify scope targeting. Verify that TTL expiry works correctly. The worst time to discover your kill switch does not propagate to a particular gateway is during an actual incident.

Design Principles

The design patterns described here share a common philosophy: the kill switch is infrastructure, not application logic. It sits below the agent framework, below the policy engine, below the approval workflow. It is the layer that everything else depends on. It must be fast, simple, and reliable. It should have fewer moving parts than the systems it protects. And it must work even when those systems are in an unknown or broken state.

If your autonomous AI agents are running in production without a kill switch that meets these requirements, the question is not whether you will need one. It is whether you will have one when you do.

← All resources