Skip to content

Bound review/adversarial diff context size #32

Closed

Description

@JohnnyVicious

Summary

Review prompt construction currently embeds the full local diff or PR diff into the prompt without a total size cap. Large local diffs or PRs can exceed provider input limits, make reviews unreliable, or waste tokens.

The upstream Codex issue included spawnSync ENOBUFS; this repo avoids that exact sync-buffer failure by using async spawn, but the provider input-size problem still applies.

Local evidence

plugins/opencode/scripts/lib/prompts.mjs:

  • buildReviewPrompt() calls getDiff(...) or getPrDiff(...).
  • buildReviewContext() emits the entire diff as:
<diff>
${diff}
</diff>

There is no per-file cap, total cap, binary patch guard, or fallback path.

Expected behavior

Large reviews should fail gracefully or degrade into a bounded review context instead of blindly sending unlimited diff text.

Suggested fix

Add review-context budget handling:

  1. Enforce a configurable total character/token budget for <diff>.
  2. Enforce per-file caps and skip obvious binary/generated blobs.
  3. Include changed-file list and stats even when truncating the diff.
  4. Mark truncation clearly in the prompt so OpenCode knows the review is partial.
  5. For very large reviews, consider a separate mode that asks OpenCode to inspect the repo/diff itself with bounded file reads instead of embedding the entire diff.

Upstream references

Derived from openai/codex-plugin-cc#11 and #69. Related local feature direction: #21 for path/folder review context with size caps.

Activity

  1. changed the title [-]Review prompts embed full diffs/PR diffs without size caps[/-] [+]Bound review/adversarial diff context size[/+] on Apr 12, 2026
  2. JohnnyVicious commented on Apr 12, 2026

    @JohnnyVicious
    OwnerAuthor

    Consolidating #40 here. The canonical scope is bounded review context for standard and adversarial reviews, including avoiding full inline diffs when the diff or PR is too large.

  3. JohnnyVicious commented on Apr 12, 2026

    @JohnnyVicious
    OwnerAuthor

    Fixed by PR #51 commit e196f88 (backed by prompts.mjs and git.mjs fixes in 892493c) — buildReviewPrompt bounds diff reads at maxBytes+1 via runCommand({maxOutputBytes}), falls back to diff_stat+changed_files when thresholds exceeded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions