Skip to content

Bound review/adversarial diff context size #32

@JohnnyVicious

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.

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