@@ -199,21 +199,23 @@ abstract class PositronAssistantParticipant implements IPositronAssistantPartici
199
199
const positronContext = await positron . ai . getPositronChatContext ( request ) ;
200
200
log . debug ( `[context] Positron context for request ${ request . id } :\n${ JSON . stringify ( positronContext , null , 2 ) } ` ) ;
201
201
202
- // Build a list of languages for which we have active sessions.
203
- //
204
202
// See IChatRuntimeSessionContext for the structure of the active
205
203
// session context objects
206
204
const activeSessions : Set < string > = new Set ( ) ;
207
205
let hasVariables = false ;
208
206
let hasConsoleSessions = false ;
209
207
for ( const reference of request . references ) {
210
208
const value = reference . value as any ;
209
+
210
+ // Build a list of languages for which we have active sessions.
211
211
if ( value . activeSession ) {
212
212
activeSessions . add ( value . activeSession . languageId ) ;
213
213
if ( value . activeSession . mode === positron . LanguageRuntimeSessionMode . Console ) {
214
214
hasConsoleSessions = true ;
215
215
}
216
216
}
217
+
218
+ // Check if there are variables defined in the session.
217
219
if ( value . variables && value . variables . length > 0 ) {
218
220
hasVariables = true ;
219
221
}
@@ -292,8 +294,10 @@ abstract class PositronAssistantParticipant implements IPositronAssistantPartici
292
294
// TODO: Remove this restriction when the tool is supported in R https://github.com/posit-dev/positron/issues/8343
293
295
// The logic above with TOOL_TAG_REQUIRES_ACTIVE_SESSION will handle checking for active sessions once this is removed.
294
296
return activeSessions . has ( 'python' ) ;
297
+ // Only include the getPlot tool if there is a plot available.
295
298
case PositronAssistantToolName . GetPlot :
296
299
return positronContext . plots ?. hasPlots === true ;
300
+ // Only include the inspectVariables tool if there are variables defined.
297
301
case PositronAssistantToolName . InspectVariables :
298
302
return hasVariables ;
299
303
// Otherwise, include the tool if it is tagged for use with Positron Assistant.
0 commit comments