{"id":51466150,"url":"https://github.com/boadij/pi-killswitch","last_synced_at":"2026-07-06T11:30:45.170Z","repository":{"id":363359569,"uuid":"1263002179","full_name":"boadij/pi-killswitch","owner":"boadij","description":"☠️ Killswitch - Keep Pi runs controlled with automatic context-budget wrap-up and kill thresholds.","archived":false,"fork":false,"pushed_at":"2026-06-08T15:26:43.000Z","size":434,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-08T16:22:33.450Z","etag":null,"topics":["coding-agent","context-budget","context-window","killswitch","llm","pi-coding-agent","pi-extension","pi-package","run-control","token-limit"],"latest_commit_sha":null,"homepage":"https://pi.dev/packages/pi-killswitch","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boadij.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-08T14:24:41.000Z","updated_at":"2026-06-08T15:27:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/boadij/pi-killswitch","commit_stats":null,"previous_names":["boadij/pi-killswitch"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/boadij/pi-killswitch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boadij%2Fpi-killswitch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boadij%2Fpi-killswitch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boadij%2Fpi-killswitch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boadij%2Fpi-killswitch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boadij","download_url":"https://codeload.github.com/boadij/pi-killswitch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boadij%2Fpi-killswitch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35189713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-06T02:00:07.184Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coding-agent","context-budget","context-window","killswitch","llm","pi-coding-agent","pi-extension","pi-package","run-control","token-limit"],"created_at":"2026-07-06T11:30:44.456Z","updated_at":"2026-07-06T11:30:45.163Z","avatar_url":"https://github.com/boadij.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ☠️ Killswitch\n\nKillswitch keeps Pi runs controlled by enforcing context-budget wrap-up and kill thresholds.\n\nStart working. Stop before the context gets out of hand.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"banner.jpg\" alt=\"Killswitch preview: Wrap Up. Kill Run.\"\u003e\n\u003c/p\u003e\n\n## What it does\n\n`pi-killswitch` watches Pi's current context usage and can request a wrap-up or kill the current run when configured thresholds are reached.\n\nIt can:\n\n- send a wrap-up steering message near the context budget\n- abort the current run at the kill threshold\n- auto-disable after a kill until the next safe rearm\n- persist per-session state across reloads\n\n## What it does not do\n\n`pi-killswitch` does not switch models, manage subagents, manage compaction, or route between premium and economy models.\n\n## Package contract\n\n`pi-killswitch` is a Pi package, not a generic Node library. Pi loads the TypeScript extension entry directly, and the package does not define Node library entry points.\n\n## Install\n\n```bash\npi install pi-killswitch\n```\n\nOpen the config UI:\n\n```text\n/killswitch\n```\n\nIf no config file exists, Killswitch uses safe defaults. To disable it globally, set `enabled` to `false` in `/killswitch`, or use `/killswitch off` to disable only the current session.\n\n## Commands\n\n```text\n/killswitch\n/killswitch status\n/killswitch wrap\n/wrap-up\n/killswitch on\n/killswitch off\n/killswitch help\n```\n\n- `/killswitch` opens the config UI.\n- `/killswitch status` shows current usage, active threshold, thresholds, mode, state, config path, and version.\n- `/killswitch wrap` requests an immediate wrap-up.\n- `/wrap-up` is a shortcut for requesting an immediate wrap-up.\n- `/killswitch on` enables Killswitch for the current session.\n- `/killswitch off` disables Killswitch for the current session.\n- `/killswitch help` shows command help.\n\n## Config\n\nConfig is stored in your Pi agent directory as `killswitch.json`.\n\nFields:\n\n- `enabled`: enable or disable globally\n- `mode`: `kill`, `wrap-up`, or `wrap-up-then-kill`\n- `autoDisarmAfterKill`: auto-disable after a kill before the next prompt\n- `autoRearmWhenSafe`: auto-rearm when usage falls back below the relevant threshold\n- `wrapUpThreshold`: threshold for wrap-up, required unless mode is `kill`\n- `killThreshold`: threshold for kill\n- `wrapUpMessage`: wrap-up message\n\nThresholds are explicit and use exactly one metric:\n\n```json\n{ \"metric\": \"percent\", \"value\": 75 }\n```\n\nor:\n\n```json\n{ \"metric\": \"tokens\", \"value\": 100000 }\n```\n\nIn `wrap-up-then-kill` mode, the wrap-up and kill thresholds must use the same metric, and wrap-up must be lower than kill.\n\nInvalid or unreadable config produces a visible error and falls back to safe defaults.\n\n## Wrap-up vs kill\n\nA wrap-up sends a user steering message asking the agent to finish gracefully, summarize current state, avoid more tools, and stop.\n\nA kill aborts the current agent run immediately, marks the session as killed, then auto-disables before the next prompt. It re-arms automatically when context falls back below the kill threshold.\n\nIn `wrap-up-then-kill` mode, Killswitch requests wrap-up when the wrap threshold is reached. If the kill threshold is already reached in the same context event, it kills immediately rather than waiting for another event.\n\n## Recommended defaults\n\nThe default mode is `wrap-up-then-kill`:\n\n```json\n{\n  \"enabled\": true,\n  \"mode\": \"wrap-up-then-kill\",\n  \"autoDisarmAfterKill\": true,\n  \"autoRearmWhenSafe\": true,\n  \"wrapUpThreshold\": { \"metric\": \"percent\", \"value\": 75 },\n  \"killThreshold\": { \"metric\": \"percent\", \"value\": 85 },\n  \"wrapUpMessage\": \"Context budget reached. Finish gracefully, summarize current state, do not call more tools, and stop.\"\n}\n```\n\n## Relationship to pi-downshift\n\n[`pi-downshift`](https://github.com/boadij/pi-downshift) switches to a cheaper model after a context threshold.\n\n[`pi-killswitch`](https://github.com/boadij/pi-killswitch) wraps up or kills the run after a context threshold.\n\nThey solve related but different problems.\n\n## Release\n\nLocal checks before publishing:\n\n```bash\nnpm ci\nnpm run check\nnpm pack --dry-run\n```\n\nRelease Please is configured for `pi-killswitch` and npm provenance publishing. See [RELEASING.md](./RELEASING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboadij%2Fpi-killswitch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboadij%2Fpi-killswitch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboadij%2Fpi-killswitch/lists"}