Pi / Oh My Pi extension that keeps a session inside a 5-hour provider usage budget.
The extension supports both harness binaries:
omp(Oh My Pi) by default.piwhenPI_BUDGET_OMP_BIN=piis set.
- Reads
<harness> usage --json --provider openai-codex, where<harness>isompby default orPI_BUDGET_OMP_BIN. - Enforces only the
5husage window by default. - Blocks new user prompts when the selected 5-hour window reaches the effective cap.
- Warns 2 percentage points before the effective cap.
- Ignores 7-day windows. They are observability, not enforcement.
- Blocks exec/write-class tool calls over cap:
bash,debug,edit,write,task,ast_edit,browser. - Allows slash commands and read/status work so the user can inspect or change policy.
/budget status
/budget on
/budget off
/budget ignore once
/budget ignore 30m
/budget cap 80
/budget cap reset
/budget config
If budget control is off when a session starts, the extension injects a visible notice: Budget control is turned off. To enable it, run /budget on.
Global defaults are configured with environment variables. /budget cap <percent> is a current-session override only; it does not edit global config or environment variables.
Environment variables:
| Variable | Default | Meaning |
|---|---|---|
PI_BUDGET_PROVIDER |
openai-codex |
Provider passed to <harness> usage --provider |
PI_BUDGET_WINDOW |
5h |
Enforced usage window |
PI_BUDGET_CAP_PERCENT |
95 |
Global default block threshold |
PI_BUDGET_WARN_PERCENT |
75 |
Global default warning threshold when no session cap is active |
PI_BUDGET_CACHE_MS |
30000 |
Usage snapshot cache TTL |
PI_BUDGET_OMP_BIN |
omp |
Harness CLI used to read usage. Set to pi for Pi. |
PI_BUDGET_FAIL_OPEN |
unset | Set 1 to allow prompts if usage cannot be read |
PI_BUDGET_DEFAULT_OFF |
unset | Set 1 to start disabled |
- Oh My Pi
omp >= 16.3.11for marketplace install autoload. - Older
ompversions may list the marketplace plugin but not load/budget. - Use
omp update, then reinstall the marketplace plugin with--force.
The repo includes project-local extension shims:
.omp/extensions/pi-budget-control.tsfor Oh My Pi..pi/extensions/pi-budget-control.tsfor Pi.
Opening omp or pi in this repo auto-loads /budget after the project is trusted. Use one-shot flags only when testing from another directory:
omp --extension .
PI_BUDGET_OMP_BIN=pi pi --extension .Oh My Pi marketplace install:
omp plugin marketplace add ./.
omp plugin install pi-budget-control@pi-budget-control-dev --forcePi local package install:
PI_BUDGET_OMP_BIN=pi pi install ./.If /budget is missing after marketplace install:
omp update
omp plugin install pi-budget-control@pi-budget-control-dev --force