CodePanel

A kill switch for coding agents needs four gates, not one flag

Why pausing unattended coding agents at only task-claim breaks resume, and how CodePanel coordinates queue, claim, model proxy, and live-run stops.

The CodePanel teamcoding-agentsautopilotsafety

When you run coding agents on autopilot triggers, you need an emergency stop that halts every active and queued workflow in seconds without corrupting queued work. While building Stop everything for CodePanel's Autopilot, we found that checking a single paused flag at task-claim time is broken: a local runner that gets a refusal when claiming a queued task marks that task as permanently refused, so clicking Resume agents later would leave every queued task stranded.

The four places work moves

An unattended coding run crosses four boundaries:

  1. Task intake (POST /api/v1/tasks, start_task, autopilot rules): Creates and queues new tasks.
  2. Runner poll (GET /api/v1/runner/queue): Hands queued tasks to online local runners.
  3. Live runs: Agents currently executing tools or waiting on interrupts in local worktrees.
  4. Model proxy: Dispatches every LLM call for both CodePanel's loop and external CLIs (Claude Code, Codex, Gemini CLI, OpenCode).

Stopping only one boundary leaves the others leaking spend or breaking recovery.

How the four gates work together

Pressing Stop everything twice in the desktop app (or ⌘⇧. twice within four seconds, or calling pause_agents / codepanel autopilot pause) activates all four gates in one transaction:

Gate Behaviour while paused Why it matters
Task creation & rules Refuses new tasks with machine-readable agents_paused and a nextAction; autopilot rules skip incoming events. Calling agents and webhooks get an explicit status instead of piling up work.
Runner poll Answers queued: [] instead of refusing claims. Queued tasks stay untouched in the database and start immediately when you resume.
Live runs Sweeps active runs through the same stop_run core (bounded per sweep) while keeping their tasks retryable. Running worktrees stop cleanly without losing the task record.
Model proxy Rejects calls before rate limiting or provider dispatch. Even an in-flight subagent or external CLI cannot spend another token.

Keeping an agent from unpausing itself

An audit of token scopes right after shipping the pause switch caught a subtle permission gap: POST /autopilot/resume initially accepted tasks:write, the same scope a coding agent's device login requests to queue tasks. Pausing only narrows permissions, so tasks:write can stay allowed to pause; lifting an owner's pause widens unattended execution, so POST /autopilot/resume now requires the owner-confirmed agents:write scope.

Learn how all eight autopilot triggers and spend caps work in Autopilot and Security.