Skip to content

Commit 880a298

Browse files
committed
Support reasoning effort for Copilot CLI
1 parent 6026a18 commit 880a298

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

src/extension/chatSessions/copilotcli/node/copilotCli.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import type { SessionOptions, SweCustomAgent } from '@github/copilot/sdk';
7+
import * as l10n from '@vscode/l10n';
78
import { promises as fs } from 'fs';
89
import * as path from 'path';
910
import type * as vscode from 'vscode';
@@ -44,6 +45,9 @@ export interface CopilotCLIModelInfo {
4445
readonly maxOutputTokens?: number;
4546
readonly maxContextWindowTokens: number;
4647
readonly supportsVision?: boolean;
48+
readonly supportsReasoningEffort?: boolean;
49+
readonly defaultReasoningEffort?: string;
50+
readonly supportedReasoningEfforts?: string[];
4751
}
4852

4953
export interface ICopilotCLIModels {
@@ -124,6 +128,9 @@ export class CopilotCLIModels extends Disposable implements ICopilotCLIModels {
124128
maxOutputTokens: model.capabilities.limits.max_output_tokens,
125129
maxContextWindowTokens: model.capabilities.limits.max_context_window_tokens,
126130
supportsVision: model.capabilities.supports.vision,
131+
supportsReasoningEffort: model.capabilities.supports.reasoningEffort,
132+
defaultReasoningEffort: model.defaultReasoningEffort,
133+
supportedReasoningEfforts: model.supportedReasoningEfforts
127134
} satisfies CopilotCLIModelInfo));
128135
} catch (ex) {
129136
this.logService.error(`[CopilotCLISession] Failed to fetch models`, ex);
@@ -164,9 +171,10 @@ export class CopilotCLIModels extends Disposable implements ICopilotCLIModels {
164171
multiplier,
165172
multiplierNumeric: model.multiplier,
166173
isUserSelectable: true,
174+
configurationSchema: buildConfigurationSchema(model),
167175
capabilities: {
168176
imageInput: model.supportsVision,
169-
toolCalling: true
177+
toolCalling: true,
170178
},
171179
targetChatSessionType: 'copilotcli',
172180
isDefault: index === 0 // SDK guarantees the first item is the default model
@@ -175,6 +183,38 @@ export class CopilotCLIModels extends Disposable implements ICopilotCLIModels {
175183
}
176184
}
177185

186+
function buildConfigurationSchema(modelInfo: CopilotCLIModelInfo): vscode.LanguageModelConfigurationSchema | undefined {
187+
const effortLevels = modelInfo.supportedReasoningEfforts ?? [];
188+
if (!effortLevels || effortLevels.length === 0) {
189+
return;
190+
}
191+
192+
const defaultEffort = modelInfo.defaultReasoningEffort;
193+
194+
return {
195+
properties: {
196+
reasoningEffort: {
197+
type: 'string',
198+
title: l10n.t('Thinking Effort'),
199+
enum: effortLevels,
200+
enumItemLabels: effortLevels.map(level => level.charAt(0).toUpperCase() + level.slice(1)),
201+
enumDescriptions: effortLevels.map(level => {
202+
switch (level) {
203+
case 'none': return l10n.t('No reasoning applied');
204+
case 'low': return l10n.t('Faster responses with less reasoning');
205+
case 'medium': return l10n.t('Balanced reasoning and speed');
206+
case 'high': return l10n.t('Greater reasoning depth but slower');
207+
case 'xhigh': return l10n.t('Maximum reasoning depth but slower');
208+
default: return level;
209+
}
210+
}),
211+
default: defaultEffort,
212+
group: 'navigation',
213+
}
214+
}
215+
};
216+
}
217+
178218
export interface ICopilotCLIAgents {
179219
readonly _serviceBrand: undefined;
180220
readonly onDidChangeAgents: Event<void>;

0 commit comments

Comments
 (0)