Skip to content

Commit 51df84e

Browse files
committed
only allow variables tool when there are variables defined
1 parent 77cb447 commit 51df84e

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
@@ -193,6 +193,7 @@ abstract class PositronAssistantParticipant implements IPositronAssistantPartici
193193
// See IChatRuntimeSessionContext for the structure of the active
194194
// session context objects
195195
const activeSessions: Set<string> = new Set();
196+
let hasVariables = false;
196197
let hasConsoleSessions = false;
197198
for (const reference of request.references) {
198199
const value = reference.value as any;
@@ -202,6 +203,9 @@ abstract class PositronAssistantParticipant implements IPositronAssistantPartici
202203
hasConsoleSessions = true;
203204
}
204205
}
206+
if (value.variables && value.variables.length > 0) {
207+
hasVariables = true;
208+
}
205209
}
206210

207211
// List of tools for use by the language model.
@@ -279,8 +283,8 @@ abstract class PositronAssistantParticipant implements IPositronAssistantPartici
279283
return activeSessions.has('python');
280284
case PositronAssistantToolName.GetPlot:
281285
return positronContext.plots?.hasPlots === true;
282-
// case PositronAssistantToolName.InspectVariables:
283-
// TODO: only allow this tool when there are variables to inspect
286+
case PositronAssistantToolName.InspectVariables:
287+
return hasVariables;
284288
// Otherwise, include the tool if it is tagged for use with Positron Assistant.
285289
// Allow all tools in Agent mode.
286290
default:

0 commit comments

Comments
 (0)