@@ -65,6 +65,7 @@ import { LanguageModelDataPart, LanguageModelPromptTsxPart, LanguageModelTextPar
6565import { ChatAgentLocation } from '../../contrib/chat/common/constants.js' ;
6666import { AiSettingsSearchResult , AiSettingsSearchResultKind } from '../../services/aiSettingsSearch/common/aiSettingsSearch.js' ;
6767import { McpServerLaunch , McpServerTransportType } from '../../contrib/mcp/common/mcpTypes.js' ;
68+ import { ILogService } from '../../../platform/log/common/log.js' ;
6869
6970export namespace Command {
7071
@@ -2903,7 +2904,7 @@ export namespace ChatResponsePart {
29032904}
29042905
29052906export namespace ChatAgentRequest {
2906- export function to ( request : IChatAgentRequest , location2 : vscode . ChatRequestEditorData | vscode . ChatRequestNotebookData | undefined , model : vscode . LanguageModelChat , diagnostics : readonly [ vscode . Uri , readonly vscode . Diagnostic [ ] ] [ ] , toolSelection : vscode . ChatRequestToolSelection | undefined , tools : Map < string , boolean > , extension : IRelaxedExtensionDescription ) : vscode . ChatRequest {
2907+ export function to ( request : IChatAgentRequest , location2 : vscode . ChatRequestEditorData | vscode . ChatRequestNotebookData | undefined , model : vscode . LanguageModelChat , diagnostics : readonly [ vscode . Uri , readonly vscode . Diagnostic [ ] ] [ ] , toolSelection : vscode . ChatRequestToolSelection | undefined , tools : Map < string , boolean > , extension : IRelaxedExtensionDescription , logService : ILogService ) : vscode . ChatRequest {
29072908 const toolReferences = request . variables . variables . filter ( v => v . kind === 'tool' ) ;
29082909 const variableReferences = request . variables . variables . filter ( v => v . kind !== 'tool' ) ;
29092910 const requestWithAllProps : vscode . ChatRequest = {
@@ -2913,7 +2914,9 @@ export namespace ChatAgentRequest {
29132914 attempt : request . attempt ?? 0 ,
29142915 enableCommandDetection : request . enableCommandDetection ?? true ,
29152916 isParticipantDetected : request . isParticipantDetected ?? false ,
2916- references : variableReferences . map ( v => ChatPromptReference . to ( v , diagnostics ) ) ,
2917+ references : variableReferences
2918+ . map ( v => ChatPromptReference . to ( v , diagnostics , logService ) )
2919+ . filter ( isDefined ) ,
29172920 toolReferences : toolReferences . map ( ChatLanguageModelToolReference . to ) ,
29182921 location : ChatLocation . to ( request . location ) ,
29192922 acceptedConfirmationData : request . acceptedConfirmationData ,
@@ -2977,10 +2980,18 @@ export namespace ChatLocation {
29772980}
29782981
29792982export namespace ChatPromptReference {
2980- export function to ( variable : IChatRequestVariableEntry , diagnostics : readonly [ vscode . Uri , readonly vscode . Diagnostic [ ] ] [ ] ) : vscode . ChatPromptReference {
2983+ export function to ( variable : IChatRequestVariableEntry , diagnostics : readonly [ vscode . Uri , readonly vscode . Diagnostic [ ] ] [ ] , logService : ILogService ) : vscode . ChatPromptReference | undefined {
29812984 let value : vscode . ChatPromptReference [ 'value' ] = variable . value ;
29822985 if ( ! value ) {
2983- throw new Error ( 'Invalid value reference' ) ;
2986+ let varStr : string ;
2987+ try {
2988+ varStr = JSON . stringify ( variable ) ;
2989+ } catch {
2990+ varStr = `kind=${ variable . kind } , id=${ variable . id } , name=${ variable . name } ` ;
2991+ }
2992+
2993+ logService . error ( `[ChatPromptReference] Ignoring invalid reference in variable: ${ varStr } ` ) ;
2994+ return undefined ;
29842995 }
29852996
29862997 if ( isUriComponents ( value ) ) {
0 commit comments