-
Notifications
You must be signed in to change notification settings - Fork 2k
Feature proposal: codexbar guard — a quota-aware exit code to gate automation #2235
Copy link
Copy link
Closed
Labels
P3Low-risk cleanup, docs, polish, ergonomics, or speculative feature.Low-risk cleanup, docs, polish, ergonomics, or speculative feature.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.Issue quality rating does not apply to this item.
Description
Activity
Metadata
Metadata
Assignees
Labels
P3Low-risk cleanup, docs, polish, ergonomics, or speculative feature.Low-risk cleanup, docs, polish, ergonomics, or speculative feature.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.Issue quality rating does not apply to this item.
Summary
Add a
codexbar guardsubcommand that turns CodexBar from a passive display into an active guardrail: it exits0when a provider has enough headroom to safely start work, and non-zero when it doesn't — so it can be dropped into scripts and agent loops.Motivation
Today CodexBar (menu bar and CLI) reports limits — you still have to look, interpret the projection, and decide. For anyone running long or looping agent tasks, the failure mode is hitting a limit mid-task and losing the run.
The data to prevent that is already computed — the CLI prints
Pace: On pace | Expected 25% used | Projected empty in 3h 35m.guardjust exposes that as a decision an automated caller can act on, via the one thing shell/automation already speaks: an exit code.Proposed behaviour
--need 20%→ exit0if ≥20% of the relevant window remains, else exit non-zero.--for 3h(optional) → also fail if a reset would land inside that window, or if the current projection ("projected empty in …") is shorter than--for.0= safe,1= insufficient headroom,2= unknown/unreachable (fail-closed by default;--fail-opento invert).--json→ emit the decision + the numbers behind it for callers that want detail.Examples
Why this fits CodexBar
codex/claudeloops on remaining quota. Cross-platform (CLI/Core), so it lands for the Linux CLI users too.Scope (MVP)
Single provider,
--need <percent>, exit0/1/2, fail-closed.--for,--json, and multi-provider (--provider all, pass only if every provider passes) as follow-ups. Deterministic — straightforward to cover with focused tests (no live provider or app run needed).Status
Implemented in #2237 — build and Linux tests green. Feedback on the flag shape (
--need/--window/--fail-open) is very welcome, and I'm happy to close it if a quota-guard / exit-code contract isn't something you'd want in CodexBar, @steipete.