agentcap-cli 0.2.2__tar.gz → 0.4.0__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.2.2 → agentcap_cli-0.4.0}/PKG-INFO +225 -26
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/README.md +223 -24
- agentcap_cli-0.4.0/landing/v2/README.md +68 -0
- agentcap_cli-0.4.0/plugin/LICENSE +21 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/pyproject.toml +5 -2
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/__init__.py +1 -1
- agentcap_cli-0.4.0/src/agentcap/_lifeline_exec.py +99 -0
- agentcap_cli-0.4.0/src/agentcap/_lifeline_watch.py +46 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/adapters.py +100 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/alerts.py +82 -2
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/budget.py +3 -1
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/cli.py +171 -21
- agentcap_cli-0.4.0/src/agentcap/failsafe.py +161 -0
- agentcap_cli-0.4.0/src/agentcap/harness.py +626 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/history.py +2 -1
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/ledger.py +3 -1
- agentcap_cli-0.4.0/src/agentcap/lifeline.py +209 -0
- agentcap_cli-0.4.0/src/agentcap/live_quota.py +251 -0
- agentcap_cli-0.4.0/src/agentcap/logschema.py +109 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/loop.py +189 -6
- agentcap_cli-0.4.0/src/agentcap/private.py +159 -0
- agentcap_cli-0.4.0/src/agentcap/procstop.py +640 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/proxy.py +245 -13
- agentcap_cli-0.4.0/src/agentcap/quota.py +2034 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/runner.py +176 -12
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/waste.py +6 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/conftest.py +6 -0
- agentcap_cli-0.4.0/tests/fixtures/harness_logs/agy-1.4.11-2026-10-30.jsonl +8 -0
- agentcap_cli-0.4.0/tests/fixtures/harness_logs/claude-2.1.316-pretooluse.json +1 -0
- agentcap_cli-0.4.0/tests/fixtures/harness_logs/claude-2.1.316-statusline.json +1 -0
- agentcap_cli-0.4.0/tests/fixtures/harness_logs/codex-rollout-2026-10-29.jsonl +3 -0
- agentcap_cli-0.4.0/tests/fixtures/harness_logs/opencode-2026-10-30.jsonl +5 -0
- agentcap_cli-0.4.0/tests/fixtures/upstream/README.md +4 -0
- agentcap_cli-0.4.0/tests/fixtures/upstream/anthropic_403_permission_error.json +1 -0
- agentcap_cli-0.4.0/tests/fixtures/upstream/openai_403_region_blocked.json +1 -0
- agentcap_cli-0.4.0/tests/fixtures/upstream/openrouter_401_user_not_found.json +1 -0
- agentcap_cli-0.4.0/tests/fixtures/upstream/openrouter_403_moderation.json +1 -0
- agentcap_cli-0.4.0/tests/fixtures/upstream/openrouter_429_rate_limited.json +1 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_budget.py +1 -0
- agentcap_cli-0.4.0/tests/test_cc_plugin.py +564 -0
- agentcap_cli-0.4.0/tests/test_child_status.py +232 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_claude_adapter_and_tiers.py +16 -0
- agentcap_cli-0.4.0/tests/test_concurrent_forgive.py +169 -0
- agentcap_cli-0.4.0/tests/test_exit_codes.py +326 -0
- agentcap_cli-0.4.0/tests/test_failsafe.py +150 -0
- agentcap_cli-0.4.0/tests/test_harness.py +575 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_history.py +1 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_ledger.py +10 -1
- agentcap_cli-0.4.0/tests/test_lifeline.py +280 -0
- agentcap_cli-0.4.0/tests/test_live_quota.py +531 -0
- agentcap_cli-0.4.0/tests/test_log_contract.py +192 -0
- agentcap_cli-0.4.0/tests/test_log_contract_live.py +54 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_loop.py +72 -0
- agentcap_cli-0.4.0/tests/test_plugin_package.py +112 -0
- agentcap_cli-0.4.0/tests/test_private_dirs.py +226 -0
- agentcap_cli-0.4.0/tests/test_procstop.py +926 -0
- agentcap_cli-0.4.0/tests/test_proxy_auth.py +554 -0
- agentcap_cli-0.4.0/tests/test_quota.py +1221 -0
- agentcap_cli-0.4.0/tests/test_release.py +40 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_runner.py +96 -0
- agentcap_cli-0.4.0/tests/test_self_approve.py +129 -0
- agentcap_cli-0.4.0/tests/test_stop_matrix.py +292 -0
- agentcap_cli-0.4.0/tests/test_upstream_refusals.py +246 -0
- agentcap_cli-0.4.0/tests/test_zombie_collector.py +191 -0
- agentcap_cli-0.2.2/src/agentcap/quota.py +0 -1055
- agentcap_cli-0.2.2/tests/test_cc_plugin.py +0 -298
- agentcap_cli-0.2.2/tests/test_quota.py +0 -627
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/.gitignore +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/LICENSE +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/analytics.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/clamp.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/cli_history.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/data/pricing.json +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/demo.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/devtools/__init__.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/devtools/fake_upstream.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/estimate.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/eta.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/license.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/plans.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/pricing.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/report.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/upstreams.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/src/agentcap/usage.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/fixtures/agents/claude/projects/-home-dev-shop/sess-p/subagents/agent-a1b2c3.jsonl +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/fixtures/agents/claude/projects/-home-dev-shop/sess-p/subagents/agent-d4e5f6.jsonl +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/fixtures/agents/claude/projects/-home-dev-shop/sess-p.jsonl +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/fixtures/agents/codex/sessions/2026/10/29/rollout-2026-10-29T09-00-00-thr-parent.jsonl +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/fixtures/agents/codex/sessions/2026/10/29/rollout-2026-10-29T09-00-50-thr-child.jsonl +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/fixtures/agents/codex/sessions/2026/10/29/rollout-2026-10-29T09-01-20-thr-fork.jsonl +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/fixtures/history/claude/.credentials.json +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/fixtures/history/claude/projects/-home-dev-shop/1f0c-sess-a.jsonl +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/fixtures/history/codex/auth.json +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/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.2.2 → agentcap_cli-0.4.0}/tests/license_support.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/proxy_support.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_adapters.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_agents.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_alerts.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_analytics.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_anthropic_proxy.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_anthropic_units.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_clamp.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_cli.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_e2e_claude.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_estimate.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_license.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_pricing.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_proxy_cancel.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_proxy_core.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_proxy_extras.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_proxy_streaming.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_report_cli.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_runaway.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_upstreams.py +0 -0
- {agentcap_cli-0.2.2 → agentcap_cli-0.4.0}/tests/test_usage.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: agentcap-cli
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.4.0
|
|
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
|
|
7
7
|
Project-URL: Issues, https://github.com/Blitz00X/agentcap/issues
|
|
@@ -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
|
|
@@ -296,13 +303,20 @@ No pip install: the plugin is stdlib Python (`python3` on PATH). How it works:
|
|
|
296
303
|
tool calls: 8 in a row stops the agent on Pro (`continue: false`), Free gets a notice.
|
|
297
304
|
Tool input and output are never stored, only a 16-char hash and counts; these per-session
|
|
298
305
|
files are deleted after 7 days (on `SessionStart`).
|
|
306
|
+
- `/usage` as well: `/agentcap:quota` takes its baseline from Claude Code's own
|
|
307
|
+
`claude -p /usage` (a local command, no model call, no quota), and while a quota is set the
|
|
308
|
+
`PreToolUse` hook starts a background `/usage` read at most once a minute. The share is the
|
|
309
|
+
higher of the statusline and `/usage` (the statusline lagged `/usage` by 1-2 points in live
|
|
310
|
+
tests, and a stale first value once looked like 1% of use). Without `/usage` the baseline is
|
|
311
|
+
only this session's own statusline reading, never another session's.
|
|
299
312
|
- Read-only: no OAuth token, credentials file or API traffic is touched.
|
|
300
313
|
|
|
301
|
-
Honest limits: the % is account-level (parallel sessions count), the stop can
|
|
302
|
-
late, and the share updates when the
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
314
|
+
Honest limits: the % is account-level (parallel sessions and other devices count), the stop can
|
|
315
|
+
be one request late (a `/usage` check runs at most once a minute), and the share updates when the
|
|
316
|
+
statusLine refreshes. Verified live on a real Claude Pro account with Claude Code 2.1.323
|
|
317
|
+
(13 Nov 2026): `/agentcap:setup`, `/agentcap:quota 2% 5h` with its baseline from `/usage`,
|
|
318
|
+
the stop at the limit, `/agentcap:approve`, `/agentcap:unsetup`, and the self-guard denying
|
|
319
|
+
`env -u CLAUDECODE agentcap approve` from the model.
|
|
306
320
|
|
|
307
321
|
## Works with Claude Max / ChatGPT subscriptions (quota mode)
|
|
308
322
|
|
|
@@ -312,7 +326,7 @@ Quota mode caps **one job's share** of it:
|
|
|
312
326
|
```bash
|
|
313
327
|
agentcap run --quota 5% -- claude # stop this job after 5% of the weekly quota
|
|
314
328
|
agentcap run --quota 10% --window 5h -- codex # or 10% of the 5-hour window
|
|
315
|
-
agentcap quota # read-only:
|
|
329
|
+
agentcap quota # read-only: current usage, asked from claude/codex (Free)
|
|
316
330
|
```
|
|
317
331
|
|
|
318
332
|
- **Read-only, ToS-safe.** AgentCap never proxies, reads or reuses your subscription login
|
|
@@ -324,26 +338,84 @@ agentcap quota # read-only: last seen usage (Fre
|
|
|
324
338
|
`used_percentage`, `resets_at`) and then runs **your own statusline command unchanged**,
|
|
325
339
|
plus a `PreToolUse` hook that denies further tool calls with a clear reason once the job's
|
|
326
340
|
share reaches the limit and ends the turn (`continue: false`). An interactive session stays open
|
|
327
|
-
(run `agentcap approve` to continue, or quit)
|
|
328
|
-
|
|
341
|
+
(run `agentcap approve` to continue, or quit); a session where the hook never fired gets
|
|
342
|
+
SIGINT. Exit code 3.
|
|
343
|
+
AgentCap also asks `claude -p /usage` (a local command: no model call, no quota) at start,
|
|
344
|
+
every minute and once after exit. The statusline % and `/usage` differ by one point at both
|
|
345
|
+
ends of a job (live: 26/27 at start, 31/32 at the end), so the statusline is only compared
|
|
346
|
+
with itself, the hook also denies when `/usage` shows the limit first, and the receipt is the
|
|
347
|
+
`/usage` difference (`measured_by: usage`).
|
|
348
|
+
The hook can stop Claude only before a tool call, so one large response overshoots: live, a
|
|
349
|
+
3% limit ended at 5% after one response with 7 parallel file reads used 3%. Usage on the same
|
|
350
|
+
account from anywhere else (claude.ai, the desktop or phone app, another terminal) counts
|
|
351
|
+
toward the job too. **Headless `claude -p`** has no statusline, so there `/usage` is the only
|
|
352
|
+
source: it is checked every 30 s and the hook ends the run at the limit (SIGINT if it keeps
|
|
353
|
+
going). Usage between two checks can overshoot. If `/usage` does not answer at start,
|
|
354
|
+
`--quota` warns and only the loop/error breakers are active.
|
|
329
355
|
- **Codex CLI:** AgentCap tails the `token_count` events Codex writes to
|
|
330
356
|
`~/.codex/sessions/**/rollout-*.jsonl` (`rate_limits.primary/secondary.used_percent`,
|
|
331
357
|
`window_minutes`, `resets_at`) and sends SIGINT at the limit. Exit code 3.
|
|
358
|
+
The % in a rollout is the value Codex got *with* a response, before that response was
|
|
359
|
+
charged, so it lags one response (live: the rollout said 3% after a job, the server 4%).
|
|
360
|
+
AgentCap therefore also asks Codex's own `codex app-server` (`account/rateLimits/read`, the
|
|
361
|
+
protocol the IDE extension uses; no model call, no quota spent, Codex handles its own login):
|
|
362
|
+
for the baseline at start, every 30 s during the job, and once after the agent exits, so the
|
|
363
|
+
last response is in the receipt (`baseline_live`, `final_live`). If the server does not answer,
|
|
364
|
+
the rollout readings are used as before.
|
|
365
|
+
Codex writes usage only when a model response ends, so one long response (xhigh/max effort
|
|
366
|
+
ran 6+ minutes in our tests) is invisible until it finishes. In quota mode AgentCap therefore
|
|
367
|
+
stops the job when a single response runs longer than `--response-timeout` (default `5m`,
|
|
368
|
+
`off` disables; time spent running tools does not count) and notes xhigh/max effort at start.
|
|
369
|
+
The interrupted response's usage is read before the receipt is written. Exit code 4,
|
|
370
|
+
reason `response_timeout`.
|
|
371
|
+
**Fail-closed (Pro):** if Codex's `token_count` events carry no `rate_limits` (API-key login, a
|
|
372
|
+
changed log format) or `codex exec` writes no session log within 90 s, the job is stopped
|
|
373
|
+
(exit 5); Free only warns. The interactive TUI is never stopped just for being idle.
|
|
332
374
|
- Baseline at job start (exact when a reading from the last 15 minutes exists, otherwise the
|
|
333
375
|
first response is not counted), window resets mid-job are handled, 80% warning,
|
|
334
|
-
per-job receipt: `
|
|
335
|
-
and receipt files work the same as for dollar caps.
|
|
376
|
+
per-job receipt: `the account's weekly quota rose 4.2% while this job ran`. Pro alerts
|
|
377
|
+
(Telegram/webhook) and receipt files work the same as for dollar caps. `agentcap` stopped by
|
|
378
|
+
Ctrl+C, SIGTERM (`timeout`) or SIGHUP (closed terminal) stops the agent and still writes the
|
|
379
|
+
receipt (reason `interrupted` / `terminated`).
|
|
380
|
+
- **`agentcap quota`** asks each agent's own client for the current values: `codex app-server`
|
|
381
|
+
for Codex and `claude -p /usage` for Claude Code (both read-only, no model call). Lines from a
|
|
382
|
+
live answer end in `(live from codex)` / `(live from claude)`; otherwise the last local
|
|
383
|
+
reading is shown with its age. `agentcap quota --local` never starts claude/codex.
|
|
384
|
+
`AGENTCAP_LIVE_QUOTA=0` turns live reads off everywhere.
|
|
336
385
|
- **Free:** `agentcap quota` and observe-only runs that print the job's share and
|
|
337
386
|
`Pro's quota mode would have stopped this job at 5%`. **Pro:** stopping at the limit.
|
|
338
387
|
|
|
339
388
|
**Honest limits.** The percentage is **account-level**: a parallel session or claude.ai/chatgpt.com
|
|
340
389
|
use in the same window counts against the job (AgentCap warns when it sees another session).
|
|
341
390
|
Values arrive once per model response, so a job **can overshoot by up to one request**.
|
|
342
|
-
Claude Code only reports `rate_limits` for Pro/Max logins and only in
|
|
343
|
-
(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.
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
391
|
+
Claude Code only reports `rate_limits` to the statusline for Pro/Max logins and only in
|
|
392
|
+
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.
|
|
393
|
+
Claude Code reports whole percents too: a cap under 1% trips at the next 1% step (AgentCap warns).
|
|
394
|
+
One response can move the account by a full step, so a 2.25% limit can end at 3%.
|
|
395
|
+
The interactive Codex TUI ignores SIGINT mid-turn, so AgentCap escalates to SIGTERM; the
|
|
396
|
+
interrupted response's usage may then be missing from the receipt (`final_read: incomplete`),
|
|
397
|
+
while the account increase it reports stays correct. AgentCap restores the terminal afterwards.
|
|
398
|
+
Codex's own sandbox (bubblewrap) fails inside some agent shells on Ubuntu
|
|
399
|
+
(`kernel.apparmor_restrict_unprivileged_userns=1`); in a normal terminal it works.
|
|
400
|
+
Verified on real accounts: see the harness support matrix under "Supported & tested".
|
|
401
|
+
|
|
402
|
+
## opencode and agy (Antigravity CLI)
|
|
403
|
+
|
|
404
|
+
Headless runs only. AgentCap reads each agent's own event stream; nothing is proxied in these modes.
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
# opencode Go (or any opencode provider): token cap, loop + error breakers
|
|
408
|
+
agentcap run --tokens 200000 -- opencode run -m opencode-go/deepseek-v4.1-flash "fix the test"
|
|
409
|
+
# opencode: cap on opencode's own cost estimate
|
|
410
|
+
agentcap run --log-cap 0.50 -- opencode run -m opencode-go/glm-5.3 "..."
|
|
411
|
+
# agy on a Google subscription: real quota % from `agy -p /quota`
|
|
412
|
+
agentcap run --quota 2% --window 5h -- agy --model gemini-3.8-flash-low -p "..."
|
|
413
|
+
# $ APIs through the proxy (OpenRouter shown)
|
|
414
|
+
AGENTCAP_OPENAI_UPSTREAM=https://openrouter.ai/api OPENAI_API_KEY=$OPENROUTER_API_KEY \
|
|
415
|
+
agentcap run --cap 0.50 -- opencode run -m agentcap/<openrouter model id> "..."
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
opencode does not expose subscription quota %, so `--quota` is refused for it; use `--tokens` or `--log-cap`. `--log-cap` trusts opencode's price table, not AgentCap's.
|
|
347
419
|
|
|
348
420
|
## Try it without an API key
|
|
349
421
|
|
|
@@ -396,6 +468,33 @@ billing. Gemini CLI 0.58 and Codex CLI 0.163 are tested end-to-end against a loc
|
|
|
396
468
|
|
|
397
469
|
Models without a bundled price (for example OpenRouter or Ollama ids) are blocked until you add a price via `AGENTCAP_PRICING_FILE`.
|
|
398
470
|
|
|
471
|
+
### Harness support matrix (real runs)
|
|
472
|
+
|
|
473
|
+
Legend: ✅ verified on a real account/endpoint · ⚠️ works with a limitation · ❌ not supported · **needs X** = untested, X blocks it.
|
|
474
|
+
|
|
475
|
+
| Harness + auth | Loop breaker (4x same call, exit 4) | Error breaker (8 failures, exit 4) | Quota % stop (exit 3) | $ / token cap |
|
|
476
|
+
| --- | --- | --- | --- | --- |
|
|
477
|
+
| 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) |
|
|
478
|
+
| 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) |
|
|
479
|
+
| 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) |
|
|
480
|
+
| 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 |
|
|
481
|
+
| 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 |
|
|
482
|
+
| opencode + OpenRouter (free model) | ✅ | ✅ | n/a | ✅ $ cap |
|
|
483
|
+
| opencode + Ollama Cloud | ✅ | ✅ | n/a | ⚠️ needs a user price (`AGENTCAP_PRICING_FILE`): Ollama publishes none |
|
|
484
|
+
| Codex + Ollama | ✅ (exit 4 on 4th identical exec) | ✅ | n/a | ✅ $ cap (user price) |
|
|
485
|
+
| Codex + OpenRouter | ✅ (exit 4 after 4 identical steps in a row; Codex 0.166, free model, 5 Nov 2026) | ✅ (exit 4 on the 8th failing command) | n/a | ✅ $ cap stop (earlier release run, free model); a rejected key stops with `upstream_auth_failed` (exit 2) |
|
|
486
|
+
| agy + Gemini API | **not provable on a free key**: agy sends >5 req/min and exits on the first 429 (no retry); needs a paid key | same | n/a | ✅ $ cap (exit 3) |
|
|
487
|
+
| Claude Code + `ANTHROPIC_API_KEY` | **needs an Anthropic API key** (proxy path; only a local fake API so far) | **needs an Anthropic API key** | n/a | **needs an Anthropic API key** |
|
|
488
|
+
|
|
489
|
+
Tested with Claude Code 2.1.316 on a real Claude Pro login (Haiku) and an activated AgentCap Pro
|
|
490
|
+
license, through the CLI, 1 Nov 2026. 429/5xx retries (identical resends) are counted neither as loops nor as failing tool calls.
|
|
491
|
+
|
|
492
|
+
Known limits: quota % is account-level (parallel sessions count); Claude/Codex report whole
|
|
493
|
+
percents; interactive Claude turns with no tool calls can't be denied, so after a 30 s grace
|
|
494
|
+
period AgentCap sends SIGINT and the session ends; Codex's sandbox can't run commands on Ubuntu 24.04 by default:
|
|
495
|
+
`kernel.apparmor_restrict_unprivileged_userns=1` blocks bubblewrap's user namespace
|
|
496
|
+
(host setting, not AgentCap; Codex falls back or needs an AppArmor profile for bwrap).
|
|
497
|
+
|
|
399
498
|
**Platforms:** Linux and macOS. Windows: not yet (use WSL2).
|
|
400
499
|
|
|
401
500
|
## How it works
|
|
@@ -430,8 +529,12 @@ Models without a bundled price (for example OpenRouter or Ollama ids) are blocke
|
|
|
430
529
|
running; real usage still settles the reservation. Clamping is on by default
|
|
431
530
|
and can be disabled with `--no-clamp`.
|
|
432
531
|
6. If even a minimal clamped request cannot fit, the request is blocked and the
|
|
433
|
-
whole child process group is terminated (`
|
|
434
|
-
|
|
532
|
+
whole child process group is terminated. In proxy (`--cap`) mode that is
|
|
533
|
+
`SIGTERM`, then `SIGKILL` after 5 s. Quota and harness (`--quota`,
|
|
534
|
+
`--tokens`, `--log-cap`) modes use `SIGINT` → `SIGTERM` → `SIGKILL`
|
|
535
|
+
(5 s / 3 s / 2 s) so a headless agent can end its turn; both paths are
|
|
536
|
+
described under "Stopping, fail-closed and self-approval". `agentcap run`
|
|
537
|
+
exits with code `3`. Pro's loop/burn breaker exits
|
|
435
538
|
with `4` (same step 4 times in a row, 8 failing tool results in a row, or a
|
|
436
539
|
burn rate above `--max-burn` $/min; see Free vs Pro).
|
|
437
540
|
The kill and its red alert fire at most once per run; later rejected
|
|
@@ -451,6 +554,19 @@ raised. Everything else is forwarded byte-for-byte, including credentials.
|
|
|
451
554
|
Reasoning/thinking tokens are billed as output and count against the same
|
|
452
555
|
output limit, so a clamp also caps them.
|
|
453
556
|
|
|
557
|
+
### Exit codes
|
|
558
|
+
|
|
559
|
+
`agentcap run` uses the same codes in `--cap`, `--quota`, `--tokens` and
|
|
560
|
+
`--log-cap` modes (0.3.1). Otherwise it returns the agent's own exit code.
|
|
561
|
+
|
|
562
|
+
| Code | Meaning |
|
|
563
|
+
| --- | --- |
|
|
564
|
+
| `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`). |
|
|
565
|
+
| `3` | A cap stopped the agent (`--cap`, `--quota`, `--tokens`, `--log-cap`). |
|
|
566
|
+
| `4` | Pro's loop/error/burn breaker stopped the agent, or (Codex quota mode) one model response ran past `--response-timeout`. |
|
|
567
|
+
| `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`). |
|
|
568
|
+
| `127` | The command itself could not be started (not found, not executable): `could not start the command (...)`. |
|
|
569
|
+
|
|
454
570
|
## Metered endpoints
|
|
455
571
|
|
|
456
572
|
| Provider | Endpoints |
|
|
@@ -480,9 +596,92 @@ Request bodies are billed at price-book rates; embeddings are input-only.
|
|
|
480
596
|
tokenizer differences), the final spend can exceed the cap by that one
|
|
481
597
|
request's estimation error. AgentCap emits an `overshoot` alert when a
|
|
482
598
|
settlement exceeds its reservation.
|
|
483
|
-
- The ledger lives at `~/.local/
|
|
599
|
+
- The ledger lives at `~/.local/state/agentcap/ledger.sqlite3`
|
|
484
600
|
(override with `$AGENTCAP_DB`).
|
|
485
601
|
|
|
602
|
+
### Stopping, fail-closed and self-approval (0.3+, Linux-verified)
|
|
603
|
+
|
|
604
|
+
- **Whole process tree.** A quota/harness stop (`--quota`, `--tokens`, `--log-cap`) sends SIGINT
|
|
605
|
+
to the agent's process group, then SIGTERM, then SIGKILL (5 s / 3 s / 2 s); a proxy (`--cap`)
|
|
606
|
+
stop sends SIGTERM, then SIGKILL after 5 s. Helpers the agent left behind in its group are also killed after a
|
|
607
|
+
normal exit, so a dev server started by the agent does not outlive the run.
|
|
608
|
+
On Linux AgentCap also enables `PR_SET_CHILD_SUBREAPER` for the run: descendants that call
|
|
609
|
+
`setsid()` or double-fork are adopted, matched against a pre-run snapshot (PID + start time),
|
|
610
|
+
and swept with SIGTERM then SIGKILL after a normal exit or a stop. It prints
|
|
611
|
+
`killed N process(es) that left the agent's process group` when that happens. A descendant it
|
|
612
|
+
may not signal (a root-owned `sudo -b` child, a setuid program) is tried once, not waited on, and
|
|
613
|
+
left running with a `could not stop N process(es) (permission denied): pid ...` warning. Daemons the agent
|
|
614
|
+
starts (a dev server, a `tmux` server, a Gradle daemon) are part of its tree and stop with the run.
|
|
615
|
+
If AgentCap itself is SIGKILLed or OOM-killed, the parent-death lifeline (`PR_SET_PDEATHSIG`)
|
|
616
|
+
kills the direct agent and a small watchdog SIGKILLs the agent's process group, which also covers
|
|
617
|
+
a real agent started by a launcher (Codex's npm wrapper on Node without `process.execve`) and
|
|
618
|
+
the agent's tool processes.
|
|
619
|
+
Limits: on non-Linux only the process group is cleaned and there is no lifeline. A process that
|
|
620
|
+
left the agent's group (`setsid`/daemonized) before AgentCap itself was SIGKILLed can still
|
|
621
|
+
escape: no userspace process can clean up after its own SIGKILL. Use a container/cgroup or a
|
|
622
|
+
separate OS user when the agent is not trusted. Adopted helpers that exit during a run stay
|
|
623
|
+
zombies until it ends (the agent's group is reaped once the agent exits, the rest by the final
|
|
624
|
+
sweep): `/proc` cannot tell an adopted `setsid` helper from a child AgentCap's own process
|
|
625
|
+
started in a new session, and taking that child's exit status would make it report 0. A long
|
|
626
|
+
run whose agent keeps leaving short-lived detached helpers holds one PID per finished helper,
|
|
627
|
+
counted against `ulimit -u`, until the run ends. Opt-in (0.3.1, default off):
|
|
628
|
+
`AGENTCAP_COLLECT_ZOMBIES=1` reaps, about once a second during the run, adopted zombies whose
|
|
629
|
+
session id is neither AgentCap's nor their own pid (an in-group background job, a double-forked
|
|
630
|
+
daemon), after re-checking their PID + start time. The agent, `setsid` helpers (session leaders)
|
|
631
|
+
and AgentCap's own children are never reaped early, so their exit codes are kept; `setsid`
|
|
632
|
+
helpers are still collected by the final sweep. Interrupting a job
|
|
633
|
+
can leave its work half done (a migration, a deploy): that is the job's responsibility, so
|
|
634
|
+
commit before a guarded run.
|
|
635
|
+
- **Fail-closed.** On Pro, quota and harness runs (`--quota`, `--tokens`, `--log-cap`) stop the
|
|
636
|
+
agent with exit code 5 instead of letting it run unguarded when opencode/agy output matches no
|
|
637
|
+
known log schema, the Codex session log becomes unreadable, or AgentCap itself hits an internal
|
|
638
|
+
error; Free only warns about these. In `--cap` mode an internal AgentCap error stops the agent
|
|
639
|
+
too, with exit code 5 and reason `internal_error` (since 0.3.1; see "Exit codes"). Two quota jobs at once are refused on Free and Pro (exit 2),
|
|
640
|
+
since the quota % is account-wide; `AGENTCAP_ALLOW_PARALLEL=1` turns that lock off.
|
|
641
|
+
Not covered yet: a stale Claude statusline (no fresh `rate_limits`) is reported, not stopped.
|
|
642
|
+
- **Rejected credentials (`--cap` proxy mode).** When the provider answers HTTP 401, 402
|
|
643
|
+
(OpenRouter: no credits), 403, or Gemini's 400 `API_KEY_INVALID`, AgentCap prints
|
|
644
|
+
`upstream rejected the request (HTTP 401: User not found.) — check the API key for <host>;
|
|
645
|
+
nothing was spent.` (the provider's short `error.message`, truncated, key-shaped text redacted,
|
|
646
|
+
headers never read). The agent's resends of such a request never count toward the loop breaker.
|
|
647
|
+
After 3 rejections in a row with no other answer between them, the run is stopped on Free and Pro
|
|
648
|
+
with reason `upstream_auth_failed` and exit 2 (like AgentCap's other exit-2 refusals: a setup
|
|
649
|
+
problem to fix, rerunning unchanged cannot help). 429/5xx answers in between neither count nor
|
|
650
|
+
break the streak, so 401/429/401/429/401 still stops. A 403 whose body is not about the key,
|
|
651
|
+
permission or account (a region/country block, a moderation or policy refusal, or no readable
|
|
652
|
+
body) is reported as `provider refused the request` instead, and three in a row stop the run with
|
|
653
|
+
reason `upstream_refused` (exit 2). If the agent gives up first with a non-zero exit code, the
|
|
654
|
+
reason is still `upstream_auth_failed`/`upstream_refused` and its own exit code is kept; if it
|
|
655
|
+
exits 0, the reason stays `child_exit` and the rejection is printed as a separate warning. One
|
|
656
|
+
rejection followed by a success changes nothing. `agentcap serve` only reports it and keeps serving.
|
|
657
|
+
- **Self-approval.** `agentcap approve` refuses (exit 2) when it runs inside an agent session
|
|
658
|
+
(`AGENTCAP_QUOTA_JOB`, `AGENTCAP_GUARDED` or `CLAUDECODE` in its environment), and the hook of
|
|
659
|
+
`agentcap run --quota -- claude` denies a Bash call that runs `agentcap approve`;
|
|
660
|
+
`/agentcap:approve` cannot be invoked by the model (`disable-model-invocation`). Run approve
|
|
661
|
+
from your own terminal. The Claude Code plugin's `PreToolUse` hook denies, on Free and Pro, any
|
|
662
|
+
model tool call that would run its own script (`python3 .../scripts/agentcap_cc.py approve`,
|
|
663
|
+
`quota`, `off`, `setup`, `unsetup`, `statusline`, `hook`; any path, `python -m agentcap_cc`,
|
|
664
|
+
`import agentcap_cc`, an `agentcap*` glob, quoted/escaped/`$IFS` forms, inside `bash -c`/`sh -c`)
|
|
665
|
+
or touch its state dir or installed plugin files: Bash and any other tool with a `command`, and
|
|
666
|
+
Write/Edit/MultiEdit/NotebookEdit on those paths. Plain reads (`cat`, `grep`, `ls`, `jq`, ...;
|
|
667
|
+
`git` without `-c`/config/checkout-style subcommands) still pass. Your own `/agentcap:approve`,
|
|
668
|
+
`/agentcap:quota` and `/agentcap:off` keep working: Claude Code runs a slash command's `!` line
|
|
669
|
+
without `PreToolUse` hooks (measured on 2.1.318, headless). When Claude Code's working
|
|
670
|
+
directory is inside the plugin's own checkout, its code files stay editable (plugin development).
|
|
671
|
+
What still passes: a command that never names the script or state dir (a script the agent
|
|
672
|
+
writes elsewhere that builds the path at run time, `$(printf ...)` path pieces, other globs),
|
|
673
|
+
and tools that execute code without a `command` field.
|
|
674
|
+
**Honest limit:** the agent runs as your OS user, so a determined agent can still clear the
|
|
675
|
+
environment, edit AgentCap's state files or kill AgentCap. AgentCap guards cooperative
|
|
676
|
+
workloads against accidents (loops, runaway spend), not a hostile agent; use a separate OS
|
|
677
|
+
user or container for that.
|
|
678
|
+
- **Log format changes.** AgentCap reads harness logs, and vendors change them. The fields it
|
|
679
|
+
reads are pinned per harness in `agentcap/logschema.py` (opencode, agy, Claude Code statusline
|
|
680
|
+
and PreToolUse, Codex rollout) and checked by `tests/test_log_contract.py` against recorded
|
|
681
|
+
fixtures; `AGENTCAP_LIVE_CONTRACT=1 pytest tests/test_log_contract_live.py` re-checks the
|
|
682
|
+
installed opencode/agy (one small model call). At run time an unknown schema fails closed
|
|
683
|
+
(above). Last live check: opencode 2.2.4 (3 Nov 2026).
|
|
684
|
+
|
|
486
685
|
## Privacy
|
|
487
686
|
|
|
488
687
|
Prompts and keys pass through the local proxy in memory; AgentCap never stores
|
|
@@ -565,7 +764,7 @@ steps are noisy. No team aggregation: everything stays on your machine.
|
|
|
565
764
|
When the Pro detectors below would have fired on a Free run, AgentCap does not stop it.
|
|
566
765
|
It prints one line: `Pro's loop breaker would have stopped this at $X.XX`.
|
|
567
766
|
|
|
568
|
-
**Pro, $12 one-time (launch week
|
|
767
|
+
**Pro, $12 one-time (launch week; $19 after): stop runs that loop or eat your quota.**
|
|
569
768
|
|
|
570
769
|
**Get Pro:** buy at https://agentcap.launchbench.studio/#pricing (Polar checkout). Polar then
|
|
571
770
|
emails you an **Access purchase** link; the key is in the Polar customer portal (not in the
|
|
@@ -594,7 +793,7 @@ The VS Code/Cursor extension and the Claude Code plugin use the same CLI licence
|
|
|
594
793
|
|
|
595
794
|
### Purchase terms
|
|
596
795
|
|
|
597
|
-
- Pro is $12 one-time (launch week
|
|
796
|
+
- Pro is $12 one-time (launch week; $19 after), no subscription. The current launch-week end date is on the pricing page.
|
|
598
797
|
- 14-day no-questions refund — email
|
|
599
798
|
[kutaykarahan6@gmail.com](mailto:kutaykarahan6@gmail.com).
|
|
600
799
|
- One licence key activates on up to 3 machines.
|
|
@@ -663,7 +862,7 @@ prices and reported usage; when usage is missing it charges the full reservation
|
|
|
663
862
|
**Is the day cap shared across machines?** No. Hour/day caps are per machine
|
|
664
863
|
(local SQLite ledger). A license covers 3 machines, each with its own budget.
|
|
665
864
|
|
|
666
|
-
**What does one-time purchase include?** $12 once in launch week ($19 after
|
|
865
|
+
**What does one-time purchase include?** $12 once in launch week ($19 after), all 0.x updates; not a
|
|
667
866
|
promise of future major versions. 14-day refund window per purchase terms.
|
|
668
867
|
|
|
669
868
|
## License
|