Skip to content

fix(strands-command): inline full PR diffs within a total budget#63

Open
yonib05 wants to merge 2 commits into
strands-agents:mainfrom
yonib05:fix/pr-diff-truncation
Open

fix(strands-command): inline full PR diffs within a total budget#63
yonib05 wants to merge 2 commits into
strands-agents:mainfrom
yonib05:fix/pr-diff-truncation

Conversation

@yonib05

@yonib05 yonib05 commented Jun 10, 2026

Copy link
Copy Markdown
Member

Problem

get_pr_files capped every changed file's patch at 50 lines:

if len(patch_lines) > 50:
    output += '\n'.join(patch_lines[:50])
    output += f"\n   ... (truncated, {len(patch_lines) - 50} more lines)\n"

The reviewer agent then reasons about a partial diff for any non-trivial
change. A bug introduced on line 60 of a changed file is simply invisible
to it, and the agent gets no signal that anything is missing beyond a
terse "truncated" note. This silently caps review quality on exactly the
larger PRs that most need a careful read.

Fix

Replace the blunt per-file line cap with a total diff character budget:

  • inline each file's full patch until the cumulative budget is reached,
  • once exceeded, list the remaining files (with their add/delete stats)
    and instruct the agent to fetch them on demand via the shell tool,
    rather than cutting a file off mid-diff.

This keeps the original intent (bounding how much diff goes into one
prompt) while ensuring that whatever is inlined is complete, and that
anything omitted is explicitly surfaced instead of hidden.

Tests

Adds tests/test_github_tools.py:

  • full diff (120 lines) is inlined without truncation,
  • oversized total diff lists the file for on-demand fetch,
  • binary/no-patch files are handled.

The first test fails against the old code (it emitted truncated and
dropped the tail), confirming the regression it guards.

35 passed

yonib05 added 2 commits June 10, 2026 12:57
get_pr_files capped every file's patch at 50 lines, so the reviewer
silently lost the tail of any larger change and reasoned about code it
never saw. Replace the per-file line cap with a total character budget:
inline full patches until the budget is reached, then list remaining
files for on-demand fetch instead of truncating mid-file.
…ping it

A file whose patch alone exceeds the budget previously produced no inline
diff at all, leaving the reviewer dependent on fetching it. Inline a
line-trimmed head slice when enough budget remains so there is always some
inline signal, and note the omitted remainder is fetchable. Adds tests for
the partial-head and mixed inline/overflow cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant