Skip to content

fix: pre-fetch review comments and allow astral.sh in responder#186

Open
microsasa wants to merge 6 commits intomainfrom
fix/responder-prefetch-comments
Open

fix: pre-fetch review comments and allow astral.sh in responder#186
microsasa wants to merge 6 commits intomainfrom
fix/responder-prefetch-comments

Conversation

@microsasa
Copy link
Owner

@microsasa microsasa commented Mar 20, 2026

Summary

Fixes #180 (MCP returns empty review comments), #183 (astral.sh blocked by firewall), and #184 (audit all workflows for missing network domains).

Problem

Three issues prevented the gh-aw agents from working correctly:

  1. MCP read failure: The GitHub MCP pull_request_read tool returns empty [] for review comments inside the gh-aw agent sandbox. This is a known issue confirmed by the gh-aw team. The responder could never find comments to address.

  2. Cannot run lint: astral.sh (where uv and ruff binaries are hosted) was blocked by the firewall. All three code-writing workflows (responder, ci-fixer, implementer) were instructed to run uv run ruff check but could not. The agents skipped validation and pushed unverified code. PR body claims like "All 416 tests pass" were written without actually running tests — confirmed by checking agent logs (zero matches for uv/ruff/pytest).

  3. Audit: All 6 workflows audited. The 3 that write code (responder, ci-fixer, implementer) now have astral.sh. The other 3 (code-health, quality-gate, test-analysis) only review/file issues and do not need it.

Solution

Pre-fetch pattern (fixes #180)

Created a shared import (.github/workflows/shared/fetch-review-comments.md) that runs before the agent starts:

  • Uses gh api graphql to fetch all review threads with resolution status
  • Flattens GraphQL comments.nodes wrapper into clean arrays
  • Writes filtered unresolved threads to /tmp/gh-aw/review-data/unresolved-threads.json
  • The agent reads from the file instead of calling MCP

This mirrors the pattern used in github/gh-aw own copilot-pr-data-fetch.md.

Network fix (fixes #183, #184)

Added "astral.sh" to network.allowed in all three code-writing workflows:

  • review-responder.md
  • ci-fixer.md
  • issue-implementer.md

Changes

  • NEW .github/workflows/shared/fetch-review-comments.md — pre-fetch shared import
  • MODIFIED .github/workflows/review-responder.md — added imports:, astral.sh, updated step 3
  • MODIFIED .github/workflows/ci-fixer.md — added astral.sh to network
  • MODIFIED .github/workflows/issue-implementer.md — added astral.sh to network
  • MODIFIED lock files recompiled for all three

Testing

Tested pre-fetch on two PRs (before jq/pagination fixes, both successful):

Known limitations

Related issues

Sasa Junuzovic and others added 3 commits March 20, 2026 09:06
MCP pull_request_read returns [] inside the agent sandbox. This has
never worked reliably in our repo. The working runs used web_fetch
as a fallback, but the agent doesn't consistently fall back.

Fix: add a shared import (fetch-review-comments.md) with a steps:
block that runs gh api graphql BEFORE the agent starts, writing
threads to /tmp/gh-aw/review-data/unresolved-threads.json. The agent
reads the file instead of querying MCP or the API.

This follows the pattern used by github/gh-aw's own workflows
(copilot-pr-data-fetch.md).

Related: #180

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The responder couldn't run ruff/uv in the sandbox because astral.sh
(where uv and ruff binaries are hosted) was blocked by the firewall.
This caused the agent to push code without lint validation, resulting
in E741 violations on PR #177.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Flatten comments.nodes wrapper in jq filter so the agent gets a
  clean comments array instead of GraphQL's { nodes: [...] } nesting.
  Matches the pattern used in gh-aw's own discussions-data-fetch.md.

- Bump reviewThreads(first: 50) to first: 100 (GitHub GraphQL max).
  This is a bandaid — proper cursor-based pagination is tracked in
  #185 but not worth the complexity yet since our PRs have 1-5
  threads.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 20, 2026 17:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes reliability issues in the review-responder gh-aw workflow by pre-fetching PR review threads via GraphQL (avoiding an intermittent MCP empty-result bug) and by allowing astral.sh so the agent can download/run the Astral Python toolchain (uv, ruff) inside the sandbox.

Changes:

  • Add a shared workflow import to fetch and persist unresolved review threads to /tmp/gh-aw/review-data/unresolved-threads.json.
  • Update review-responder to import the pre-fetch step, read the local JSON file instead of MCP/REST, and allow astral.sh.
  • Recompile the locked workflow YAML.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
.github/workflows/shared/fetch-review-comments.md New shared import that queries GraphQL for review threads and writes unresolved threads JSON for the agent to consume.
.github/workflows/review-responder.md Imports the pre-fetch step, switches instructions to read pre-fetched JSON, and adds astral.sh to the network allowlist.
.github/workflows/review-responder.lock.yml Updated compiled workflow reflecting the import, allowlist changes, and new pre-fetch step.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sasa Junuzovic and others added 2 commits March 20, 2026 10:14
Same firewall gap as the responder (#183). Both workflows instruct
the agent to run uv/ruff/pytest inside the sandbox, but astral.sh
was blocked. The agents were never actually running CI — the PR body
claims like 'All 416 tests pass' were written without executing any
tools. Confirmed by checking logs: zero matches for uv/ruff/pytest
in implementer run 23334098536.

Closes #184

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The tools.bash block in the shared import caused the compiled lock
file to switch from --allow-all-tools to a restricted shell allowlist
that excluded uv/ruff/pyright/pytest. The agent would still be unable
to run CI even with astral.sh allowed. Removing the tools block
restores --allow-all-tools since the steps block runs as a workflow
step, not inside the agent sandbox.

Also removed 2>&1 from the gh api call — stderr was being mixed into
the JSON output file, which would corrupt it if gh emitted warnings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 20, 2026 17:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Bump comments(first: 10) to comments(first: 100) so threads with
  many comments aren't truncated.
- Replace silent jq fallback (2>/dev/null || echo []) with explicit
  error handling — step now fails loudly if jq can't parse the
  GraphQL response instead of silently writing empty array.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants