feat(webhook): forward CP API key, add label trigger, optional review caps - #63
Merged
AbirAbbas merged 7 commits intoAug 8, 2026
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>
…d caps The Go node is the default install since Agent-Field#64, but its webhook rejected every pull_request event and fireReview sent no auth header, so the 401 fix and the new label/caps features only existed on the Python node. Mirror all three: conditional X-API-Key from AGENTFIELD_API_KEY, a configurable PR_AF_LABEL labeled-event trigger with delivery-ID LRU and per-PR TTL dedupe, and request-time cap parsing with the same input keys and validation as the Python side. Tests use an injected transport so no listening socket is needed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The node registers under NODE_ID but _fire_review always posted to pr-af.review, so any deployment overriding NODE_ID dispatched to a reasoner that does not exist. The Go port already uses n.NodeID. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… PR_AF_IGNORE_PATHS Malformed cap values escaped _fire_review's exception handler as webhook 500s, and concurrency 0 / negative values produced hangs or crashes: non-integer or below-minimum values are now logged and ignored (concurrency >= 1, depth >= 0, iterations >= 1). Label-triggered dispatches now dedupe GitHub delivery IDs (bounded LRU) and rate-limit per PR URL (10 min TTL, in-memory by design — single-process webhook). PR_AF_IGNORE_PATHS is removed instead of shipped inert: nothing in either pipeline reads ignore_paths yet; real diff filtering is follow-up work. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
With max_concurrent_reviewers=1 — the headline use case for the new webhook caps — a dimension that spawned a sub-review deadlocked: the parent held the sole semaphore permit while awaiting a child that could never acquire one. Await spawned children after the parent's permit is released. The Go orchestrator is structurally immune (parents return before children acquire). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
PR_AF_LABEL and the three cap variables were configurable but invisible to af config / Desktop because neither agentfield-package.yaml declared them; the Go README env table now lists them too. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Pushed a takeover pass to get this merge-ready — the base feature is unchanged, thanks @jainakshay93. What's new on top of the original commit (plus a merge of current main):
Gates: ruff clean, pytest 79 passed, go build/vet/test/gofmt clean, CI green. |
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