fix(investigation): actually use thinking_budget parameter for per-specialist max_tokens

The _run_specialist_session() function accepted thinking_budget as a parameter
but completely ignored it, always deriving max_thinking_tokens from thinking_level
instead. This made the per-specialist max_tokens configuration (e.g., 128000 for
root_cause agents) non-functional.

Updated the thinking_kwargs logic to prioritize explicit thinking_budget when
provided, with fallback to thinking_level-based derivation for backward
compatibility.

This fix ensures both investigation and PR review specialists correctly use
their configured max_tokens budgets.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
This commit is contained in:
Sondre Engebråten
2026-02-16 16:15:07 +01:00
co-authored by Claude Sonnet 4.5
parent e20b3f7c18
commit fac3a22dd0
@@ -194,11 +194,19 @@ class ParallelAgentOrchestrator:
# Create SDK client for this specialist
# Use per-specialist model for betas (not the global config model)
betas = get_model_betas(model or self.config.model or "sonnet")
# Use per-specialist thinking level when provided
effective_thinking = thinking_level or self.config.thinking_level or "medium"
thinking_kwargs = get_thinking_kwargs_for_model(
model, effective_thinking
)
# Get thinking budget - use explicit budget if provided, otherwise derive from thinking level
if thinking_budget is not None:
thinking_kwargs = {
"max_thinking_tokens": thinking_budget
}
else:
# Use per-specialist thinking level when provided
effective_thinking = thinking_level or self.config.thinking_level or "medium"
thinking_kwargs = get_thinking_kwargs_for_model(
model, effective_thinking
)
# Override effort_level if explicitly provided (e.g., investigation
# agents always use "high" effort regardless of thinking level).
# Only applies to adaptive models (Opus 4.6+) where thinking_kwargs