AgentKit
DocsKitsCLI ReferenceDesktop App
BetaYou are reading docs for the beta channel (3.4.0-beta.1). Features may change before the next stable release.Switch to stable →

host

ak host gate

Wait out a saturated host, then run a heavy command at low priority

Use ak host gate -- <cmd> for builds, test suites, preflights, and installs. While the verdict is hold or clean, it waits with backoff; throttle, go, and unknown never block, and after --max-wait it runs anyway with a warning, so a gate never hangs a script. The command then runs at low CPU and I/O priority and its exit status is passed on. From AgentKit CLI v3.3.0-beta.20, --pause-on-hold also pauses the running command while the host stays on hold. See ak host for the verdicts.

Command contract

Wait out a saturated host, then run a heavy command at low priority

Synopsis

Checks host status (the watcher's snapshot when fresh, else a 3-second sample). While the verdict is hold, or clean (a watched volume is low on space), it waits with backoff 15 s, 30 s, then 60 s, printing one stderr line per wait with the verdict, its reasons and the top I/O process (its write rate; on Windows the rate counts all I/O, network and pipes included, and says so). throttle, go and unknown never block. --max-wait 0 skips the check entirely. After --max-wait it runs anyway with a warning, so a gate never hangs a script. A watcher notice for the current worktree is printed once and deleted.

The command then runs with this terminal's stdin, stdout and stderr at low priority (disable with --low-priority=false): on Windows it starts suspended in the below-normal priority class, inherited by its children, gets low I/O priority, then resumes; on Linux nice 10 plus the idle I/O class, both inherited; on macOS under taskpolicy -b. It is started directly, never through a shell. ak forwards Ctrl-C, SIGTERM and SIGHUP to it (on Linux it also gets SIGTERM if ak dies), waits, and passes its exit status on.

--pause-on-hold also pauses the running command and its child processes when two checks 30 s apart both read hold (SIGSTOP on Linux and macOS, NtSuspendProcess on Windows), and resumes them when the hold ends, after --max-pause, or before ak forwards a signal or exits. After a pause that reached --max-pause it does not pause again for the same length of time. Suits builds and installs; a test with timeouts may count paused time.

Effects: Runs the given command, which may change anything that command changes. Reads host status and deletes the current worktree's inbox notice; never reaches the network itself.

Exit status: 0 the command exited 0; any other status it exits with is passed on (128 plus the signal number if a signal ended it) 2 invalid flags or no command after -- 5 the command could not be started, or the wait was interrupted before it started

ak host gate [flags] -- <cmd> [args...]

Examples

  ak host gate -- go test ./...
  ak host gate --max-wait 10m -- pnpm build
  ak host gate --max-wait 0 -- make lint
  ak host gate --pause-on-hold -- pnpm install

Options

  -h, --help                 help for gate
      --json                 Emit machine-readable JSON (implies --no-interactive)
      --low-priority         Run the command at low CPU and I/O priority (default true)
      --max-pause duration   Longest single pause with --pause-on-hold (default 10m0s)
      --max-wait duration    Longest time to wait for the host before running anyway (0 runs at once) (default 30m0s)
      --no-interactive       Disable interactive prompts (CI-safe)
      --pause-on-hold        Pause the running command while the host stays on hold
  -q, --quiet                Suppress non-error output on stderr
  -V, --verbose              Extra diagnostic output on stderr (loses to --quiet)
  -y, --yes                  Assume yes for all prompts

SEE ALSO

  • ak host - Inspect host pressure before starting parallel work