GitHub pull request reviews

Have an agent review pull requests - either through the GitHub chat channel, or from GitHub Actions calling a routine webhook when a pull request is ready.

Veyra Docs TeamUpdated 2 min readVersion 3 · History

There are two ways to bring pull requests to an agent. Use the GitHub channel when people should talk to the agent on GitHub. Use a routine webhook from GitHub Actions when every ready pull request should get a review, with no one asking.

Option 1: the GitHub channel

Connect GitHub as a chat channel. GitHub then sends events for the repositories you choose to:

HTTP
POST https://intelligence-api.veyra.so/api/chat-webhooks/{publicId}/github

Each delivery is verified with the GitHub App's webhook secret (X-Hub-Signature-256). Mentions of the agent and review requests become tasks; the agent answers in the pull request's conversation. GitHub's X-GitHub-Delivery id keeps redeliveries from creating duplicates.

Option 2: a routine webhook from GitHub Actions

A workflow in your repository calls a routine trigger when a pull request passes its checks. The routine's agent reviews it and posts its recommendation on the routine's task.

Set up the routine

  1. Create a routine with your reviewer agent. In its request, say what to check and what to publish, for example: "Review the pull request {{pr_url}} at head {{head_sha}}. Verify the head and base again before you start. Post MERGE, HOLD or DO NOT MERGE with your reasons. Do not approve, merge or comment on GitHub."
  2. Declare the required text variables pr_url, pr_number, head_sha and base_sha.
  3. Set When a run overlaps to Always enqueue, so separate pull requests are never merged into one review.
  4. Add a webhook trigger with signing mode bearer. Copy the URL and the secret.

Set up GitHub

  1. In the repository, create an Actions environment (for example pr-review) limited to your default branch.
  2. Add two environment secrets: VEYRA_REVIEW_WEBHOOK_URL and VEYRA_REVIEW_WEBHOOK_TOKEN.
  3. Add a workflow that runs from your default branch after your checks finish and sends only identifiers, never code:
YAML
name: Ask Veyra for a review
on:
  workflow_run:
    workflows: [ci]
    types: [completed]
permissions:
  contents: read
  pull-requests: read
jobs:
  notify:
    if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request'
    runs-on: ubuntu-latest
    environment: pr-review
    steps:
      - name: Send the pull request to the review routine
        env:
          URL: ${{ secrets.VEYRA_REVIEW_WEBHOOK_URL }}
          TOKEN: ${{ secrets.VEYRA_REVIEW_WEBHOOK_TOKEN }}
          PR: ${{ toJSON(github.event.workflow_run.pull_requests[0]) }}
        run: |
          number=$(jq -r .number <<<"$PR")
          head=$(jq -r .head.sha <<<"$PR")
          base=$(jq -r .base.sha <<<"$PR")
          body=$(jq -n --arg n "$number" --arg h "$head" --arg b "$base" \
            --arg u "https://github.com/${{ github.repository }}/pull/$number" \
            '{variables: {pr_url: $u, pr_number: $n, head_sha: $h, base_sha: $b}}')
          curl --fail --silent --show-error --max-time 15 --proto '=https' \
            -X POST "$URL" \
            -H "Authorization: Bearer $TOKEN" \
            -H "Content-Type: application/json" \
            -H "Idempotency-Key: pr-$number-$head-$base" \
            --data "$body"

The idempotency key makes a repeated event for the same pull request, head and base a no-op. A new commit or a new base gets a new review.

Test it

Create the trigger in test mode first. A delivery in test mode is authenticated and recorded without starting a review; turn test mode off when it passes.

Important

The webhook carries identifiers, not code. The agent must treat them as untrusted, fetch the pull request itself, and confirm the head and base have not changed before it recommends anything.

GitHubInboundRoutinesWebhooks