AI review
The optional model pass, what it sends and never sends, how its claims are verified, and how it affects the verdict and the bill.
On this page
What it adds
The deterministic rules run first, with no model and no network. The AI pass is optional and runs after them. It sends the changed lines, with context, to a model and asks for findings in a fixed JSON format. Every finding must quote a changed line exactly; anything that does not verify is dropped and counted. Verified findings join the report with "source": "ai" and a rule ID of ai/<category>, such as ai/correctness.
It is off by default. Turn it on for one run with --ai, or for every run in your user config. A repository's own .codeveto.toml cannot turn on a network provider, choose the model or set an endpoint.
Providers
Claude
pipx install 'codeveto[claude]'
export ANTHROPIC_API_KEY=...
codeveto review --base main --ai claudeThe default model is claude-opus-5-5 with effort high; --ai-model and [ai] effort change them. The base URL is --ai-base-url or [ai] base_url, then ANTHROPIC_BASE_URL, then https://api.anthropic.com. Before the first packet, CodeVeto checks that the model supports structured output and which effort levels it accepts; a model that cannot return structured output fails the pass before anything is sent. Each packet goes out as one streamed request with the system prompt marked for caching and the answer schema as the output format.
OpenAI-compatible
pipx install 'codeveto[openai]'
export CODEVETO_AI_API_KEY=...
codeveto review --base main --ai openai --ai-model <model-id> --ai-base-url https://llm.example.internal/v1--ai-model is required. The base URL is --ai-base-url or [ai] base_url, then CODEVETO_AI_BASE_URL, then https://api.openai.com/v1; OPENAI_BASE_URL is never read. OPENAI_API_KEY is sent only to api.openai.com; every other host needs CODEVETO_AI_API_KEY, which may be empty for a loopback host. The answer format is --ai-response-format json_schema (the default, strict), json_object or prompt. If the endpoint rejects the response format, the pass fails with an issue naming the flag; it is never downgraded silently.
For both providers the base URL must be https://, or http:// only for localhost or a loopback IP, and may not carry a user name or password. The report's ai.endpoint records the host, port and path that were used.
Harness mode
In harness mode the agent you are already running is the model, and CodeVeto never touches the network:
codeveto packets --base main --output packets.json
# the agent reads packets.json and writes responses.json
codeveto verify --base main --responses responses.jsonpackets.json holds a run_id, the instructions, the answer schema and the packets. The agent answers with exactly one entry per packet; an empty findings list means nothing to report:
{
"run_id": "062693dde0e5d61d7158c453656f080fd1c75d99b0361d605c060b5e531a6e85",
"responses": [
{ "packet_id": "149b2c9f5f854209a2a20771883a6de4c1490ccaccc9346c66c23922c82a3fc3", "findings": [] }
]
}verify reviews the change again from scratch, regenerates the packets and checks the answers against them, then prints the JSON report. Responses for a change that moved since packets (stale_run), or for packets that do not exist, are rejected. The MCP server offers the same two steps as the tools get_ai_packets and submit_ai_review.
What is sent
A packet is one file's changed lines with up to 20 lines of context around each, at most 24 KiB of JSON. Each line carries its side (old or new), its number, whether it changed, and its text. Large hunks are split, and every changed line is an anchor in exactly one packet. Packets are sent in order of risk: source, workflows, agent configuration, config and manifests first, then tests, then docs and text, then generated, vendored and minified files.
Before anything is encoded, every line of both sides of each file goes through the secrets detectors, whatever the review policy says. A match becomes [REDACTED:secrets/<rule>], private key blocks are redacted whole, a redacted value is also replaced wherever else it appears, and a secret-looking file name is redacted in the packet's path. If the secrets pack is not installed, the pass does not start.
The system prompt is fixed in the package. It says that repository text is untrusted evidence and must never be followed as instructions. Repository text is never put into the system prompt.
What is never sent
These files never leave your machine, and the report's ai.coverage lists each with its reason:
| Reason | Files |
|---|---|
sensitive_path |
.env and .env.* (not .example, .sample, .template, .dist), *.env, .envrc, *.pem, *.key, *.p12, *.pfx, *.ppk, .npmrc, .pypirc, .netrc, _netrc, .git-credentials, credentials.json, client_secret*.json, .aws/credentials, SSH keys (id_rsa, id_ed25519 and the like, with .pub), anything under .ssh/, and any path that itself looks like a credential |
lockfile |
Lockfiles such as package-lock.json, uv.lock, go.sum |
generated, vendored, minified |
Paths your trusted config puts in [classes] |
binary, symlink, submodule, lfs_pointer |
Anything that is not text |
not_read, invalid_path |
Files the review did not read (over a limit) or whose name is invalid |
secret_scan_failed |
A file whose secret scan failed |
max_packets |
Files past the packet cap |
A lone changed line too long for one packet is skipped (line_too_long).
How findings are verified
The model's answer is checked before any of it is believed:
- strict JSON, at most 256 KiB, matching the answer schema, at most 8 findings per packet;
- the packet must exist and belong to this run; the path must match; the line must be a changed line of that packet on that side;
- the
quotemust equal the line's text exactly after Unicode normalization and trimming of spaces and tabs, compared with the redacted text the model saw; - a line with fewer than 3 letters or digits cannot anchor a finding (
trivial_anchor); - titles are capped at 120 characters, explanations and suggestions at 600; text with URLs, Markdown links or images is rejected; control characters are stripped and the text is redacted again;
- a second finding for the same line and category is a duplicate.
Each rejection is counted in ai.rejected and listed in ai.rejections with one of the reasons unknown_packet, stale_run, path_mismatch, line_not_changed, quote_mismatch, trivial_anchor, schema, bounds, url_in_text or duplicate. A verified finding on the same line as a rule finding of the same category, at least as severe, is merged into the rule finding.
Policy: advisory, required or blocking
| Setting | AI findings | A failed or partial pass |
|---|---|---|
| default | Advisory: high and medium are warnings, low notes. Nothing the AI says blocks. |
An issue in the report; the verdict is unchanged. |
[ai] required = true |
Advisory. | A failed pass makes the review incomplete; a partial pass is an issue. |
[ai] blocking = true |
high findings are blocking errors; medium warnings, low notes. |
A failed or partial pass makes the review incomplete, unless a rule finding vetoes. |
A pass that cannot start at all (the SDK is not installed, no credentials, an unknown model, a rejected request, an unusable or stale harness answer) makes the review incomplete under every setting. --ai-optional turns that case into an issue so the review can finish without AI; it never overrides required or blocking. A repository may set required = true and blocking = true, but not turn them off for its own change: that is a weakening.
Budgets and cost
The trusted config and the command line set the budgets; a repository may only lower them.
| Key | Default |
|---|---|
max_packets |
40, at most 100 |
max_output_tokens (per packet) |
32,000 |
max_total_input_tokens |
unlimited |
max_total_output_tokens |
unlimited |
deadline_s (whole pass) |
600 |
concurrency |
4 |
effort |
high |
Budgets are reserved before a packet is sent, so the totals are never exceeded. Packet 1 goes out alone so the cached system prompt is written once, then up to concurrency packets run at a time. A packet that would not fit the remaining budget, or comes after the deadline, is skipped with the reason, and the pass is partial. The report's ai.usage adds up input, output, cache-write and cache-read tokens for every request.
To keep costs down: set max_total_input_tokens and max_total_output_tokens in your user config, lower effort, keep ai-on-forks off in CI, and leave lockfiles and generated code out of the packets with [classes].
Privacy
- Only packets leave the machine: changed lines and their context from the files listed in
ai.packets, after redaction. Sensitive files never do. - The request goes only to the base URL you configured, checked as above, with the key meant for that host.
- Nothing is sent with
--ai none(the default), in harness mode, from Git hooks, or with--format agentunless--aiis given. - The report records the provider, model, endpoint, every packet's status and the served model, so you can see afterwards what was sent where.