@@ -188,21 +188,23 @@ abstract class PositronAssistantParticipant implements IPositronAssistantPartici
188
188
const positronContext = await positron . ai . getPositronChatContext ( request ) ;
189
189
log . debug ( `[context] Positron context for request ${ request . id } :\n${ JSON . stringify ( positronContext , null , 2 ) } ` ) ;
190
190
191
- // Build a list of languages for which we have active sessions.
192
- //
193
191
// See IChatRuntimeSessionContext for the structure of the active
194
192
// session context objects
195
193
const activeSessions : Set < string > = new Set ( ) ;
196
194
let hasVariables = false ;
197
195
let hasConsoleSessions = false ;
198
196
for ( const reference of request . references ) {
199
197
const value = reference . value as any ;
198
+
199
+ // Build a list of languages for which we have active sessions.
200
200
if ( value . activeSession ) {
201
201
activeSessions . add ( value . activeSession . languageId ) ;
202
202
if ( value . activeSession . mode === positron . LanguageRuntimeSessionMode . Console ) {
203
203
hasConsoleSessions = true ;
204
204
}
205
205
}
206
+
207
+ // Check if there are variables defined in the session.
206
208
if ( value . variables && value . variables . length > 0 ) {
207
209
hasVariables = true ;
208
210
}
@@ -281,8 +283,10 @@ abstract class PositronAssistantParticipant implements IPositronAssistantPartici
281
283
// TODO: Remove this restriction when the tool is supported in R https://github.com/posit-dev/positron/issues/8343
282
284
// The logic above with TOOL_TAG_REQUIRES_ACTIVE_SESSION will handle checking for active sessions once this is removed.
283
285
return activeSessions . has ( 'python' ) ;
286
+ // Only include the getPlot tool if there is a plot available.
284
287
case PositronAssistantToolName . GetPlot :
285
288
return positronContext . plots ?. hasPlots === true ;
289
+ // Only include the inspectVariables tool if there are variables defined.
286
290
case PositronAssistantToolName . InspectVariables :
287
291
return hasVariables ;
288
292
// Otherwise, include the tool if it is tagged for use with Positron Assistant.
0 commit comments