Skip to content

feat: env-configurable review budget caps (PR_AF_MAX_DURATION_SECONDS / PR_AF_MAX_COST_USD)#41

Merged
AbirAbbas merged 1 commit into
mainfrom
feat/env-review-budget
Jun 4, 2026
Merged

feat: env-configurable review budget caps (PR_AF_MAX_DURATION_SECONDS / PR_AF_MAX_COST_USD)#41
AbirAbbas merged 1 commit into
mainfrom
feat/env-review-budget

Conversation

@AbirAbbas

Copy link
Copy Markdown
Contributor

Summary

The review budget caps (max_duration_seconds, max_cost_usd) were only settable per-call via the review() reasoner args. github-buddy calls pr-af.review without 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_dimension runs, 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 the 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 vars are unset (no behavior change).
  • An explicit per-call arg still wins over the env var.
  • max_cost_usd / max_duration_seconds reasoner params become … | None = None, matching the existing int | None = None params on the same reasoner (max_concurrent_reviewers, max_coverage_iterations), so reasoner registration is unaffected.
  • Mirrors the existing PR_AF_* env pattern in config.py.

After merge + deploy, set PR_AF_MAX_DURATION_SECONDS=1800 on 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)
  • New tests pass; full suite green except one pre-existing, unrelated flaky timeout test (test_create_request_fails_fast_when_hax_wedges), which fails identically on main.

🤖 Generated with Claude Code

…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>
@AbirAbbas AbirAbbas merged commit 25d411d into main Jun 4, 2026
2 checks passed
@AbirAbbas AbirAbbas deleted the feat/env-review-budget branch June 4, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant