Skip to content

Conversation

@Felipe-RA
Copy link

@Felipe-RA Felipe-RA commented Nov 24, 2025

Important

Solves #7

Problem

The reviewDiff function in reviewer.ts rejects valid review completions when the AI agent returns an empty string as the result. This occurs with large diffs (130K+ chars) where the agent uses only toolbox functions (leave_inline_comment, leave_general_comment) without additional text output.

Error observed:

[Amp] Started thread: T-06b3f3b3-a708-08371dc31a64
[Amp] Review completed successfully
Error starting thread: Error: Amp review failed

Root Cause

Line 81 in src/review/reviewer.ts:

if (!threadId || !result) throw new Error('Amp review failed');
  • Empty string is falsy in JavaScript, so !result evaluates to true
  • This causes the check to fail even when the review succeeded
  • Comments are collected via the JSONL file, not the result string
  • The result field is never used after being returned (verified in process-review.ts)

Solution

Changed the validation to only check for threadId:

if (!threadId) throw new Error('No thread ID received from Amp');

This allows empty result strings (which should be valid when AI uses only tools to write comments) while still catching legitimate errors (no thread created).

Testing

  • TypeScript type-check passes
  • Build succeeds
  • Verified result field is never accessed in process-review.ts
  • Reproduced the bug locally with tool-only AI responses
  • Confirmed fix resolves the issue when triggered on the local docker

Impact

  • Safe: result field is never used after this, so removing the check doesn't break anything
  • Backward compatible: Still returns result in response object

The reviewDiff function was rejecting valid review completions when
the AI agent returned an empty string as the result. This occurred
when the agent used only toolbox functions (leave_inline_comment,
leave_general_comment) without additional text output.

Issue:
- Line 81 checked: if (!threadId || !result)
- Empty string is falsy in JavaScript, so !result evaluates to true
- This caused 'Amp review failed' errors even when review succeeded
- Comments are collected via JSONL file, not the result string
- The result field is never used after being returned

Fix:
- Changed to only check: if (!threadId)
- Empty result is now valid (AI used tools, no text needed)
- Only fails if no thread was created (legitimate error)

Evidence:
- Tested with 130K+ char diffs that trigger tool-only responses
- Verified result field is never accessed in process-review.ts
- Build passes, TypeScript compiles successfully

This allows reviews to complete when AI agents generate comments via
tools without returning additional text in the result field.
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