feat(webhook): forward CP API key, add label trigger, optional review caps - #63
Open
jainakshay93 wants to merge 1 commit into
Open
Conversation
… caps Three improvements to the GitHub webhook handler, found running pr-af self-hosted with control-plane auth on a small shared host: 1. Forward AGENTFIELD_API_KEY as X-API-Key on the review-dispatch call. Without it, the webhook silently 401s whenever the control plane has auth enabled, so no webhook-triggered review ever runs. 2. Trigger a review when a configurable label (PR_AF_LABEL, default 'pr-af') is added to a PR — an alternative to the @mention comment. 3. Optional per-deployment review caps for webhook runs, applied only when set (PR_AF_MAX_CONCURRENT_REVIEWERS / PR_AF_MAX_REVIEW_DEPTH / PR_AF_MAX_COVERAGE_ITERATIONS / PR_AF_IGNORE_PATHS). Lets a small or shared host bound resource use without a code change; default behaviour is unchanged when unset. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Three improvements to the GitHub webhook handler (
app.py), found running pr-af self-hosted with control-plane auth on a small shared host. All are opt-in / non-breaking.1. Forward the control-plane API key (bug fix)
_fire_reviewPOSTs to/api/v1/execute/async/pr-af.reviewwith no auth header. When the control plane runs with auth enabled (AGENTFIELD_API_KEYset), that call 401s — so the webhook silently never dispatches a review. Now it forwardsAGENTFIELD_API_KEYasX-API-Keywhen set.2. Label trigger (feature)
Adds a
pull_requestlabeledhandler: applying a configurable label (PR_AF_LABEL, defaultpr-af) to a PR fires a review — an alternative to the@pr-afcomment mention. Handy where teams prefer a label, or where GitHub Actions can't run.3. Optional review caps for webhook runs (feature)
Webhook-triggered reviews can now read optional per-deployment limits, applied only when set (default behaviour unchanged):
PR_AF_MAX_CONCURRENT_REVIEWERSPR_AF_MAX_REVIEW_DEPTHPR_AF_MAX_COVERAGE_ITERATIONSPR_AF_IGNORE_PATHS(comma-separated)This lets a small/shared host bound resource use (e.g.
max_concurrent_reviewers=1,max_review_depth=0) without patching code — the default fan-out (concurrency 8, deep sub-reviews) can exhaust memory on a modest box and deadlock on very large PRs.Notes
.env.exampledocuments all new vars.🤖 Generated with Claude Code