# Cost and coverage

> Abstract: Every review is estimated before anything is sent to the model, refused over a limit you set, capped at one model call, and cached. Whatever it could not check is written into the report instead of being left out.

## The estimate comes first

`--estimate` makes zero model calls. It performs the same diff preparation and static checks as a review, and reports what the complete prompt would cost.

The estimate covers the whole prompt: the review rubric, a fixed instruction, the scanner evidence that sits on lines the patch shows, and the line-numbered patch itself. PR-Agent's token estimator counts it.

> Hadolint, zizmor and OSV-Scanner results, and Qualgen's advisories, are never in the prompt. They cost no tokens and do not count.

## A real estimate

The run below is real. `--estimate` was run on a throwaway repository with a two-file change: a shell script that leaves two variables unquoted, and a workflow that passes a pull request title into an inline script. ShellCheck and actionlint found all three problems. No model was called.

**A real `--estimate` on a throwaway repository.**

- Command: `cursor-review --repo /tmp/example --base main --estimate`
- Exit status: 0
- Length: 1,419 estimated tokens against a limit of 6,000
- Findings: 3: one from actionlint, two from ShellCheck, none from a model
- Coverage: Both changed files were checked in full. No path was left out.

```text
{
  "provider": "cursor",
  "source": "/private/tmp/example",
  "head": "1a64c12013445ed5cfcb8679b73c5ab5c2d9f02f",
  "model": "cursor-default",
  "estimated_input_tokens": 1419,
  "max_input_tokens": 6000,
  "cursor_invocations": 0,
  "cache_hit": false,
  "omitted": [],
  "checks": [
    {
      "tool": "actionlint",
      "path": ".github/workflows/ci.yml",
      "state": "complete",
      "findings": [
        {
          "path": ".github/workflows/ci.yml",
          "rule": "expression",
          "line": 11,
          "message": "\"github.event.pull_request.title\" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks for more details"
        }
      ]
    },
    {
      "tool": "shellcheck",
      "path": "deploy.sh",
      "state": "complete",
      "findings": [
        {
          "path": "deploy.sh",
          "rule": "SC2086",
          "line": 4,
          "message": "Double quote to prevent globbing and word splitting."
        },
        {
          "path": "deploy.sh",
          "rule": "SC2086",
          "line": 5,
          "message": "Double quote to prevent globbing and word splitting."
        }
      ]
    }
  ],
  "findings": [],
  "cursor_usage": null,
  "state": "estimate",
  "model_invocations": 0,
  "model_usage": null
}
```

Quoted verbatim. SHA-256 of the text above: `c7edd99fb385d72523937873d11c310316b536f6b7dddf9d1440c9a660ed517c`

Comments:
- Comment 1 (line 6): The whole prompt, counted before anything is sent: 1,419 tokens, against the limit on the next line.
- Comment 2 (line 8): No model was called. `--estimate` prepares everything a review prepares, and stops.
- Comment 3 (line 10): No path was left out. Every changed file had a usable patch.
- Comment 4 (line 19): actionlint's finding: a pull request title passed straight into an inline script.
- Comment 5 (line 32): ShellCheck's: two unquoted variables, on lines 4 and 5.
- Comment 6 (line 45): Model findings. Empty, because no model ran. The scanners' findings sit under `checks`.
- Comment 7 (line 47): The state decides the exit status. `estimate` is 0.


## When the estimate is too large

An estimate above the limit ends the review before the model is invoked. The state is [`over-budget`](output.md#over-budget), the exit status is 2, and the static checks and history advisories are still reported.

The [overview](index.md) quotes one such review from the project's own pull request #15. Thirty-five minutes later the same pull request was reviewed again at a later head:

**The second comment on that pull request, [on GitHub](https://github.com/medici-finance/assay-pr-agent/pull/15#issuecomment-7181350117).**

- Manuscript: `medici-finance/assay-pr-agent#15`, revision `c609020`; posted by `assay-pr-agent[bot]` on 26 November 2026
- Recommendation: Not reviewed: over budget
- Length: 12,645 estimated tokens against a limit of 6,000
- Findings: None. Hadolint found nothing at this revision.
- Coverage: The model review was skipped. History was unavailable.

```text
Codex review of c609020b9ec08fa35e18dea33f5dfd7db779b837
over-budget
Skipped Codex. Estimated prompt 12645 tokens exceeds the limit of 6000.

Static checks
- hadolint: 0 CI, 1 local, 0 findings, 0 incomplete.


Qualgen history unavailable for this review.


Review tooling built on [PR-Agent](https://github.com/the-pr-agent/pr-agent).

On-behalf-of: human:review-operator mode:unattended
```

Quoted verbatim. SHA-256 of the text above: `6ab0b24d421511c2c704004cd1226846bcce653e8379ab0faba9150f88dd0a12`

Comments:
- Comment 1 (line 3): Still over the limit, and larger: 12,645 estimated tokens.
- Comment 2 (line 6): No findings this time. The Dockerfile problems of the earlier head had been fixed, and the scan says so.


Repeat `--path path/to/file` to review an exact changed path, or split the change.

## Where the limit comes from

The limit is 6,000 estimated input tokens by default. Three things can change it, and the first one found wins:

| Source | Scope |
|---|---|
| `--max-input-tokens` | One run |
| `REVIEW_MAX_INPUT_TOKENS` in the environment | That container |
| The `REVIEW_MAX_INPUT_TOKENS` setting saved by setup | The saved setup, which the wizard asks for |
| 6,000 | When none of the above is set |

## One call, at most

Each run can launch the provider CLI **once**, with a 120-second timeout and at most three accepted findings. There is no model fallback, repair prompt, automatic retry or model polling.

The cap covers the prompt the reviewer submits. The CLI controls its own system context, its own output and its own billed usage. `model_usage` is filled in only if the CLI supplies it.

## The cache

A successful result is cached, and a repeated request does not pay again.

| Where it lives | When |
|---|---|
| `~/.cache/cursor-pr-review`, or under `XDG_CACHE_HOME` | The command line on its own |
| `/state/cache` | Reviews run by the poller, which passes `--cache-dir` |

The container image sets `XDG_CACHE_HOME=/tmp/.cache`, because its root filesystem is read-only. That covers a `cursor-review` run by hand inside the container.

A result is reused when all of these match the earlier run:

- The prompt: the same patch and the same scanner evidence.
- The scope, and the model.
- The source, meaning the change's address or the repository path.
- The provider, and for Cursor the team.

The commit's SHA is not among them. A new commit that leaves the patch unchanged hits the cache.

> The cache holds the model's answer, nothing else. Scanners and Qualgen run on every request, so a repeated review gets fresh static checks beside the cached findings.

A lock serializes duplicate local requests. For CI reuse across jobs, provide a persistent, trusted `--cache-dir`; each ephemeral runner otherwise starts cold. Use an explicit model for results you can compare.

## Coverage

A review can come back with less than was asked for, and says so each time.

| Written in the report | When |
|---|---|
| A path under `omitted` | A file has no usable patch or no head-side location, as for a whole-file deletion, or was excluded by `--path`. |
| A check with the state `could-not-check`, and a reason | A scanner could not run. [Static checks](checks.md) lists the reasons. |
| `Outside review coverage` in the comment | Any omitted path, repeated where people read it. |

Scanner findings are kept apart from model findings in the JSON. Missing scanner evidence stays visible even when the model finds nothing. Whenever anything is omitted or could not be checked, the state is [`partial`](output.md#partial) and the exit status is 2.

## Exit status

| Exit status | Meaning |
|---|---|
| 0 | The requested review or estimate completed in full. A review with findings also exits 0. |
| 2 | Partial coverage, a budget refusal, a model or tool error, or a publication failure. |

[Output and exit codes](output.md) lists the six states behind them and every field of the report.

---

Source of this page: https://pr-agent.assay.guide/cost
