Restart-on-exit supervisor for autonomous CLI agents
Project description
中文 · English
agent-runner
A restart-on-exit supervisor for autonomous CLI agents. Spawn an agent (Claude Code, a custom CLI, anything) round-after-round under defenses that prevent the failure modes that bite in production: stuck rounds, orphan commits, OAuth burn loops, full disks, runaway memory.
┌──────────────────────────────────────────┐
│ Layer 3: The Witness (monitor) │ 9 detectors + auto-stop
├──────────────────────────────────────────┤
│ Layer 2: The Loop (serve, ~60 LOC) │ signal-trapping restart loop
├──────────────────────────────────────────┤
│ Layer 1: The Round (round) │ one agent invocation
└──────────────────────────────────────────┘
Install
pip install cli-agent-runner
The installed CLI command is agent-runner (the PyPI distribution name is
prefixed for namespace disambiguation; the import name and command are not).
Quick start
cd your-project
agent-runner init # scaffold agent-runner.toml + prompts/main.md
$EDITOR agent-runner.toml # point agent.command at your CLI
agent-runner install --monitor # systemd user units for serve + monitor
agent-runner status # confirm running
agent-runner peek # snapshot of project state
agent-runner monitor # live anomaly detection
Full walkthrough: docs/quickstart.md.
13 verbs
| Lifecycle | Observation |
|---|---|
init / install / uninstall |
peek — state snapshot |
start / stop / kill / cancel |
watch — peek in a refresh loop |
restart / status |
monitor — 9 detectors, alerts, auto-stop |
round / serve |
Verb reference: docs/commands.md.
Defenses (built in)
11 named defenses, structured as data — see agent-runner peek --select defenses.
Each carries the historical incident it codifies and the invariant test that
guards it. Highlights:
- round_timeout_s — hard wall, never the agent's word on when to stop
- process_group_isolation — kill the round, not just the parent
- orphan_stash_idempotency_s — no 3-stashes-per-second pile-ups
- sha_locked_stash —
stash@{N}indices drift; SHAs don't - set_diff_classification — line-set comparison, not unified-diff +/- scan
- startup_smoke_check — refuse to run with a clearly-truncated prompt
Full list and rationale: docs/architecture.md.
Monitor: 9 detectors
Notify only: timeout_rate, hung, orphan_chain, disk_warning,
mem_pressure, smoke_fail_rate, network_fail.
Auto-stop the service (continuing is harmful):
oauth_fail— burning API quota on auth-rejected roundsdisk_critical— writing to a near-full disk risks corruption
Runs locally or against a remote host via ssh:
agent-runner monitor # local, 30s poll
agent-runner monitor --host pi # remote, 60s poll
agent-runner monitor --json | jq -c # pipe to downstream consumers
Documentation
docs/quickstart.md— 5-step install + first rounddocs/commands.md— verb referencedocs/configuration.md—agent-runner.tomlschemadocs/runbook.md— operator troubleshooting (OAuth, disk, orphan)docs/architecture.md— 3-layer model, defenses-as-data
Status
Phase 2 (operator surface) shipped. Phase 3 (LLM-augmented Critic) reserved —
[llm] config block and agent_runner.critic Protocol stubs are in place,
implementation TBD.
Development
git clone https://github.com/wan9yu/cli-agent-runner.git
cd cli-agent-runner
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
./build.sh check # full local-CI sweep
./build.sh test # unit + integration only
AGENT_RUNNER_E2E_PI=1 ./build.sh e2e # opt-in pi e2e (needs ssh alias `pi`)
Some docs/*.md blocks are generated from code — ./build.sh docs rewrites
the <!-- gen:* --> regions, and ./build.sh check verifies they are fresh.
POSIX-only (Linux, macOS). Tested under Python 3.11+ on x86_64 and aarch64.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cli_agent_runner-0.1.1.tar.gz.
File metadata
- Download URL: cli_agent_runner-0.1.1.tar.gz
- Upload date:
- Size: 89.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a8afdf488a4415005586e0d3ce7b5cfc14a3b72741e090d58ce8e385e3866bc
|
|
| MD5 |
a99191886540151a08ceb478384cf959
|
|
| BLAKE2b-256 |
56d7eb9f9c8ca31f7e2f0ae2d274df8fbdee3dc501f73ebbfb31dcc4a616e854
|
Provenance
The following attestation bundles were made for cli_agent_runner-0.1.1.tar.gz:
Publisher:
release.yml on wan9yu/cli-agent-runner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cli_agent_runner-0.1.1.tar.gz -
Subject digest:
0a8afdf488a4415005586e0d3ce7b5cfc14a3b72741e090d58ce8e385e3866bc - Sigstore transparency entry: 1508740394
- Sigstore integration time:
-
Permalink:
wan9yu/cli-agent-runner@b28618af7daf66c81d91b70f4580c6fac417b3d6 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/wan9yu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b28618af7daf66c81d91b70f4580c6fac417b3d6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cli_agent_runner-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cli_agent_runner-0.1.1-py3-none-any.whl
- Upload date:
- Size: 50.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24e192cdea0eed97ac35e44eda105d839443385f20fd9365b13dc7c1deea60c4
|
|
| MD5 |
63efdd0de2b90b70b6a56a5081bd4b3b
|
|
| BLAKE2b-256 |
4bb057b81a610913ccf1e2a015610ba2f79eb6261966d03121a2f93cebb48be1
|
Provenance
The following attestation bundles were made for cli_agent_runner-0.1.1-py3-none-any.whl:
Publisher:
release.yml on wan9yu/cli-agent-runner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cli_agent_runner-0.1.1-py3-none-any.whl -
Subject digest:
24e192cdea0eed97ac35e44eda105d839443385f20fd9365b13dc7c1deea60c4 - Sigstore transparency entry: 1508742015
- Sigstore integration time:
-
Permalink:
wan9yu/cli-agent-runner@b28618af7daf66c81d91b70f4580c6fac417b3d6 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/wan9yu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b28618af7daf66c81d91b70f4580c6fac417b3d6 -
Trigger Event:
push
-
Statement type: