Skip to content

Commit 6af7fb0

Browse files
committed
add comments to clarify cases
1 parent c180417 commit 6af7fb0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

extensions/positron-assistant/src/participants.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,21 +199,23 @@ abstract class PositronAssistantParticipant implements IPositronAssistantPartici
199199
const positronContext = await positron.ai.getPositronChatContext(request);
200200
log.debug(`[context] Positron context for request ${request.id}:\n${JSON.stringify(positronContext, null, 2)}`);
201201

202-
// Build a list of languages for which we have active sessions.
203-
//
204202
// See IChatRuntimeSessionContext for the structure of the active
205203
// session context objects
206204
const activeSessions: Set<string> = new Set();
207205
let hasVariables = false;
208206
let hasConsoleSessions = false;
209207
for (const reference of request.references) {
210208
const value = reference.value as any;
209+
210+
// Build a list of languages for which we have active sessions.
211211
if (value.activeSession) {
212212
activeSessions.add(value.activeSession.languageId);
213213
if (value.activeSession.mode === positron.LanguageRuntimeSessionMode.Console) {
214214
hasConsoleSessions = true;
215215
}
216216
}
217+
218+
// Check if there are variables defined in the session.
217219
if (value.variables && value.variables.length > 0) {
218220
hasVariables = true;
219221
}
@@ -292,8 +294,10 @@ abstract class PositronAssistantParticipant implements IPositronAssistantPartici
292294
// TODO: Remove this restriction when the tool is supported in R https://github.com/posit-dev/positron/issues/8343
293295
// The logic above with TOOL_TAG_REQUIRES_ACTIVE_SESSION will handle checking for active sessions once this is removed.
294296
return activeSessions.has('python');
297+
// Only include the getPlot tool if there is a plot available.
295298
case PositronAssistantToolName.GetPlot:
296299
return positronContext.plots?.hasPlots === true;
300+
// Only include the inspectVariables tool if there are variables defined.
297301
case PositronAssistantToolName.InspectVariables:
298302
return hasVariables;
299303
// Otherwise, include the tool if it is tagged for use with Positron Assistant.

0 commit comments

Comments
 (0)