fix(open-swe): surface reviewer diff-prep failures instead of swallowing (#1260)

When `_ensure_repo_checked_out` or `compute_diff_in_sandbox` fail, the
reviewer used to log+continue and hand the agent an empty diff. The
agent would then emit a misleading "no issues found" review and the
underlying error stayed buried in server logs.

Now the helpers raise on non-zero exit codes (with the sandbox output)
and the prep block re-raises, so the failure shows up in the LangSmith
run trace and we can debug the real issue.
This commit is contained in:
Johannes du Plessis 2026-05-07 18:20:27 -07:00 • committed by GitHub
parent 7e1746f420
commit 8d52e17614
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View file

@ -179,7 +179,14 @@ async def _ensure_repo_checked_out(
)
import asyncio
await asyncio.to_thread(sandbox_backend.execute, script)
result = await asyncio.to_thread(sandbox_backend.execute, script)
exit_code = getattr(result, "exit_code", None)
if exit_code not in (0, None):
output = getattr(result, "output", "") or ""
raise RuntimeError(
f"Repo checkout failed (exit {exit_code}) for {owner}/{repo} "
f"@ {head_sha} (base {base_sha}). Script output:\n{output}"
)
def _build_first_review_context(
@ -326,7 +333,11 @@ async def get_reviewer_agent(config: RunnableConfig) -> Pregel:
)
diff_line_set = compute_diff_line_set(diff_text)
except Exception:
# Don't swallow: an empty diff makes the agent emit a misleading
# "no issues found" review. Re-raise so the failure surfaces in
# the LangSmith trace with stderr from the sandbox commands.
logger.exception("Reviewer prep failed for thread %s", thread_id)
raise
config["configurable"]["diff_text"] = diff_text
config["configurable"]["diff_line_set"] = {

View file

@ -208,6 +208,13 @@ async def compute_diff_in_sandbox(
operator = "..." if merge_base else ".."
cmd = f"cd {work_dir} && git diff --no-color {base_ref}{operator}{head_ref}"
result = await asyncio.to_thread(sandbox_backend.execute, cmd)
exit_code = getattr(result, "exit_code", None)
if exit_code not in (0, None):
output = _stdout_from_result(result)
raise RuntimeError(
f"git diff failed (exit {exit_code}) for "
f"{base_ref}{operator}{head_ref} in {work_dir}. Output:\n{output}"
)
return _stdout_from_result(result)