From fac3a22dd0a4145f925f63fa42e30eeb0632bb7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sondre=20Engebr=C3=A5ten?= Date: Mon, 16 Feb 2026 16:15:07 +0100 Subject: [PATCH] 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 --- .../github/services/parallel_agent_base.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/apps/backend/runners/github/services/parallel_agent_base.py b/apps/backend/runners/github/services/parallel_agent_base.py index 7fcba2dd..38c0e1df 100644 --- a/apps/backend/runners/github/services/parallel_agent_base.py +++ b/apps/backend/runners/github/services/parallel_agent_base.py @@ -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