{"record":{"id":"b1832fd24f393105","repo":"microsoft/vscode","slug":"unable-to-build-prompt-modelmaxprompttokens-m","errorCode":null,"errorMessage":"Unable to build prompt, modelMaxPromptTokens = ${maxTokens} (${e.message})","messagePattern":"Unable to build prompt, modelMaxPromptTokens = (.+?) \\((.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extensions/copilot/src/extension/intents/node/agentIntent.ts","lineNumber":842,"sourceCode":"\t\t}\n\n\t\t// Render the prompt without summarization or cache breakpoints, using\n\t\t// the original endpoint (not reduced for tools/safety buffer).\n\t\tconst renderWithoutSummarization = async (reason: string, renderProps: AgentPromptProps = props): Promise<RenderPromptResult> => {\n\t\t\tthis.logService.debug(`[Agent] ${reason}, rendering without summarization`);\n\t\t\tconst renderer = PromptRenderer.create(this.instantiationService, this.endpoint, this.prompt, {\n\t\t\t\t...renderProps,\n\t\t\t\tendpoint: this.endpoint,\n\t\t\t\tenableSummarization: false,\n\t\t\t\tenableCacheBreakpoints: false\n\t\t\t});\n\t\t\ttry {\n\t\t\t\treturn await renderer.render(progress, token);\n\t\t\t} catch (e) {\n\t\t\t\tif (e instanceof BudgetExceededError) {\n\t\t\t\t\tthis.logService.error(e, `[Agent] fallback render failed due to budget exceeded`);\n\t\t\t\t\tconst maxTokens = this.endpoint.modelMaxPromptTokens;\n\t\t\t\t\tthrow new Error(`Unable to build prompt, modelMaxPromptTokens = ${maxTokens} (${e.message})`);\n\t\t\t\t}\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t};\n\n\t\t// Helper function for synchronous summarization flow with fallbacks\n\t\tconst renderWithSummarization = async (reason: string, renderProps: AgentPromptProps = props): Promise<RenderPromptResult> => {\n\t\t\t// Check if a previous foreground summarization already failed in this\n\t\t\t// turn.  The metadata is set on the turn returned by getLatestTurn(),\n\t\t\t// which is the same turn throughout a single buildPrompt call since\n\t\t\t// the conversation doesn't advance mid-render.\n\t\t\tconst turn = promptContext.conversation?.getLatestTurn();\n\t\t\tconst previousForegroundSummary = turn?.getMetadata(SummarizedConversationHistoryMetadata);\n\t\t\tif (previousForegroundSummary?.source === 'foreground' && previousForegroundSummary.outcome && previousForegroundSummary.outcome !== 'success') {\n\t\t\t\tthis.logService.debug(`[ConversationHistorySummarizer] ${reason}, skipping repeated foreground summarization after prior failure (${previousForegroundSummary.outcome})`);\n\t\t\t\t/* __GDPR__\n\t\t\t\t\t\"triggerSummarizeSkipped\" : {\n\t\t\t\t\t\t\"owner\": \"bhavyau\",","sourceCodeStart":824,"sourceCodeEnd":860,"githubUrl":"https://github.com/microsoft/vscode/blob/a94b963a32aa9749d69504576791fa29700ae46d/extensions/copilot/src/extension/intents/node/agentIntent.ts#L824-L860","documentation":"Error \"Unable to build prompt, modelMaxPromptTokens = ${maxTokens} (${e.message})\" thrown in microsoft/vscode.","triggerScenarios":"Thrown at extensions/copilot/src/extension/intents/node/agentIntent.ts:842 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"a94b963a32aa9749d69504576791fa29700ae46d","analyzedAt":"2026-08-12T01:08:56.794Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}