agentcap-cli 0.3.1__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/PKG-INFO +87 -23
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/README.md +86 -22
- agentcap_cli-0.4.1/landing/v2/README.md +68 -0
- agentcap_cli-0.4.1/plugin/LICENSE +21 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/pyproject.toml +1 -1
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/__init__.py +1 -1
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/alerts.py +25 -1
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/cli.py +27 -5
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/harness.py +63 -3
- agentcap_cli-0.4.1/src/agentcap/live_quota.py +251 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/quota.py +860 -45
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/waste.py +36 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/conftest.py +6 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_cc_plugin.py +107 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_harness.py +55 -4
- agentcap_cli-0.4.1/tests/test_live_quota.py +684 -0
- agentcap_cli-0.4.1/tests/test_plugin_package.py +112 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_procstop.py +40 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_proxy_auth.py +2 -2
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_quota.py +357 -10
- agentcap_cli-0.4.1/tests/test_stop_matrix.py +292 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/.gitignore +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/LICENSE +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/_lifeline_exec.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/_lifeline_watch.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/adapters.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/analytics.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/budget.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/clamp.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/cli_history.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/data/pricing.json +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/demo.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/devtools/__init__.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/devtools/fake_upstream.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/estimate.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/eta.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/failsafe.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/history.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/ledger.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/license.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/lifeline.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/logschema.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/loop.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/plans.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/pricing.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/private.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/procstop.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/proxy.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/report.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/runner.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/upstreams.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/src/agentcap/usage.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/agents/claude/projects/-home-dev-shop/sess-p/subagents/agent-a1b2c3.jsonl +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/agents/claude/projects/-home-dev-shop/sess-p/subagents/agent-d4e5f6.jsonl +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/agents/claude/projects/-home-dev-shop/sess-p.jsonl +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/agents/codex/sessions/2026/10/29/rollout-2026-10-29T09-00-00-thr-parent.jsonl +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/agents/codex/sessions/2026/10/29/rollout-2026-10-29T09-00-50-thr-child.jsonl +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/agents/codex/sessions/2026/10/29/rollout-2026-10-29T09-01-20-thr-fork.jsonl +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/harness_logs/agy-1.4.11-2026-10-30.jsonl +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/harness_logs/claude-2.1.316-pretooluse.json +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/harness_logs/claude-2.1.316-statusline.json +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/harness_logs/codex-rollout-2026-10-29.jsonl +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/harness_logs/opencode-2026-10-30.jsonl +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/history/claude/.credentials.json +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/history/claude/projects/-home-dev-shop/1f0c-sess-a.jsonl +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/history/codex/auth.json +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/history/codex/sessions/2026/10/29/rollout-2026-10-29T10-00-00-0199aaaa-bbbb-cccc-dddd-eeeeeeeeeeee.jsonl +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/upstream/README.md +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/upstream/anthropic_403_permission_error.json +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/upstream/openai_403_region_blocked.json +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/upstream/openrouter_401_user_not_found.json +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/upstream/openrouter_403_moderation.json +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/fixtures/upstream/openrouter_429_rate_limited.json +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/license_support.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/proxy_support.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_adapters.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_agents.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_alerts.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_analytics.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_anthropic_proxy.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_anthropic_units.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_budget.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_child_status.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_clamp.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_claude_adapter_and_tiers.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_cli.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_concurrent_forgive.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_e2e_claude.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_estimate.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_exit_codes.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_failsafe.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_history.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_ledger.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_license.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_lifeline.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_log_contract.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_log_contract_live.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_loop.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_pricing.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_private_dirs.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_proxy_cancel.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_proxy_core.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_proxy_extras.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_proxy_streaming.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_release.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_report_cli.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_runaway.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_runner.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_self_approve.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_upstream_refusals.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_upstreams.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_usage.py +0 -0
- {agentcap_cli-0.3.1 → agentcap_cli-0.4.1}/tests/test_zombie_collector.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: agentcap-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: Local-first quota and cost guard for coding agents: per-job share of Claude Code/Codex/Gemini subscription quota, loop breaker, evidence receipt.
|
|
5
5
|
Project-URL: Homepage, https://agentcap.launchbench.studio
|
|
6
6
|
Project-URL: Repository, https://github.com/Blitz00X/agentcap
|
|
@@ -75,17 +75,20 @@ your subscription quota % and Codex support.
|
|
|
75
75
|
proxy also catches identical requests and `--max-burn` $/min spikes.
|
|
76
76
|
- **Per-job quota %.** Stop one job at its share of the account's weekly or 5-hour limit.
|
|
77
77
|
- **Evidence receipt.** Each stop prints and saves why (`same tool call 4 times in a row (Bash)`,
|
|
78
|
-
`
|
|
78
|
+
`the account's weekly quota rose 5.1% while this job ran`) and the last tool call's name, as numbers and tool
|
|
79
79
|
names only, never prompts or tool inputs.
|
|
80
80
|
- **Approve.** After a stop, `agentcap approve` (or `/agentcap:approve` in the plugin) raises the
|
|
81
81
|
limit by 50%, at most twice, and the run continues. This works for interactive Claude Code,
|
|
82
82
|
which stays open after a stop. Codex and headless `claude -p` jobs are stopped with SIGINT, so
|
|
83
83
|
there approve only helps before the limit is hit; after a stop it says so and changes nothing.
|
|
84
|
+
Run it from your own shell while the job runs (live Codex test: `1% -> 1.5% -> 2.25%`, the third
|
|
85
|
+
approve refused). With whole-percent quota steps a 1.5% limit stops at the next step, 2%.
|
|
84
86
|
- **Free** runs the same detectors in observe-only mode and prints what Pro would have done.
|
|
85
87
|
|
|
86
88
|
Honest limits: Claude tool-error streaks are only caught on API-key runs (the subscription hook sees
|
|
87
89
|
the call, not its result); the stop can be one request late; quota % is account-level; verified on
|
|
88
|
-
fixtures, fake CLIs and real Claude Code
|
|
90
|
+
fixtures, fake CLIs and real Claude Code hooks; quota stops verified on real Claude Pro and ChatGPT
|
|
91
|
+
Plus accounts (see "Supported & tested").
|
|
89
92
|
|
|
90
93
|
## The API-key cap
|
|
91
94
|
|
|
@@ -279,7 +282,11 @@ The easiest path on a Claude Max or Pro plan. Inside Claude Code:
|
|
|
279
282
|
/agentcap:off # clear it; /agentcap:unsetup restores your old statusLine
|
|
280
283
|
```
|
|
281
284
|
|
|
282
|
-
No pip install: the plugin is stdlib Python (`python3` on PATH).
|
|
285
|
+
No pip install: the plugin is stdlib Python (`python3` on PATH). The marketplace installs only
|
|
286
|
+
the self-contained `plugin/` folder (commands, hooks, the script and the few `agentcap` modules it
|
|
287
|
+
imports), not the whole repo. Contributors: `plugin/` is generated, edit the sources and run
|
|
288
|
+
`python3 scripts/build_plugin.py` (`--check` verifies; `claude --plugin-dir plugin` loads it locally).
|
|
289
|
+
How it works:
|
|
283
290
|
|
|
284
291
|
- Claude Code only exposes the subscription `rate_limits` % to the **statusLine** command, and a
|
|
285
292
|
plugin can't set the main statusLine. So `/agentcap:setup` asks once and writes it to
|
|
@@ -289,6 +296,10 @@ No pip install: the plugin is stdlib Python (`python3` on PATH). How it works:
|
|
|
289
296
|
`Stop` prints a receipt (`session 4.2% / 5% (weekly)`). **Free:** live meter + one notice
|
|
290
297
|
at the limit (`Pro would stop the agent here`). Pro is read from the licence the `agentcap`
|
|
291
298
|
CLI stores after `agentcap license activate` (paste the key at the hidden prompt).
|
|
299
|
+
- Waiting is not looping: a shell call that starts with `sleep N` (`sleep 4; ls done.flag`,
|
|
300
|
+
`sleep 30 && curl .../health`) counts toward neither the repeat streak nor the error streak,
|
|
301
|
+
in the CLI (Claude and Codex) and the plugin (live gate test: a 4th wait-for-a-file check was
|
|
302
|
+
stopped as a loop). An endless `sleep 1; retry` loop is then only stopped by the quota.
|
|
292
303
|
- Loop breaker (works with or without `/agentcap:quota`): `PreToolUse` hashes each tool call
|
|
293
304
|
(name + input, per session and per subagent; polling tools like `TaskOutput`/`BashOutput`
|
|
294
305
|
are ignored). The 4th identical call in a row is denied with `continue: false` on **Pro**;
|
|
@@ -296,13 +307,20 @@ No pip install: the plugin is stdlib Python (`python3` on PATH). How it works:
|
|
|
296
307
|
tool calls: 8 in a row stops the agent on Pro (`continue: false`), Free gets a notice.
|
|
297
308
|
Tool input and output are never stored, only a 16-char hash and counts; these per-session
|
|
298
309
|
files are deleted after 7 days (on `SessionStart`).
|
|
310
|
+
- `/usage` as well: `/agentcap:quota` takes its baseline from Claude Code's own
|
|
311
|
+
`claude -p /usage` (a local command, no model call, no quota), and while a quota is set the
|
|
312
|
+
`PreToolUse` hook starts a background `/usage` read at most once a minute. The share is the
|
|
313
|
+
higher of the statusline and `/usage` (the statusline lagged `/usage` by 1-2 points in live
|
|
314
|
+
tests, and a stale first value once looked like 1% of use). Without `/usage` the baseline is
|
|
315
|
+
only this session's own statusline reading, never another session's.
|
|
299
316
|
- Read-only: no OAuth token, credentials file or API traffic is touched.
|
|
300
317
|
|
|
301
|
-
Honest limits: the % is account-level (parallel sessions count), the stop can
|
|
302
|
-
late, and the share updates when the
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
318
|
+
Honest limits: the % is account-level (parallel sessions and other devices count), the stop can
|
|
319
|
+
be one request late (a `/usage` check runs at most once a minute), and the share updates when the
|
|
320
|
+
statusLine refreshes. Verified live on a real Claude Pro account with Claude Code 2.1.323
|
|
321
|
+
(13 Nov 2026): `/agentcap:setup`, `/agentcap:quota 2% 5h` with its baseline from `/usage`,
|
|
322
|
+
the stop at the limit, `/agentcap:approve`, `/agentcap:unsetup`, and the self-guard denying
|
|
323
|
+
`env -u CLAUDECODE agentcap approve` from the model.
|
|
306
324
|
|
|
307
325
|
## Works with Claude Max / ChatGPT subscriptions (quota mode)
|
|
308
326
|
|
|
@@ -312,7 +330,7 @@ Quota mode caps **one job's share** of it:
|
|
|
312
330
|
```bash
|
|
313
331
|
agentcap run --quota 5% -- claude # stop this job after 5% of the weekly quota
|
|
314
332
|
agentcap run --quota 10% --window 5h -- codex # or 10% of the 5-hour window
|
|
315
|
-
agentcap quota # read-only:
|
|
333
|
+
agentcap quota # read-only: current usage, asked from claude/codex (Free)
|
|
316
334
|
```
|
|
317
335
|
|
|
318
336
|
- **Read-only, ToS-safe.** AgentCap never proxies, reads or reuses your subscription login
|
|
@@ -325,24 +343,70 @@ agentcap quota # read-only: last seen usage (Fre
|
|
|
325
343
|
plus a `PreToolUse` hook that denies further tool calls with a clear reason once the job's
|
|
326
344
|
share reaches the limit and ends the turn (`continue: false`). An interactive session stays open
|
|
327
345
|
(run `agentcap approve` to continue, or quit); a session where the hook never fired gets
|
|
328
|
-
SIGINT. Exit code 3.
|
|
329
|
-
|
|
346
|
+
SIGINT. Exit code 3.
|
|
347
|
+
AgentCap also asks `claude -p /usage` (a local command: no model call, no quota) at start,
|
|
348
|
+
every minute and once after exit. The statusline % and `/usage` differ by one point at both
|
|
349
|
+
ends of a job (live: 26/27 at start, 31/32 at the end), so the statusline is only compared
|
|
350
|
+
with itself, the hook also denies when `/usage` shows the limit first, and the receipt is the
|
|
351
|
+
`/usage` difference (`measured_by: usage`). `/usage` itself shows a job's usage 30-90 s after
|
|
352
|
+
its requests (live gate test: short jobs read 0.0% at exit and the % appeared a minute later),
|
|
353
|
+
so a quota stop can come that much later, and after a Claude job a detached process keeps
|
|
354
|
+
reading `/usage` for up to 90 s and rewrites the receipt with the settled share
|
|
355
|
+
(`settled: true`, `share_pct_at_exit` keeps the first value). It stops early when the value
|
|
356
|
+
holds or when another AgentCap quota job starts (`settle_cut`); other Claude use on the account
|
|
357
|
+
in those 90 s (another chat, another device) still counts toward the receipt.
|
|
358
|
+
The hook can stop Claude only before a tool call, so one large response overshoots: live, a
|
|
359
|
+
3% limit ended at 5% after one response with 7 parallel file reads used 3%. Usage on the same
|
|
360
|
+
account from anywhere else (claude.ai, the desktop or phone app, another terminal) counts
|
|
361
|
+
toward the job too. **Headless `claude -p`** has no statusline, so there `/usage` is the only
|
|
362
|
+
source: it is checked every 30 s and the hook ends the run at the limit (SIGINT if it keeps
|
|
363
|
+
going). Usage between two checks can overshoot. If `/usage` does not answer at start,
|
|
364
|
+
`--quota` warns and only the loop/error breakers are active.
|
|
330
365
|
- **Codex CLI:** AgentCap tails the `token_count` events Codex writes to
|
|
331
366
|
`~/.codex/sessions/**/rollout-*.jsonl` (`rate_limits.primary/secondary.used_percent`,
|
|
332
367
|
`window_minutes`, `resets_at`) and sends SIGINT at the limit. Exit code 3.
|
|
368
|
+
The % in a rollout is the value Codex got *with* a response, before that response was
|
|
369
|
+
charged, so it lags one response (live: the rollout said 3% after a job, the server 4%).
|
|
370
|
+
AgentCap therefore also asks Codex's own `codex app-server` (`account/rateLimits/read`, the
|
|
371
|
+
protocol the IDE extension uses; no model call, no quota spent, Codex handles its own login):
|
|
372
|
+
for the baseline at start, every 30 s during the job, and once after the agent exits, so the
|
|
373
|
+
last response is in the receipt (`baseline_live`, `final_live`). If the server does not answer,
|
|
374
|
+
the rollout readings are used as before.
|
|
375
|
+
Codex writes usage only when a model response ends, so one long response (xhigh/max effort
|
|
376
|
+
ran 6+ minutes in our tests) is invisible until it finishes. In quota mode AgentCap therefore
|
|
377
|
+
stops the job when a single response runs longer than `--response-timeout` (default `5m`,
|
|
378
|
+
`off` disables; time spent running tools does not count) and notes xhigh/max effort at start.
|
|
379
|
+
The interrupted response's usage is read before the receipt is written. Exit code 4,
|
|
380
|
+
reason `response_timeout`.
|
|
381
|
+
**Fail-closed (Pro):** if Codex's `token_count` events carry no `rate_limits` (API-key login, a
|
|
382
|
+
changed log format) or `codex exec` writes no session log within 90 s, the job is stopped
|
|
383
|
+
(exit 5); Free only warns. The interactive TUI is never stopped just for being idle.
|
|
333
384
|
- Baseline at job start (exact when a reading from the last 15 minutes exists, otherwise the
|
|
334
385
|
first response is not counted), window resets mid-job are handled, 80% warning,
|
|
335
|
-
per-job receipt: `
|
|
336
|
-
and receipt files work the same as for dollar caps.
|
|
386
|
+
per-job receipt: `the account's weekly quota rose 4.2% while this job ran`. Pro alerts
|
|
387
|
+
(Telegram/webhook) and receipt files work the same as for dollar caps. `agentcap` stopped by
|
|
388
|
+
Ctrl+C, SIGTERM (`timeout`) or SIGHUP (closed terminal) stops the agent and still writes the
|
|
389
|
+
receipt (reason `interrupted` / `terminated`).
|
|
390
|
+
- **`agentcap quota`** asks each agent's own client for the current values: `codex app-server`
|
|
391
|
+
for Codex and `claude -p /usage` for Claude Code (both read-only, no model call). Lines from a
|
|
392
|
+
live answer end in `(live from codex)` / `(live from claude)`; otherwise the last local
|
|
393
|
+
reading is shown with its age. `agentcap quota --local` never starts claude/codex.
|
|
394
|
+
`AGENTCAP_LIVE_QUOTA=0` turns live reads off everywhere.
|
|
337
395
|
- **Free:** `agentcap quota` and observe-only runs that print the job's share and
|
|
338
396
|
`Pro's quota mode would have stopped this job at 5%`. **Pro:** stopping at the limit.
|
|
339
397
|
|
|
340
398
|
**Honest limits.** The percentage is **account-level**: a parallel session or claude.ai/chatgpt.com
|
|
341
399
|
use in the same window counts against the job (AgentCap warns when it sees another session).
|
|
342
400
|
Values arrive once per model response, so a job **can overshoot by up to one request**.
|
|
343
|
-
Claude Code only reports `rate_limits` for Pro/Max logins and only in
|
|
344
|
-
(the statusline does not run in `claude -p`). Codex's rollout format is undocumented and may change. Codex reports `used_percent` in whole percent, so a Codex cap under 1% cannot trigger until the job has used a full 1% (AgentCap warns at start). Use `--quota 1%` or more for Codex.
|
|
401
|
+
Claude Code only reports `rate_limits` to the statusline for Pro/Max logins and only in
|
|
402
|
+
interactive sessions (the statusline does not run in `claude -p`; there AgentCap reads `/usage`). Codex's rollout format is undocumented and may change. Codex reports `used_percent` in whole percent, so a Codex cap under 1% cannot trigger until the job has used a full 1% (AgentCap warns at start). Use `--quota 1%` or more for Codex.
|
|
345
403
|
Claude Code reports whole percents too: a cap under 1% trips at the next 1% step (AgentCap warns).
|
|
404
|
+
One response can move the account by a full step, so a 2.25% limit can end at 3%.
|
|
405
|
+
The interactive Codex TUI ignores SIGINT mid-turn, so AgentCap escalates to SIGTERM; the
|
|
406
|
+
interrupted response's usage may then be missing from the receipt (`final_read: incomplete`),
|
|
407
|
+
while the account increase it reports stays correct. AgentCap restores the terminal afterwards.
|
|
408
|
+
Codex's own sandbox (bubblewrap) fails inside some agent shells on Ubuntu
|
|
409
|
+
(`kernel.apparmor_restrict_unprivileged_userns=1`); in a normal terminal it works.
|
|
346
410
|
Verified on real accounts: see the harness support matrix under "Supported & tested".
|
|
347
411
|
|
|
348
412
|
## opencode and agy (Antigravity CLI)
|
|
@@ -420,10 +484,10 @@ Legend: ✅ verified on a real account/endpoint · ⚠️ works with a limitatio
|
|
|
420
484
|
|
|
421
485
|
| Harness + auth | Loop breaker (4x same call, exit 4) | Error breaker (8 failures, exit 4) | Quota % stop (exit 3) | $ / token cap |
|
|
422
486
|
| --- | --- | --- | --- | --- |
|
|
423
|
-
| Claude Code, Pro/Max sub, interactive | ✅ (deny keeps the session; resumes after approve) | ✅ | ✅
|
|
424
|
-
| Claude Code, Pro/Max sub, headless `claude -p` | ✅ (exit 4) | ✅ (exit 4) |
|
|
425
|
-
| Codex, ChatGPT sub | ✅ | ✅ | ✅ (whole %; warns under 1%) | ❌ by design (no proxy on a subscription) |
|
|
426
|
-
| opencode Go | ✅ | ✅ | ❌ opencode
|
|
487
|
+
| Claude Code, Pro/Max sub, interactive | ✅ (deny keeps the session; resumes after approve) | ✅ | ✅ statusline + `/usage` every minute (deny keeps the session); `agentcap approve` ✅. Live, Claude Code 2.1.322/323, Pro, 12-13 Nov 2026 | ❌ by design (no proxy on a subscription login; AgentCap refuses) |
|
|
488
|
+
| Claude Code, Pro/Max sub, headless `claude -p` | ✅ (exit 4) | ✅ (exit 4) | ✅ via `/usage` every 30 s (coarser; live: a 2% cap ended at 4%) | ❌ by design (refused) |
|
|
489
|
+
| Codex, ChatGPT sub | ✅ | ✅ | ✅ `exec` and interactive TUI (whole %; warns under 1%; one-response timeout, default 5m; terminal restored after a TUI stop; approve mid-run; live % from `codex app-server` at start, every 30 s and after exit). Live, Codex 0.167.1, Plus, 11-12 Nov 2026 | ❌ by design (no proxy on a subscription) |
|
|
490
|
+
| opencode Go | ✅ | ✅ | ❌ not yet: opencode 1.x's session log reports Go cost as 0 and leaves out subagents (live test, 11 Nov 2026), so a Go % cap cannot be measured; do not rely on `--quota` with opencode | ✅ `--tokens`; `--log-cap` uses opencode's own price table |
|
|
427
491
|
| agy, Google sub (plain `agentcap run -- agy` needs no key: breakers only) | ✅ | ✅ | ✅ (tested at 0.5%; ~10 s polling, can overshoot) | ❌ (sub); $ only via Gemini API |
|
|
428
492
|
| opencode + OpenRouter (free model) | ✅ | ✅ | n/a | ✅ $ cap |
|
|
429
493
|
| opencode + Ollama Cloud | ✅ | ✅ | n/a | ⚠️ needs a user price (`AGENTCAP_PRICING_FILE`): Ollama publishes none |
|
|
@@ -441,7 +505,7 @@ period AgentCap sends SIGINT and the session ends; Codex's sandbox can't run com
|
|
|
441
505
|
`kernel.apparmor_restrict_unprivileged_userns=1` blocks bubblewrap's user namespace
|
|
442
506
|
(host setting, not AgentCap; Codex falls back or needs an AppArmor profile for bwrap).
|
|
443
507
|
|
|
444
|
-
**Platforms:** Linux
|
|
508
|
+
**Platforms:** Linux (tested live). macOS: the code path exists but has not been tested on a real Mac yet; the Linux-only parts (parent-death signal, subreaper) do not apply there. Windows: not yet (use WSL2).
|
|
445
509
|
|
|
446
510
|
## How it works
|
|
447
511
|
|
|
@@ -509,7 +573,7 @@ output limit, so a clamp also caps them.
|
|
|
509
573
|
| --- | --- |
|
|
510
574
|
| `2` | Setup or auth refusal: bad flags, a Pro-only flag on Free, a conflicting CLI config, a second quota job, the provider rejected the credentials (`upstream_auth_failed`), or it refused the request for another reason (`upstream_refused`). |
|
|
511
575
|
| `3` | A cap stopped the agent (`--cap`, `--quota`, `--tokens`, `--log-cap`). |
|
|
512
|
-
| `4` | Pro's loop/error/burn breaker stopped the agent
|
|
576
|
+
| `4` | Pro's loop/error/burn breaker stopped the agent, or (Codex quota mode) one model response ran past `--response-timeout`. |
|
|
513
577
|
| `5` | Internal error: AgentCap could not use its own state (HOME, `quota.lock`, ledger, license or job files), its proxy could not start, an opencode/agy log schema or Codex rollout log could not be read (fail-closed), or AgentCap hit an internal fault. The message names the failed action and path (`internal state error: could not open the quota lock ...`); the agent was not started, or was stopped (reason `internal_error`). |
|
|
514
578
|
| `127` | The command itself could not be started (not found, not executable): `could not start the command (...)`. |
|
|
515
579
|
|
|
@@ -545,7 +609,7 @@ Request bodies are billed at price-book rates; embeddings are input-only.
|
|
|
545
609
|
- The ledger lives at `~/.local/state/agentcap/ledger.sqlite3`
|
|
546
610
|
(override with `$AGENTCAP_DB`).
|
|
547
611
|
|
|
548
|
-
### Stopping, fail-closed and self-approval (0.3
|
|
612
|
+
### Stopping, fail-closed and self-approval (0.3+, Linux-verified)
|
|
549
613
|
|
|
550
614
|
- **Whole process tree.** A quota/harness stop (`--quota`, `--tokens`, `--log-cap`) sends SIGINT
|
|
551
615
|
to the agent's process group, then SIGTERM, then SIGKILL (5 s / 3 s / 2 s); a proxy (`--cap`)
|
|
@@ -45,17 +45,20 @@ your subscription quota % and Codex support.
|
|
|
45
45
|
proxy also catches identical requests and `--max-burn` $/min spikes.
|
|
46
46
|
- **Per-job quota %.** Stop one job at its share of the account's weekly or 5-hour limit.
|
|
47
47
|
- **Evidence receipt.** Each stop prints and saves why (`same tool call 4 times in a row (Bash)`,
|
|
48
|
-
`
|
|
48
|
+
`the account's weekly quota rose 5.1% while this job ran`) and the last tool call's name, as numbers and tool
|
|
49
49
|
names only, never prompts or tool inputs.
|
|
50
50
|
- **Approve.** After a stop, `agentcap approve` (or `/agentcap:approve` in the plugin) raises the
|
|
51
51
|
limit by 50%, at most twice, and the run continues. This works for interactive Claude Code,
|
|
52
52
|
which stays open after a stop. Codex and headless `claude -p` jobs are stopped with SIGINT, so
|
|
53
53
|
there approve only helps before the limit is hit; after a stop it says so and changes nothing.
|
|
54
|
+
Run it from your own shell while the job runs (live Codex test: `1% -> 1.5% -> 2.25%`, the third
|
|
55
|
+
approve refused). With whole-percent quota steps a 1.5% limit stops at the next step, 2%.
|
|
54
56
|
- **Free** runs the same detectors in observe-only mode and prints what Pro would have done.
|
|
55
57
|
|
|
56
58
|
Honest limits: Claude tool-error streaks are only caught on API-key runs (the subscription hook sees
|
|
57
59
|
the call, not its result); the stop can be one request late; quota % is account-level; verified on
|
|
58
|
-
fixtures, fake CLIs and real Claude Code
|
|
60
|
+
fixtures, fake CLIs and real Claude Code hooks; quota stops verified on real Claude Pro and ChatGPT
|
|
61
|
+
Plus accounts (see "Supported & tested").
|
|
59
62
|
|
|
60
63
|
## The API-key cap
|
|
61
64
|
|
|
@@ -249,7 +252,11 @@ The easiest path on a Claude Max or Pro plan. Inside Claude Code:
|
|
|
249
252
|
/agentcap:off # clear it; /agentcap:unsetup restores your old statusLine
|
|
250
253
|
```
|
|
251
254
|
|
|
252
|
-
No pip install: the plugin is stdlib Python (`python3` on PATH).
|
|
255
|
+
No pip install: the plugin is stdlib Python (`python3` on PATH). The marketplace installs only
|
|
256
|
+
the self-contained `plugin/` folder (commands, hooks, the script and the few `agentcap` modules it
|
|
257
|
+
imports), not the whole repo. Contributors: `plugin/` is generated, edit the sources and run
|
|
258
|
+
`python3 scripts/build_plugin.py` (`--check` verifies; `claude --plugin-dir plugin` loads it locally).
|
|
259
|
+
How it works:
|
|
253
260
|
|
|
254
261
|
- Claude Code only exposes the subscription `rate_limits` % to the **statusLine** command, and a
|
|
255
262
|
plugin can't set the main statusLine. So `/agentcap:setup` asks once and writes it to
|
|
@@ -259,6 +266,10 @@ No pip install: the plugin is stdlib Python (`python3` on PATH). How it works:
|
|
|
259
266
|
`Stop` prints a receipt (`session 4.2% / 5% (weekly)`). **Free:** live meter + one notice
|
|
260
267
|
at the limit (`Pro would stop the agent here`). Pro is read from the licence the `agentcap`
|
|
261
268
|
CLI stores after `agentcap license activate` (paste the key at the hidden prompt).
|
|
269
|
+
- Waiting is not looping: a shell call that starts with `sleep N` (`sleep 4; ls done.flag`,
|
|
270
|
+
`sleep 30 && curl .../health`) counts toward neither the repeat streak nor the error streak,
|
|
271
|
+
in the CLI (Claude and Codex) and the plugin (live gate test: a 4th wait-for-a-file check was
|
|
272
|
+
stopped as a loop). An endless `sleep 1; retry` loop is then only stopped by the quota.
|
|
262
273
|
- Loop breaker (works with or without `/agentcap:quota`): `PreToolUse` hashes each tool call
|
|
263
274
|
(name + input, per session and per subagent; polling tools like `TaskOutput`/`BashOutput`
|
|
264
275
|
are ignored). The 4th identical call in a row is denied with `continue: false` on **Pro**;
|
|
@@ -266,13 +277,20 @@ No pip install: the plugin is stdlib Python (`python3` on PATH). How it works:
|
|
|
266
277
|
tool calls: 8 in a row stops the agent on Pro (`continue: false`), Free gets a notice.
|
|
267
278
|
Tool input and output are never stored, only a 16-char hash and counts; these per-session
|
|
268
279
|
files are deleted after 7 days (on `SessionStart`).
|
|
280
|
+
- `/usage` as well: `/agentcap:quota` takes its baseline from Claude Code's own
|
|
281
|
+
`claude -p /usage` (a local command, no model call, no quota), and while a quota is set the
|
|
282
|
+
`PreToolUse` hook starts a background `/usage` read at most once a minute. The share is the
|
|
283
|
+
higher of the statusline and `/usage` (the statusline lagged `/usage` by 1-2 points in live
|
|
284
|
+
tests, and a stale first value once looked like 1% of use). Without `/usage` the baseline is
|
|
285
|
+
only this session's own statusline reading, never another session's.
|
|
269
286
|
- Read-only: no OAuth token, credentials file or API traffic is touched.
|
|
270
287
|
|
|
271
|
-
Honest limits: the % is account-level (parallel sessions count), the stop can
|
|
272
|
-
late, and the share updates when the
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
288
|
+
Honest limits: the % is account-level (parallel sessions and other devices count), the stop can
|
|
289
|
+
be one request late (a `/usage` check runs at most once a minute), and the share updates when the
|
|
290
|
+
statusLine refreshes. Verified live on a real Claude Pro account with Claude Code 2.1.323
|
|
291
|
+
(13 Nov 2026): `/agentcap:setup`, `/agentcap:quota 2% 5h` with its baseline from `/usage`,
|
|
292
|
+
the stop at the limit, `/agentcap:approve`, `/agentcap:unsetup`, and the self-guard denying
|
|
293
|
+
`env -u CLAUDECODE agentcap approve` from the model.
|
|
276
294
|
|
|
277
295
|
## Works with Claude Max / ChatGPT subscriptions (quota mode)
|
|
278
296
|
|
|
@@ -282,7 +300,7 @@ Quota mode caps **one job's share** of it:
|
|
|
282
300
|
```bash
|
|
283
301
|
agentcap run --quota 5% -- claude # stop this job after 5% of the weekly quota
|
|
284
302
|
agentcap run --quota 10% --window 5h -- codex # or 10% of the 5-hour window
|
|
285
|
-
agentcap quota # read-only:
|
|
303
|
+
agentcap quota # read-only: current usage, asked from claude/codex (Free)
|
|
286
304
|
```
|
|
287
305
|
|
|
288
306
|
- **Read-only, ToS-safe.** AgentCap never proxies, reads or reuses your subscription login
|
|
@@ -295,24 +313,70 @@ agentcap quota # read-only: last seen usage (Fre
|
|
|
295
313
|
plus a `PreToolUse` hook that denies further tool calls with a clear reason once the job's
|
|
296
314
|
share reaches the limit and ends the turn (`continue: false`). An interactive session stays open
|
|
297
315
|
(run `agentcap approve` to continue, or quit); a session where the hook never fired gets
|
|
298
|
-
SIGINT. Exit code 3.
|
|
299
|
-
|
|
316
|
+
SIGINT. Exit code 3.
|
|
317
|
+
AgentCap also asks `claude -p /usage` (a local command: no model call, no quota) at start,
|
|
318
|
+
every minute and once after exit. The statusline % and `/usage` differ by one point at both
|
|
319
|
+
ends of a job (live: 26/27 at start, 31/32 at the end), so the statusline is only compared
|
|
320
|
+
with itself, the hook also denies when `/usage` shows the limit first, and the receipt is the
|
|
321
|
+
`/usage` difference (`measured_by: usage`). `/usage` itself shows a job's usage 30-90 s after
|
|
322
|
+
its requests (live gate test: short jobs read 0.0% at exit and the % appeared a minute later),
|
|
323
|
+
so a quota stop can come that much later, and after a Claude job a detached process keeps
|
|
324
|
+
reading `/usage` for up to 90 s and rewrites the receipt with the settled share
|
|
325
|
+
(`settled: true`, `share_pct_at_exit` keeps the first value). It stops early when the value
|
|
326
|
+
holds or when another AgentCap quota job starts (`settle_cut`); other Claude use on the account
|
|
327
|
+
in those 90 s (another chat, another device) still counts toward the receipt.
|
|
328
|
+
The hook can stop Claude only before a tool call, so one large response overshoots: live, a
|
|
329
|
+
3% limit ended at 5% after one response with 7 parallel file reads used 3%. Usage on the same
|
|
330
|
+
account from anywhere else (claude.ai, the desktop or phone app, another terminal) counts
|
|
331
|
+
toward the job too. **Headless `claude -p`** has no statusline, so there `/usage` is the only
|
|
332
|
+
source: it is checked every 30 s and the hook ends the run at the limit (SIGINT if it keeps
|
|
333
|
+
going). Usage between two checks can overshoot. If `/usage` does not answer at start,
|
|
334
|
+
`--quota` warns and only the loop/error breakers are active.
|
|
300
335
|
- **Codex CLI:** AgentCap tails the `token_count` events Codex writes to
|
|
301
336
|
`~/.codex/sessions/**/rollout-*.jsonl` (`rate_limits.primary/secondary.used_percent`,
|
|
302
337
|
`window_minutes`, `resets_at`) and sends SIGINT at the limit. Exit code 3.
|
|
338
|
+
The % in a rollout is the value Codex got *with* a response, before that response was
|
|
339
|
+
charged, so it lags one response (live: the rollout said 3% after a job, the server 4%).
|
|
340
|
+
AgentCap therefore also asks Codex's own `codex app-server` (`account/rateLimits/read`, the
|
|
341
|
+
protocol the IDE extension uses; no model call, no quota spent, Codex handles its own login):
|
|
342
|
+
for the baseline at start, every 30 s during the job, and once after the agent exits, so the
|
|
343
|
+
last response is in the receipt (`baseline_live`, `final_live`). If the server does not answer,
|
|
344
|
+
the rollout readings are used as before.
|
|
345
|
+
Codex writes usage only when a model response ends, so one long response (xhigh/max effort
|
|
346
|
+
ran 6+ minutes in our tests) is invisible until it finishes. In quota mode AgentCap therefore
|
|
347
|
+
stops the job when a single response runs longer than `--response-timeout` (default `5m`,
|
|
348
|
+
`off` disables; time spent running tools does not count) and notes xhigh/max effort at start.
|
|
349
|
+
The interrupted response's usage is read before the receipt is written. Exit code 4,
|
|
350
|
+
reason `response_timeout`.
|
|
351
|
+
**Fail-closed (Pro):** if Codex's `token_count` events carry no `rate_limits` (API-key login, a
|
|
352
|
+
changed log format) or `codex exec` writes no session log within 90 s, the job is stopped
|
|
353
|
+
(exit 5); Free only warns. The interactive TUI is never stopped just for being idle.
|
|
303
354
|
- Baseline at job start (exact when a reading from the last 15 minutes exists, otherwise the
|
|
304
355
|
first response is not counted), window resets mid-job are handled, 80% warning,
|
|
305
|
-
per-job receipt: `
|
|
306
|
-
and receipt files work the same as for dollar caps.
|
|
356
|
+
per-job receipt: `the account's weekly quota rose 4.2% while this job ran`. Pro alerts
|
|
357
|
+
(Telegram/webhook) and receipt files work the same as for dollar caps. `agentcap` stopped by
|
|
358
|
+
Ctrl+C, SIGTERM (`timeout`) or SIGHUP (closed terminal) stops the agent and still writes the
|
|
359
|
+
receipt (reason `interrupted` / `terminated`).
|
|
360
|
+
- **`agentcap quota`** asks each agent's own client for the current values: `codex app-server`
|
|
361
|
+
for Codex and `claude -p /usage` for Claude Code (both read-only, no model call). Lines from a
|
|
362
|
+
live answer end in `(live from codex)` / `(live from claude)`; otherwise the last local
|
|
363
|
+
reading is shown with its age. `agentcap quota --local` never starts claude/codex.
|
|
364
|
+
`AGENTCAP_LIVE_QUOTA=0` turns live reads off everywhere.
|
|
307
365
|
- **Free:** `agentcap quota` and observe-only runs that print the job's share and
|
|
308
366
|
`Pro's quota mode would have stopped this job at 5%`. **Pro:** stopping at the limit.
|
|
309
367
|
|
|
310
368
|
**Honest limits.** The percentage is **account-level**: a parallel session or claude.ai/chatgpt.com
|
|
311
369
|
use in the same window counts against the job (AgentCap warns when it sees another session).
|
|
312
370
|
Values arrive once per model response, so a job **can overshoot by up to one request**.
|
|
313
|
-
Claude Code only reports `rate_limits` for Pro/Max logins and only in
|
|
314
|
-
(the statusline does not run in `claude -p`). Codex's rollout format is undocumented and may change. Codex reports `used_percent` in whole percent, so a Codex cap under 1% cannot trigger until the job has used a full 1% (AgentCap warns at start). Use `--quota 1%` or more for Codex.
|
|
371
|
+
Claude Code only reports `rate_limits` to the statusline for Pro/Max logins and only in
|
|
372
|
+
interactive sessions (the statusline does not run in `claude -p`; there AgentCap reads `/usage`). Codex's rollout format is undocumented and may change. Codex reports `used_percent` in whole percent, so a Codex cap under 1% cannot trigger until the job has used a full 1% (AgentCap warns at start). Use `--quota 1%` or more for Codex.
|
|
315
373
|
Claude Code reports whole percents too: a cap under 1% trips at the next 1% step (AgentCap warns).
|
|
374
|
+
One response can move the account by a full step, so a 2.25% limit can end at 3%.
|
|
375
|
+
The interactive Codex TUI ignores SIGINT mid-turn, so AgentCap escalates to SIGTERM; the
|
|
376
|
+
interrupted response's usage may then be missing from the receipt (`final_read: incomplete`),
|
|
377
|
+
while the account increase it reports stays correct. AgentCap restores the terminal afterwards.
|
|
378
|
+
Codex's own sandbox (bubblewrap) fails inside some agent shells on Ubuntu
|
|
379
|
+
(`kernel.apparmor_restrict_unprivileged_userns=1`); in a normal terminal it works.
|
|
316
380
|
Verified on real accounts: see the harness support matrix under "Supported & tested".
|
|
317
381
|
|
|
318
382
|
## opencode and agy (Antigravity CLI)
|
|
@@ -390,10 +454,10 @@ Legend: ✅ verified on a real account/endpoint · ⚠️ works with a limitatio
|
|
|
390
454
|
|
|
391
455
|
| Harness + auth | Loop breaker (4x same call, exit 4) | Error breaker (8 failures, exit 4) | Quota % stop (exit 3) | $ / token cap |
|
|
392
456
|
| --- | --- | --- | --- | --- |
|
|
393
|
-
| Claude Code, Pro/Max sub, interactive | ✅ (deny keeps the session; resumes after approve) | ✅ | ✅
|
|
394
|
-
| Claude Code, Pro/Max sub, headless `claude -p` | ✅ (exit 4) | ✅ (exit 4) |
|
|
395
|
-
| Codex, ChatGPT sub | ✅ | ✅ | ✅ (whole %; warns under 1%) | ❌ by design (no proxy on a subscription) |
|
|
396
|
-
| opencode Go | ✅ | ✅ | ❌ opencode
|
|
457
|
+
| Claude Code, Pro/Max sub, interactive | ✅ (deny keeps the session; resumes after approve) | ✅ | ✅ statusline + `/usage` every minute (deny keeps the session); `agentcap approve` ✅. Live, Claude Code 2.1.322/323, Pro, 12-13 Nov 2026 | ❌ by design (no proxy on a subscription login; AgentCap refuses) |
|
|
458
|
+
| Claude Code, Pro/Max sub, headless `claude -p` | ✅ (exit 4) | ✅ (exit 4) | ✅ via `/usage` every 30 s (coarser; live: a 2% cap ended at 4%) | ❌ by design (refused) |
|
|
459
|
+
| Codex, ChatGPT sub | ✅ | ✅ | ✅ `exec` and interactive TUI (whole %; warns under 1%; one-response timeout, default 5m; terminal restored after a TUI stop; approve mid-run; live % from `codex app-server` at start, every 30 s and after exit). Live, Codex 0.167.1, Plus, 11-12 Nov 2026 | ❌ by design (no proxy on a subscription) |
|
|
460
|
+
| opencode Go | ✅ | ✅ | ❌ not yet: opencode 1.x's session log reports Go cost as 0 and leaves out subagents (live test, 11 Nov 2026), so a Go % cap cannot be measured; do not rely on `--quota` with opencode | ✅ `--tokens`; `--log-cap` uses opencode's own price table |
|
|
397
461
|
| agy, Google sub (plain `agentcap run -- agy` needs no key: breakers only) | ✅ | ✅ | ✅ (tested at 0.5%; ~10 s polling, can overshoot) | ❌ (sub); $ only via Gemini API |
|
|
398
462
|
| opencode + OpenRouter (free model) | ✅ | ✅ | n/a | ✅ $ cap |
|
|
399
463
|
| opencode + Ollama Cloud | ✅ | ✅ | n/a | ⚠️ needs a user price (`AGENTCAP_PRICING_FILE`): Ollama publishes none |
|
|
@@ -411,7 +475,7 @@ period AgentCap sends SIGINT and the session ends; Codex's sandbox can't run com
|
|
|
411
475
|
`kernel.apparmor_restrict_unprivileged_userns=1` blocks bubblewrap's user namespace
|
|
412
476
|
(host setting, not AgentCap; Codex falls back or needs an AppArmor profile for bwrap).
|
|
413
477
|
|
|
414
|
-
**Platforms:** Linux
|
|
478
|
+
**Platforms:** Linux (tested live). macOS: the code path exists but has not been tested on a real Mac yet; the Linux-only parts (parent-death signal, subreaper) do not apply there. Windows: not yet (use WSL2).
|
|
415
479
|
|
|
416
480
|
## How it works
|
|
417
481
|
|
|
@@ -479,7 +543,7 @@ output limit, so a clamp also caps them.
|
|
|
479
543
|
| --- | --- |
|
|
480
544
|
| `2` | Setup or auth refusal: bad flags, a Pro-only flag on Free, a conflicting CLI config, a second quota job, the provider rejected the credentials (`upstream_auth_failed`), or it refused the request for another reason (`upstream_refused`). |
|
|
481
545
|
| `3` | A cap stopped the agent (`--cap`, `--quota`, `--tokens`, `--log-cap`). |
|
|
482
|
-
| `4` | Pro's loop/error/burn breaker stopped the agent
|
|
546
|
+
| `4` | Pro's loop/error/burn breaker stopped the agent, or (Codex quota mode) one model response ran past `--response-timeout`. |
|
|
483
547
|
| `5` | Internal error: AgentCap could not use its own state (HOME, `quota.lock`, ledger, license or job files), its proxy could not start, an opencode/agy log schema or Codex rollout log could not be read (fail-closed), or AgentCap hit an internal fault. The message names the failed action and path (`internal state error: could not open the quota lock ...`); the agent was not started, or was stopped (reason `internal_error`). |
|
|
484
548
|
| `127` | The command itself could not be started (not found, not executable): `could not start the command (...)`. |
|
|
485
549
|
|
|
@@ -515,7 +579,7 @@ Request bodies are billed at price-book rates; embeddings are input-only.
|
|
|
515
579
|
- The ledger lives at `~/.local/state/agentcap/ledger.sqlite3`
|
|
516
580
|
(override with `$AGENTCAP_DB`).
|
|
517
581
|
|
|
518
|
-
### Stopping, fail-closed and self-approval (0.3
|
|
582
|
+
### Stopping, fail-closed and self-approval (0.3+, Linux-verified)
|
|
519
583
|
|
|
520
584
|
- **Whole process tree.** A quota/harness stop (`--quota`, `--tokens`, `--log-cap`) sends SIGINT
|
|
521
585
|
to the agent's process group, then SIGTERM, then SIGKILL (5 s / 3 s / 2 s); a proxy (`--cap`)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# AgentCap landing — v2
|
|
2
|
+
|
|
3
|
+
Live since 8 November 2026 at https://agentcap.launchbench.studio/.
|
|
4
|
+
The previous design in `landing/index.html` is kept untouched.
|
|
5
|
+
|
|
6
|
+
## Preview
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
cd landing
|
|
10
|
+
python3 -m http.server 8787
|
|
11
|
+
# open http://127.0.0.1:8787/v2/
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## What is here
|
|
15
|
+
|
|
16
|
+
- `index.html` — the page. No build step, no framework, no trackers.
|
|
17
|
+
- `style.css` — the whole design.
|
|
18
|
+
- `script.js` — the copy-to-clipboard button only.
|
|
19
|
+
- `fonts.css` / `fonts/` — self-hosted Instrument Serif and IBM Plex.
|
|
20
|
+
- `agentcap-0.2.0.vsix` — served from the site root, not from this folder.
|
|
21
|
+
|
|
22
|
+
## Deploy target (verified 8 November 2026)
|
|
23
|
+
|
|
24
|
+
Caddy serves the `agentcap.launchbench.studio` block from `/data/agentcap-site`
|
|
25
|
+
inside the `qpa-caddy-1` container. On the host that volume is:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
/var/lib/docker/volumes/qpa_caddy_data/_data/agentcap-site
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The canonical copy is `/srv/agentcap`. Deploy to both:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# from the repo root
|
|
35
|
+
rsync -av --exclude README.md --exclude '*.vsix*' --exclude '*.gif' \
|
|
36
|
+
landing/v2/ quilt-vps:/srv/agentcap/
|
|
37
|
+
|
|
38
|
+
ssh quilt-vps \
|
|
39
|
+
'sudo rsync -a /srv/agentcap/ /var/lib/docker/volumes/qpa_caddy_data/_data/agentcap-site/'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Do not use `--delete`: the root also holds `agentcap-0.2.0.vsix`, its
|
|
43
|
+
`.sha256`, and the two demo GIFs.
|
|
44
|
+
|
|
45
|
+
`~/agentcap-staging` is a separate staging copy. It is not the live root; do not
|
|
46
|
+
deploy there expecting the site to change.
|
|
47
|
+
|
|
48
|
+
The Caddyfile is at
|
|
49
|
+
`/home/ubuntu/apps/quilt-pattern-draft-auditor/Caddyfile`. Its CSP for this
|
|
50
|
+
site must include `font-src 'self'` and `script-src 'self'`; without them the
|
|
51
|
+
self-hosted fonts and `script.js` are blocked. Reload with:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
ssh quilt-vps 'sudo docker exec qpa-caddy-1 caddy reload --config /etc/caddy/Caddyfile --adapter caddyfile'
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Backup made before the 8 November deploy:
|
|
58
|
+
`/home/ubuntu/backups/agentcap-live-20261108-0030/`.
|
|
59
|
+
|
|
60
|
+
## Direction
|
|
61
|
+
|
|
62
|
+
Warm paper, ink, one signal red. Editorial serif display, IBM Plex for text and
|
|
63
|
+
evidence. The hero is a real `agentcap demo` receipt, not a stock illustration.
|
|
64
|
+
No gradients, no glass, no icon grid, no fake logos or testimonials.
|
|
65
|
+
|
|
66
|
+
Content was checked against the 0.3.x tree. Product claims, pricing and limits
|
|
67
|
+
are the same as the previous landing page; the OAuth FAQ answer distinguishes
|
|
68
|
+
the dollar proxy from quota mode.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kutay Karahan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "agentcap-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.1"
|
|
8
8
|
description = "Local-first quota and cost guard for coding agents: per-job share of Claude Code/Codex/Gemini subscription quota, loop breaker, evidence receipt."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -301,6 +301,22 @@ class AlertDispatcher:
|
|
|
301
301
|
self._threads: list[threading.Thread] = []
|
|
302
302
|
self._lock = threading.Lock()
|
|
303
303
|
self._seen_once: set[tuple[str, object]] = set()
|
|
304
|
+
self._held: list[str] | None = None
|
|
305
|
+
|
|
306
|
+
# ------------------------------------------------------ terminal hold
|
|
307
|
+
def hold_terminal(self) -> None:
|
|
308
|
+
"""Keep terminal lines while an interactive agent owns the screen: written
|
|
309
|
+
into it they overlap its input box and are erased on redraw (live C3,
|
|
310
|
+
12 Nov 2026). Webhook/Telegram delivery is not held."""
|
|
311
|
+
with self._lock:
|
|
312
|
+
if self._held is None:
|
|
313
|
+
self._held = []
|
|
314
|
+
|
|
315
|
+
def release_terminal(self) -> None:
|
|
316
|
+
with self._lock:
|
|
317
|
+
held, self._held = self._held, None
|
|
318
|
+
for line in held or []:
|
|
319
|
+
self._write(line)
|
|
304
320
|
|
|
305
321
|
# --------------------------------------------------------------- sending
|
|
306
322
|
def __call__(self, event: Mapping[str, Any]) -> None:
|
|
@@ -348,8 +364,16 @@ class AlertDispatcher:
|
|
|
348
364
|
self._deliver(self._post_telegram, payload)
|
|
349
365
|
|
|
350
366
|
def _terminal(self, message: str, *, color: str = RED) -> None:
|
|
367
|
+
line = f"{color}{redact(message)}{RESET}"
|
|
368
|
+
with self._lock:
|
|
369
|
+
if self._held is not None:
|
|
370
|
+
self._held.append(line)
|
|
371
|
+
return
|
|
372
|
+
self._write(line)
|
|
373
|
+
|
|
374
|
+
def _write(self, line: str) -> None:
|
|
351
375
|
try:
|
|
352
|
-
print(
|
|
376
|
+
print(line, file=self.stderr, flush=True)
|
|
353
377
|
except Exception:
|
|
354
378
|
pass
|
|
355
379
|
|