Review-E cost reduction — claude-tmux ToS finding and the legitimate direction
Review-E cost reduction — decision note
Section titled “Review-E cost reduction — decision note”Context
Section titled “Context”Review-E’s metered Anthropic spend runs ~$800/mo (a floor — usage.js prices the
200K long-context tier above the $15/$75 base it rolls up). The active provider is
claude-cli(rig-gitops/apps/review-e/rig-agent-helmrelease.yamlline 203): the rig spawns the Claude Code CLI as a subprocess, not the Anthropic SDK Messages API.
The dominant cost driver is input compounding across the agentic loop: with
--max-turns 150, the full accumulated transcript — system prompt + the ~12.3K-token
BRAIN.md (measured live at 49,142 bytes, re-ingested every run) + diff + all prior tool
results — is re-sent as input on every turn. There is no engineered prompt caching
anywhere in the live path (grep of src/ finds zero cache_control; the only hits read
back CLI-reported cache token counts for reporting). Static prompt footprint (~1.5-2K tokens)
is negligible by comparison.
Decision (a): claude-tmux / subscription billing is PROHIBITED
Section titled “Decision (a): claude-tmux / subscription billing is PROHIBITED”The claude-tmux provider initiative — routing Review-E through an interactive tmux TTY to
draw on a Claude Max subscription instead of metered API credits — is abandoned and must
not be re-attempted.
Two reasons:
- ToS: Billing a Claude Max/subscription seat for unattended, 24/7 automation violates Anthropic’s Terms of Service (subscription OAuth is for interactive Claude Code/Claude.ai use; the metered API is the sanctioned path for automation). Credentials can be revoked.
- It doesn’t even work: Billing follows the credential, not the invocation mode.
tmuxvsclaude -pdoes not change which pool is billed — the premise inclaude-tmux.js(and thedocs/configuration.mdprose claiming “interactive TTY usage draws from the regular subscription interactive limit, not the metered Agent-SDK credit pool”) is technically false.
Status: both activation PRs (rig-agent-runtime#577 Dockerfile tmux install,
rig-gitops#578 review-e pilot HelmRelease flip) were closed-unmerged on 2026-06-16. No agent
is configured with provider: claude-tmux, tmux is not in the rig image, and claude-cli
remains the default and automatic fallback. The merged provider code (rar#574,
commit 1d89ec5) is therefore inert in production.
Cleanup: document-as-deprecated, do not revert. The 1d89ec5 merge is stacked on a
real provider-chain bug fix (c49afa2: fallbackProviders previously produced no fallback)
plus its regression tests, so a naive git revert would conflict or reintroduce that bug. A
single docs(deprecate) PR annotates claude-tmux.js, the agent.js switch arm, and the
docs/configuration.md provider rows. tmux the tool stays approved (it is the run-the-docs
recorder backbone — Stig-Johnny/claude-3#774); only the subscription-billing use was prohibited.
Decision (b): the legitimate cost-reduction direction
Section titled “Decision (b): the legitimate cost-reduction direction”We pursue the levers that actually fit a CLI-subprocess agentic reviewer, in priority order. Several widely-cited API techniques were evaluated and rejected as inapplicable to this agent (see below).
Adopt (sanctioned, behavior-safe, architecturally native):
- Lower
--max-turnsfrom 150 (directly attacks the dominant input-compounding axis). Instrument the turn-count distribution first — set the cap above the p95 of legitimate reviews so deep reviews aren’t truncated. Est. 10-25%, pending real data. - Shrink BRAIN.md (49,142 B ≈ 12.3K tokens, re-paid every run and re-sent every turn). Trim to the review-relevant subset. Est. 5-15%, behavior-neutral if done carefully.
- PR-skip / no-LLM gating — gate docs-only, dependabot, generated, and trivial PRs before any CLI spawn, fail-open, using the same pattern as the existing size/CoI gates. Est. 3-10% (not the 20-40% sometimes quoted — skipped PRs are the cheap, low-turn runs). Hard never-skip list for sensitive paths; lockfile-only bumps route to a real supply-chain/advisory scan, never a blind skip.
- Route small/low-risk PRs to the non-metered
codex-cli/gpt-5.5 pod (already running on ChatGPT quota; both pods consumeassignments:review-e, onlyclaude-clibills Anthropic). Shifts spend off the metered pool. Quality parity to be verified before broad routing.
Realistic combined estimate: ~15-30% off metered Review-E spend from levers 1-3 (do not sum — they overlap on the same per-turn input volume); honest midpoint ~20%. Routing (lever 4) adds further reduction of the metered bill by moving volume off Anthropic. Actual numbers require the turn-count and per-review token instrumentation noted below.
Rejected for this agent (do not implement as cost plays):
- Prompt caching as a quick win — NOT applicable to the live path.
cache_controlis an SDK/Messages-API field; the CLI subprocess has no surface to set it, and the CLI already caches its stable prefix internally. Becomes a real (input-only, ~25-45% off prefix) lever only after a separate SDK migration — not planned as a cost play. - Model cascade / Haiku first-pass — ~0-10%, plausibly negative. Model is fixed per pod; a weaker model takes more turns and re-pays BRAIN.md per escalation, and Haiku’s weak spot (subtle multi-file/concurrency/security/migration defects) is exactly Review-E’s job.
- Batch API — ~0%. The live path isn’t the Messages API, and a 1-150-turn agentic loop can’t be expressed as independent up-front requests.
- Context trimming (diff-only) — ~0% drop-in. The rig front-loads no files; diff and file bodies are pulled by the CLI’s own tool calls. Aggressive trimming would blind the structural-correctness gate.
- Output-token cap — ~2-6%. No
--max-tokenson the CLI path, and output is the minority of spend.
Uncertainty / what we still need to measure
Section titled “Uncertainty / what we still need to measure”All savings percentages above are estimates and depend on data the rig does not yet expose:
- Turn-count distribution per review (p50/p95/max) — required to size
--max-turnssafely and to confirm the lever-1 estimate. This is the single highest-value measurement. - Per-review token breakdown (input vs output, BRAIN.md share, tool-pulled context share) — confirms the BRAIN.md-shrink and max-turns estimates and the input-dominance assumption.
- PR mix (share of docs-only/dependabot/trivial vs feature reviews, and their token cost) — confirms the skip-gate dollar impact (count of skippable PRs ≠ dollars saved).
- Codex/gpt-5.5 review quality parity on the small-PR slice — required before routing volume off the metered pool.
Until that telemetry exists, ship levers 1-3 conservatively (instrument-then-tune) and treat the ~20% combined figure as a planning estimate, not a commitment.