Skip to content

Review agent intermittently completes without writing review-metrics.yaml #337

Description

@nsheaps

Summary

The AI review pipeline's "review" job (running the reviewer agent via claude-code-action) sometimes completes with is_error: false — the agent itself reports success — without ever writing the required review-metrics.yaml/.json file at REVIEW_METRICS_PATH. The downstream script agent-repo/.github/scripts/review-receiver/read-metrics-and-compute-conclusion.sh then fails with:

##[error]No metrics file at ... — review agent did not complete.

This cascades to a LouisBrunner/checks-action step reporting conclusion: failure, title: "The review agent failed to run" on the original check run in the consumer repo, plus a generic ::error::Receiver pipeline failed. line. The accompanying troubleshooting hint about REVIEW_GITHUB_APP_ID/REVIEW_GITHUB_APP_PRIVATE_KEY does not apply — auth is confirmed present in all three occurrences below.

Evidence

Occurrence 1 — nsheaps/agents#333 (check run 93983045453, job 93983057990, run 31554184270)

  • Agent JSON result: is_error: false, num_turns: 49, total_cost_usd: 2.0171772499999996, permission_denials_count: 16
  • No metrics file was ever written despite the agent reporting success.

Occurrence 2 — nsheaps/.ai-agent-jack#483 (check run 93984292623, HeadSHA f40ef82e86547f0b67b93c6d7b8820e26f7f4b3f, run 31554600489)

  • Same symptom, on the SAME HeadSHA that an EARLIER run successfully completed a full review (Henry's COMMENT-verdict review is posted on this PR). This confirms the failure is intermittent, not something that blocks review outright — a re-run on identical input can succeed or fail.

Occurrence 3 — nsheaps/ai-mktpl#743 (check run 93983718763, HeadSHA 68e8e530a50fec9478c2d3ce699d38bb809a8c71, run 31554405041)

  • Same symptom, different repo entirely.

Three independent occurrences across three different repos, with successful runs interspersed on at least one of the same commits — this points to a systemic/intermittent reliability bug in the shared review pipeline (claude-code-action and/or the metrics-handling script), not something caused by the content of any specific PR.

Candidate root cause (not fully confirmed)

The review prompt template embedded in the job log (step 11, "Emit review metrics") explicitly instructs the agent to use the Write tool at /home/runner/work/_temp/review-metrics.yaml, and explicitly warns:

[do NOT use] Bash(gh:*)/Bash(git:*) — allowlist and will be silently denied, leaving this step incomplete even though the rest of the review su[cceeded]...

This suggests that on failing runs, the agent may attempt to write/commit the metrics file via a gh/git-based path instead of the required Write tool, gets silently denied (a plausible source of some of the 16 permission_denials_count seen on occurrence 1), completes the rest of the review successfully, but never actually creates the gating file. This is grounded in log evidence but NOT confirmed via a full turn-by-turn transcript — the specific denied tool call hasn't been isolated.

Suggested investigation checklist

  • Pull the full turn-by-turn transcript (not just the final JSON result) for at least one failing run to confirm which tool call was denied around step 11
  • Check whether the prompt template's warning about gh/git being denied is itself a signal the template should be hardened (e.g. retry logic, or a repo-side fallback check for the metrics file via a non-agent step)
  • Determine whether this correlates with agent turn count / cost (occurrence 1 had a relatively high num_turns: 49 — does the agent "forget" the metrics step on longer reviews?)
  • Consider adding a fallback: if the agent's own JSON result reports is_error: false but no metrics file exists, treat it as a distinct, more specific failure mode (e.g. "review completed but metrics step skipped") rather than the generic "review agent did not complete" — this would make the failure mode easier to diagnose from the check-run title alone
  • Consider whether claude-code-action's permission allowlist should explicitly grant Write to the metrics path (it should already, per the prompt template, but confirm the actual allowlist config) to rule out a race/config drift

Impact

Blocks the CI-green gate for PRs relying on request-review label re-triggering — three in-flight PRs (nsheaps/agents#333, nsheaps/.ai-agent-jack#483, nsheaps/ai-mktpl#743) hit this and required re-triggering the review.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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