feat: add adaptive review effort budgets #19
Reference in New Issue
Block a user
Delete Branch "feat/review-budget-governor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Calibration
Reviewed active PR context from netcracker/interview and techspark/suaspark-dashboard to keep focused reviews inexpensive while allowing larger TypeScript/Go changes to complete.
Verification
🤖 AI Review · pragent pilot · headroom/MiniMax-M2.7 ·
4d51e14a· Merge confidence: 3/5 🟡Summary of Changes
Key Risks & Concerns
Findings Overview
2 inline comment(s); 4 total.
pilot/review/opencode_runtime.py:730pilot/review/budget.py:176pilot/review/opencode_runtime.py:124tests/pilot/review_tests/budget_test.py:922Unanchored Notes
pilot/review/opencode_runtime.py:730— If parse_events returns (text, None) — which it does when no step_finish event has been seen yet — usage is None and usage.get(...) raises TypeError: 'NoneType' object is not callable. This crashes the review process when the subprocess is terminated by the duration budget before emitting any step event.tests/pilot/review_tests/budget_test.py:922— The test passes runner=None to _run_process expecting it to be used, but since budget is also provided, the runner argument is ignored (Popen is used unconditionally). The test exercises Popen + budget enforcement correctly but does not exercise the runner code path it declares it is testing.🔋 AI Usage & Run Details
headroom/MiniMax-M2.7· opencode · 19 steps · 391.4s@@ -0,0 +173,4 @@cache_writes=int(usage.get("cache_write") or 0),output=int(usage.get("output") or 0),), price)except Exception:🔴 [HIGH] equivalent_cost wraps the entire cost_model import and cost() call in 'except Exception', which silently catches ImportError/ModuleNotFoundError. If cost_model is not on the Python path at runtime (any deployment where pilot/ is not in sys.path), equivalent_cost returns 0.0 and max_equivalent_cost_usd budget enforcement is completely non-functional — the cost cap can never be reached.
Fix: Catch only ImportError/ModuleNotFoundError and let other exceptions propagate; or validate at startup that cost_model is importable when max_equivalent_cost_usd is configured.
🪙 ~2,951 (3.0K) tok (19% · attributed output)
@@ -95,2 +121,4 @@raise RuntimeError(last_err or "opencode produced no output")def _run_process(🟡 [MEDIUM] The runner parameter is accepted and documented but is never used when budget is provided — _run_process always calls subprocess.Popen directly in that path. A caller passing a custom runner (e.g., for testability) would have it silently ignored with no error or warning.
Fix: Either remove the runner parameter from the budget path, or raise ValueError if runner is not callable when budget is provided.
🪙 ~1,885 (1.9K) tok (12% · attributed output)
🤖 AI Review · pragent pilot · headroom/MiniMax-M2.7 ·
592747d9· Merge confidence: 4/5 🟢Summary of Changes
Key Risks & Concerns
Findings Overview
1 inline comment(s); 1 total.
pilot/review/opencode_runtime.py:181🔋 AI Usage & Run Details
headroom/MiniMax-M2.7· opencode · 14 steps · 386.4s@@ -97,0 +178,4 @@"output": usage.get("output", 0) - previous["output"],}cost = float(usage.get("cost", 0.0)) - previous["cost"]previous.update({🟡 [MEDIUM] previous.update() (lines 181-189) never includes tool_calls, so the tool_calls count accumulated by parse_events is silently discarded and never propagated to BudgetState. The max_equivalent_cost_usd cap itself is unaffected (it uses only steps/total_tokens/output_tokens/equivalent_cost_usd), but metadata fields derived from BudgetState.snapshot() and the per-iteration accumulation will undercount tool calls in Langfuse.
Fix: Add 'tool_calls': usage.get('tool_calls', 0) to both the delta dict (lines 172-179) and the previous.update() call (lines 181-189), and track previous_tool_calls = 0 similarly.
🪙 ~14,610 (14.6K) tok (100% · attributed output)