What happened
On PR #23, the review agent ran 5 times. On each run, the agent computed the PR's total changed lines using a jq expression against the GitHub API's pulls/{number}/files endpoint. The formula [.[].additions + .[].deletions] | add was used, which in jq generates a cross-product: for each element's .additions, it adds every element's .deletions, producing N-squared results instead of N. On run 4 (workflow 30523081668), this computed 91,080 lines; on run 5 (30524230162), it computed 93,908 lines. The actual PR size was ~2,700 lines — a ~33x inflation. The agent self-corrected each time by re-running with the correct formula [.[] | (.additions + .deletions)] | add, but this wasted one turn per review run.
What could go better
The agent wastes a turn (and associated tokens) on every review run to self-correct the line count. Over 5 reviews on this PR, that is 5 wasted turns. The inflated initial count may also influence early reasoning about the PR's complexity before the correction occurs — the agent briefly believes it is reviewing a 91K-line change. Confidence: high — the bug was observed on both run 4 and run 5 with consistent behavior, and the jq cross-product semantics are well-documented. The fix is straightforward.
Proposed change
Pre-compute the accurate PR line count in scripts/pre-review.sh and pass it to the agent as an environment variable (e.g., PR_TOTAL_CHANGED_LINES). This removes the need for the agent to construct jq expressions for basic PR metadata at all. Alternatively, if the line count must be computed by the agent, add guidance in the skills/pr-review/SKILL.md skill definition warning about the jq cross-product pitfall: 'When computing totals from arrays, use [.[] | (.additions + .deletions)] | add — do NOT use [.[].additions + .[].deletions] | add as the latter produces a cross-product in jq.' The pre-script approach is preferred because it eliminates the class of error entirely.
Validation criteria
On the next 3 review agent runs against any repo in per-repo install mode, the agent should not compute an inflated line count or need a self-correction turn. If using the pre-script approach, the PR_TOTAL_CHANGED_LINES env var should be set before the agent starts. If using the skill-guidance approach, the agent should use the correct jq formula on the first attempt.
Generated by retro agent from redhat-community-ai-tools/code-to-docs#23
What happened
On PR #23, the review agent ran 5 times. On each run, the agent computed the PR's total changed lines using a jq expression against the GitHub API's
pulls/{number}/filesendpoint. The formula[.[].additions + .[].deletions] | addwas used, which in jq generates a cross-product: for each element's.additions, it adds every element's.deletions, producing N-squared results instead of N. On run 4 (workflow 30523081668), this computed 91,080 lines; on run 5 (30524230162), it computed 93,908 lines. The actual PR size was ~2,700 lines — a ~33x inflation. The agent self-corrected each time by re-running with the correct formula[.[] | (.additions + .deletions)] | add, but this wasted one turn per review run.What could go better
The agent wastes a turn (and associated tokens) on every review run to self-correct the line count. Over 5 reviews on this PR, that is 5 wasted turns. The inflated initial count may also influence early reasoning about the PR's complexity before the correction occurs — the agent briefly believes it is reviewing a 91K-line change. Confidence: high — the bug was observed on both run 4 and run 5 with consistent behavior, and the jq cross-product semantics are well-documented. The fix is straightforward.
Proposed change
Pre-compute the accurate PR line count in
scripts/pre-review.shand pass it to the agent as an environment variable (e.g.,PR_TOTAL_CHANGED_LINES). This removes the need for the agent to construct jq expressions for basic PR metadata at all. Alternatively, if the line count must be computed by the agent, add guidance in theskills/pr-review/SKILL.mdskill definition warning about the jq cross-product pitfall: 'When computing totals from arrays, use[.[] | (.additions + .deletions)] | add— do NOT use[.[].additions + .[].deletions] | addas the latter produces a cross-product in jq.' The pre-script approach is preferred because it eliminates the class of error entirely.Validation criteria
On the next 3 review agent runs against any repo in per-repo install mode, the agent should not compute an inflated line count or need a self-correction turn. If using the pre-script approach, the
PR_TOTAL_CHANGED_LINESenv var should be set before the agent starts. If using the skill-guidance approach, the agent should use the correct jq formula on the first attempt.Generated by retro agent from redhat-community-ai-tools/code-to-docs#23