feat: env-configurable review budget caps (PR_AF_MAX_DURATION_SECONDS / PR_AF_MAX_COST_USD)#41
Merged
Merged
Conversation
…CONDS / PR_AF_MAX_COST_USD) The review duration/cost caps were only settable per-call via the review() reasoner args, which github-buddy does not pass — so every review used the hardcoded defaults (300s / $2). On non-trivial PRs the 300s cap is exhausted during anatomy/meta before review_dimension runs, yielding zero findings. Add a _resolve_budget_caps() helper: when the caller passes no explicit value, fall back to PR_AF_MAX_DURATION_SECONDS / PR_AF_MAX_COST_USD env vars, then to the historical 300s / $2 defaults. Defaults are unchanged when the env is unset; an explicit per-call arg still wins over the env. Mirrors the existing PR_AF_* env pattern in config.py. Co-Authored-By: Claude Opus 4.8 <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.
Summary
The review budget caps (
max_duration_seconds,max_cost_usd) were only settable per-call via thereview()reasoner args. github-buddy callspr-af.reviewwithout passing them, so every review used the hardcoded defaults (300s / $2).On any non-trivial PR the 300s cap is exhausted during the anatomy + meta phases (anatomy alone takes ~200–260s) before
review_dimensionruns, so the pipeline identifies risks but produces zero scored findings → no review posted, no HITL gate. There was no way to raise the cap without a code change, because the value is unconditionally taken from the reasoner default.Change
Add
_resolve_budget_caps(): when the caller passes no explicit value, fall back to thePR_AF_MAX_DURATION_SECONDS/PR_AF_MAX_COST_USDenv vars, then to the historical300s/\$2defaults.max_cost_usd/max_duration_secondsreasoner params become… | None = None, matching the existingint | None = Noneparams on the same reasoner (max_concurrent_reviewers,max_coverage_iterations), so reasoner registration is unaffected.PR_AF_*env pattern inconfig.py.After merge + deploy, set
PR_AF_MAX_DURATION_SECONDS=1800on the pr-af service to let reviews complete.Tests
tests/test_budget_env.py— env override used when no explicit value; historical defaults when env unset; explicit arg wins over env.Validation
ruff check src/ scripts/— passes (CI lint gate)test_create_request_fails_fast_when_hax_wedges), which fails identically onmain.🤖 Generated with Claude Code