Repository navigation
Description
OpenCodeReview Version
open-code-review v1.8.10 (adbd4fd) darwin/arm64 built at: 2026-08-08T01:30:30Z
Operating System
macOS (Apple Silicon)
Installation Method
npm (global)
LLM Provider
Other OpenAI-compatible endpoint
Bug Description
--preview applies only the static file filters, but a real review applies an additional per-file prompt-size filter before it freezes coverage. A file can therefore be listed under "Will review" and then never be reviewed.
Preview classifies files with whyExcluded (internal/agent/preview.go:34), covering user_exclude, unsupported_ext, default_path, deleted, and binary. A real run additionally calls filterLargeDiffs (internal/agent/agent.go:497), which drops any diff whose token count exceeds llmloop.PromptTokenLimit(Template.MaxTokens) — 80% of max_tokens. That runs before registerCoverage (internal/agent/agent.go:509) seals the selected set, so dropped files are absent from the manifest's selected coverage.
Preview cannot apply that filter today even in principle: runPreview (cmd/opencodereview/review_cmd.go:378) does not pass Template into agent.Args, so Template.MaxTokens is zero on the preview path.
This makes --preview unsound as a pre-flight check. It is the natural input for CI admission control ("is this changeset too big to review?"), but its selected set is not the set the review will actually cover.
Steps to Reproduce
Default configuration, no flags. No API key is needed and no request is made: filterLargeDiffs runs before any dispatch; the dummy endpoint only gets past runtime construction.
mkdir repro && cd repro && git init -q .
git config user.email t@t && git config user.name t
printf 'package main\n\nfunc main() {}\n' > seed.go
git add -A && git commit -qm init
# ~186 KB, so its diff exceeds 80% of the default max_tokens (58888 -> 47110)
{ echo "package huge"; for i in $(seq 1 4000); do echo "func Hn$i(a int) int { return a * $i }"; done; } > huge.go
git add -A && git commit -qm "add one large file"
# 1. preview lists huge.go under "Will review"
ocr review --commit HEAD --preview
# 2. the real run drops it before dispatch
OCR_LLM_URL=https://api.invalid.test/v1 OCR_LLM_TOKEN=dummy OCR_LLM_MODEL=fake-model ocr review --commit HEADExpected Behavior
Preview's will_review: true set should equal the set a fresh, non-resumed, unbudgeted real run registers as selected coverage.
Concretely:
- Extract the deterministic pre-dispatch selection as one operation returning every input file with a decision and a stable reason, and have both
Agent.Previewand the real pre-dispatch path consume it. Reimplementing the size check separately in preview would just let the two drift again. - Add a stable exclusion reason for oversized diffs, e.g.
too_large, so consumers need not reproduce the tokenizer or the 80% threshold. The human preview can render it through the existing reason rendering. - Give preview the resolved per-file limit without initializing a provider. Since feat(config): make per-file token limit configurable #716 the limit comes from
--max-tokens, then app config, then the template;resolveMaxTokensneeds onlyAppCfg, which loads independently ofllm.ResolveEndpointWithOptions. So preview can resolve the real limit while keeping its current property of requiring no API key.
Explicitly out of scope: aggregate --max-tokens-budget exhaustion, LLM failures, and anything else depending on execution. Those cannot be predicted statically, and preview should document that rather than guess.
Logs / Error Output
$ ocr review --commit HEAD --preview
Preview: 1 file(s) changed | +4001 -0
Will review (1):
[A] huge.go +4001 -0
$ ocr review --commit HEAD
[ocr] 1 file(s) changed, reviewing 1 in /tmp/repro
[ocr] Skipping huge.go (~70047 tokens exceeds 80% of max_tokens(58888))
[ocr] Pre-filtered 1 file(s) exceeding 80% of max_tokens
[ocr] All changed files exceeded the token size limit. Skipping review.
[ocr] Summary: 0 file(s) reviewed, 0 comment(s), ~0 token(s) used, 0s elapsed
Review skipped: no items were selected.Additional Context
The WARNING: prompt tokens ... line above is a different gate: it measures the assembled prompt rather than the diff, and does not drop the file. ok.go stays selected. Only big2.go leaves the selected set, and only big2.go is the divergence.
This looks like the remaining half of #480, which asked that "preview must apply the same relevant selection stages as review execution, or clearly report why later prefilters can change scope". #482 fixed the reporting side by making files_reviewed count dispatchable files; the selection sets themselves still diverge, and #480's note that "large-diff filtering also occurs at a different stage" still holds.
Related: #367, #480, #482, #716.
I'm happy to implement this, but it changes how selection is structured, so I'd rather agree on the approach first — in particular whether you prefer a shared pure selection function over having preview call filterLargeDiffs directly, and whether too_large is the reason string you want.
Disclosure: Issue report authored by AI, with human guidance and careful review.
Activity
wu21-web commentedon Aug 8, 2026
Is this issue fixed by now?
zmwangx commentedon Aug 8, 2026
It's not; the two preview-related PRs I opened and got merged yesterday are separate issues. I raised this as an issue instead of opening a PR because there are decisions I want to run through maintainers first, like I said above,
But maybe I should just open an accompanying PR and get feedback there?
zmwangx commentedon Aug 9, 2026
I created #801 which is one possible implementation—I consider this the best for long term, but not the simplest change to fix this.
fix(agent): make --preview apply the same selection the review applies
fix(agent): make --preview apply the same selection the review applies (
fix(agent): make --preview apply the same selection the review applies (
Merge tag 'v1.12.9' into feat/ocr-core-local
docs(solutions): refresh workflow-issues learnings after the v1.12.9 …