@@ -65,6 +65,7 @@ import { LanguageModelDataPart, LanguageModelPromptTsxPart, LanguageModelTextPar
65
65
import { ChatAgentLocation } from '../../contrib/chat/common/constants.js' ;
66
66
import { AiSettingsSearchResult , AiSettingsSearchResultKind } from '../../services/aiSettingsSearch/common/aiSettingsSearch.js' ;
67
67
import { McpServerLaunch , McpServerTransportType } from '../../contrib/mcp/common/mcpTypes.js' ;
68
+ import { ILogService } from '../../../platform/log/common/log.js' ;
68
69
69
70
export namespace Command {
70
71
@@ -2903,7 +2904,7 @@ export namespace ChatResponsePart {
2903
2904
}
2904
2905
2905
2906
export 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 {
2907
2908
const toolReferences = request . variables . variables . filter ( v => v . kind === 'tool' ) ;
2908
2909
const variableReferences = request . variables . variables . filter ( v => v . kind !== 'tool' ) ;
2909
2910
const requestWithAllProps : vscode . ChatRequest = {
@@ -2913,7 +2914,9 @@ export namespace ChatAgentRequest {
2913
2914
attempt : request . attempt ?? 0 ,
2914
2915
enableCommandDetection : request . enableCommandDetection ?? true ,
2915
2916
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 ) ,
2917
2920
toolReferences : toolReferences . map ( ChatLanguageModelToolReference . to ) ,
2918
2921
location : ChatLocation . to ( request . location ) ,
2919
2922
acceptedConfirmationData : request . acceptedConfirmationData ,
@@ -2977,10 +2980,18 @@ export namespace ChatLocation {
2977
2980
}
2978
2981
2979
2982
export 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 {
2981
2984
let value : vscode . ChatPromptReference [ 'value' ] = variable . value ;
2982
2985
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 ;
2984
2995
}
2985
2996
2986
2997
if ( isUriComponents ( value ) ) {
0 commit comments