# Cost & two-tier models

# Cost & two-tier models

Cost per PR is inline's primary design constraint. A team opens a lot of pull requests; a naive "send the whole diff to the best model" review costs around **$0.25** each. inline targets **~$0.03–0.07 per PR** blended, and gets there by stacking five levers in order of impact.

> **The rule of thumb:** filter what you can for free, diff only what changed, cache what repeats, compress what's left, and spend the expensive model only where judgment is actually required.

## The levers, in order

### 1. Path filters (free)

The cheapest token is the one never sent. Before anything else, inline drops files that never deserve a review:

```text
lockfiles · build output (dist, build, out, bin, obj) · dependencies (node_modules, vendor)
generated code · minified JS · migrations · snapshots
images · fonts · PDFs · source maps · data files · fixtures
```

Filtered files cost nothing — no triage, no review. The defaults are combined with per-repo and per-workspace globs you set in [review config](./review-config.html).

### 2. Incremental diffs

inline reviews **only what's new since it last looked**. The last completed review's head becomes the comparison base, so the third push to a PR reviews only the third push — deduped against everything already flagged. A PR with ten pushes doesn't pay to re-read the first nine.

### 3. Prompt caching

inline uses prompt caching aggressively, with three cache breakpoints:

- The **system prompt** (role + guideline pack) is byte-identical per repo and cached at a long TTL, so it survives the gaps between a repo's PRs.
- The **first user message** (diff + manifest) is cached.
- The **last message rolls forward** each agent step, so accumulating tool-result history stays cached across the loop.

Cached reads cost a small fraction of fresh input. Keeping per-PR content *out* of the system prompt is a deliberate discipline — anything that changes per review would bust the cache.

### 4. Diff compression

What survives the filters is ranked by change volume, enormous files are de-prioritized, and the diff sent to the model is clipped. Omitted files are noted so the review agent can pull exactly what it needs with its file-reading tools instead of paying for everything up front.

### 5. Two model tiers

The biggest structural saving is never running the expensive model when it isn't warranted:

| Stage | Model tier | Role |
| --- | --- | --- |
| Triage | Fast model | Classify trivial vs substantive |
| Explorers | Fast model | Breadth-first mapping subagents |
| Deep review | Frontier model | Judgment, multi-hop reasoning |
| Memory / feedback | Fast model | Distill knowledge, draft rules |

A fast model triages **every** PR cheaply; the frontier model only runs on the ~40–60% classified substantive. Within a deep review, the token-heavy breadth work is delegated to fast **explorer subagents** at a fraction of the frontier model's input price, leaving the deep model to do the reasoning. inline is powered by Claude across every tier.

## Cost accounting

inline accounts for every review's cost from live token usage, tracking input, output, and cached-read and cached-write tokens separately so cached tokens are never double-billed. Each review stores a per-model breakdown (triage, review, explore) you can inspect in the portal.

## Monthly budgets

Every workspace has a monthly budget. inline fires a one-time alert at 80% of the cap. Past the cap, with **budget-degrade** enabled, reviews stop at the cheap triage stage and are marked incomplete — which excludes them from the incremental base, so a PR that got a degraded review this month gets a full one next month rather than being silently skipped. Configure the cap and degrade behavior in [review config](./review-config.html).

## What you can tune

In the portal you can adjust, per repo or per workspace:

- **Path filters** — additional globs to exclude.
- **Reasoning effort** — how hard the deep model thinks (low through max).
- **Severity threshold** and **confidence floor** — see [noise control](./review-noise.html).
- **Monthly budget** and **budget-degrade** behavior.

See [review config](./review-config.html) for the full list.
