Kill Switch
Per-agent and tenant-wide emergency stops for incident response. Sets matching sessions to status=killed and broadcasts the kill to live WebSocket subscribers via the AgentSessionDO.
Features
Per-agent
DELETE /api/ai-gateway/agents/:id/sessions terminates every active session for one agent. Returns the count + IDs that were transitioned.
Tenant-wide
POST /api/ai-gateway/agents/sessions/_all/kill kills every session across every agent. Use when the misbehaving agent isn't yet known.
Role-gated
Both endpoints require owner / admin / editor role and are audit-logged with tenantId + actor + count.
Code Examples
SDK
// Kill all active sessions for one agent
const r1 = await agents.killAllSessions(agent.id);
console.log(`Killed ${r1.killed} session(s)`, r1.sessionIds);
// Emergency stop — every session in every agent in this tenant
const r2 = await agents.killAllTenantSessions();
console.log(`Tenant-wide stop: ${r2.killed} session(s)`, r2.sessions);
Dashboard
Operators trigger the same actions from the agent detail page:
/dashboard/ai-agent-gateway
Per-agent "Kill Sessions" button next to Delete, plus a top-right
red "Emergency Stop" button that kills every session in the tenant.
Both gated by window.confirm and report the kill count.