From d4f432224ad3bb9b911d93f09ffbdec0aa06cb99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sondre=20Engebr=C3=A5ten?= Date: Mon, 16 Feb 2026 18:42:52 +0100 Subject: [PATCH] fix(investigation): reserve 1 token for message separator in max_tokens The SDK needs 1 token for the space/message separator between thinking and response. Set SPECIALIST_MAX_TOKENS values 1 token lower than API limits to avoid rejection errors: - root_cause: 127999 (API max: 128000) - impact/fix_advisor/reproducer: 63999 (API max: 64000) This fixes API errors like: max_tokens: 128001 > 128000, which is the maximum allowed Co-Authored-By: Claude Sonnet 4.5 --- .../github/services/issue_investigation_orchestrator.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/backend/runners/github/services/issue_investigation_orchestrator.py b/apps/backend/runners/github/services/issue_investigation_orchestrator.py index 1b0754e5..e2664505 100644 --- a/apps/backend/runners/github/services/issue_investigation_orchestrator.py +++ b/apps/backend/runners/github/services/issue_investigation_orchestrator.py @@ -97,11 +97,12 @@ logger = logging.getLogger(__name__) # Per-specialist max_tokens configuration (Opus 4.6 supports up to 128K) # Root cause gets highest limit for deep analysis +# Note: Values are 1 token lower than API max to reserve space for message separator SPECIALIST_MAX_TOKENS = { - "root_cause": 128000, # Maximum for complex multi-file tracing - "impact": 64000, # Standard for component mapping - "fix_advisor": 64000, # Standard for fix approaches - "reproducer": 64000, # Standard for test coverage analysis + "root_cause": 127999, # Maximum for complex multi-file tracing (API max: 128000) + "impact": 63999, # Standard for component mapping (API max: 64000) + "fix_advisor": 63999, # Standard for fix approaches (API max: 64000) + "reproducer": 63999, # Standard for test coverage analysis (API max: 64000) } # =============================================================================