From 251e254b1230f1dedb874e12c8e0a21047ce2140 Mon Sep 17 00:00:00 2001 From: Brad DerManouelian Date: Fri, 22 May 2026 10:45:41 -0500 Subject: [PATCH] fix(llm): honor configured max-output-tokens in outline endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The two-phase test-case generation outline route silently capped maxTokens at 1024 via Math.min(providerConfig.defaultMaxTokens ?? 1024, 1024), overriding whatever value the user set in LLM settings. When a user requested "Many" outlines, the response often exceeded 1024 tokens, causing the JSON to truncate mid-array. The resulting parse error suggested raising max-output-tokens — a setting the route ignored. - Drop the hard 1024 ceiling; honor providerConfig.defaultMaxTokens and fall back to resolvedPrompt.maxOutputTokens, matching the expand route's resolution order. - Bump the no-config fallback from 1024 to 2048 so "Many" outlines fit out of the box. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../app/api/llm/generate-test-cases/outline/route.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/testplanit/app/api/llm/generate-test-cases/outline/route.ts b/testplanit/app/api/llm/generate-test-cases/outline/route.ts index eacd03f4..7d301d7c 100644 --- a/testplanit/app/api/llm/generate-test-cases/outline/route.ts +++ b/testplanit/app/api/llm/generate-test-cases/outline/route.ts @@ -109,12 +109,15 @@ export async function POST(request: NextRequest) { const systemPrompt = buildOutlineSystemPrompt(quantity); const userPrompt = buildOutlineUserPrompt(issue, context); - let maxTokens = resolvedPrompt.maxOutputTokens ?? 1024; + let maxTokens = resolvedPrompt.maxOutputTokens ?? 2048; const providerConfig = await (prisma as any).llmProviderConfig.findFirst({ where: { llmIntegrationId: resolved.integrationId }, }); if (providerConfig) { - maxTokens = Math.min(providerConfig.defaultMaxTokens ?? 1024, 1024); + maxTokens = + providerConfig.defaultMaxTokens ?? + resolvedPrompt.maxOutputTokens ?? + 2048; } const llmRequest: LlmRequest = {