Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { BasePromptElementProps, PromptElement, PromptSizing } from '@vscode/prompt-tsx';
import type { LanguageModelToolInformation } from 'vscode';
import { ConfigKey, IConfigurationService } from '../../../../platform/configuration/common/configurationService';
import { isGpt5PlusFamily } from '../../../../platform/endpoint/common/chatModelCapabilities';
import { isGpt5PlusFamily, isHiddenModelN } from '../../../../platform/endpoint/common/chatModelCapabilities';
import { IChatEndpoint } from '../../../../platform/networking/common/networking';
import { IPromptPathRepresentationService } from '../../../../platform/prompts/common/promptPathRepresentationService';
import { IExperimentationService } from '../../../../platform/telemetry/common/nullExperimentationService';
Expand Down Expand Up @@ -480,12 +480,12 @@ export class ApplyPatchInstructions extends PromptElement<DefaultAgentPromptProp
}

async render(state: void, sizing: PromptSizing) {
const isGpt5 = isGpt5PlusFamily(this.props.modelFamily);
const useSimpleInstructions = isGpt5 && this.configurationService.getExperimentBasedConfig(ConfigKey.Advanced.Gpt5AlternativePatch, this._experimentationService);
const isGpt5OrHiddenModelN = isGpt5PlusFamily(this.props.modelFamily) || (this.props.modelFamily !== undefined && isHiddenModelN(this.props.modelFamily));
const useSimpleInstructions = isGpt5OrHiddenModelN && this.configurationService.getExperimentBasedConfig(ConfigKey.Advanced.Gpt5AlternativePatch, this._experimentationService);

return <Tag name='applyPatchInstructions'>
To edit files in the workspace, use the {ToolName.ApplyPatch} tool. If you have issues with it, you should first try to fix your patch and continue using {ToolName.ApplyPatch}. {this.props.tools[ToolName.EditFile] && <>If you are stuck, you can fall back on the {ToolName.EditFile} tool, but {ToolName.ApplyPatch} is much faster and is the preferred tool.</>}<br />
{isGpt5 && <>Prefer the smallest set of changes needed to satisfy the task. Avoid reformatting unrelated code; preserve existing style and public APIs unless the task requires changes. When practical, complete all edits for a file within a single message.<br /></>}
{isGpt5OrHiddenModelN && <>Prefer the smallest set of changes needed to satisfy the task. Avoid reformatting unrelated code; preserve existing style and public APIs unless the task requires changes. When practical, complete all edits for a file within a single message.<br /></>}
{!useSimpleInstructions && <>
The tool call requires both `input`, a string representing the patch to apply, and `explanation`, a short description of what the patch aims to achieve. The input follows a special format. For each snippet of code that needs to be changed, repeat the following:<br />
<ApplyPatchFormatInstructions /><br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import type * as vscode from 'vscode';
import { isGpt5PlusFamily } from '../../../platform/endpoint/common/chatModelCapabilities';
import { isGpt5PlusFamily, isHiddenModelN } from '../../../platform/endpoint/common/chatModelCapabilities';
import { IChatEndpoint } from '../../../platform/networking/common/networking';
import { ToolName } from '../common/toolNames';
import { ICopilotTool, ToolRegistry } from '../common/toolsRegistry';
Expand All @@ -17,7 +17,7 @@ class ManageTodoListTool implements ICopilotTool<unknown> {
public static readonly nonDeferred = true;

alternativeDefinition(tool: vscode.LanguageModelToolInformation, endpoint?: IChatEndpoint): vscode.LanguageModelToolInformation {
if (!isGpt5PlusFamily(endpoint)) {
if (!isGpt5PlusFamily(endpoint) && (!endpoint || !isHiddenModelN(endpoint))) {
return tool;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export function modelCanUseApplyPatchExclusively(model: LanguageModelChat | ICha
if (isVSCModelReplaceStringSet(model)) {
return false;
}
return isGpt5PlusFamily(model) || isVSCModelA(model) || isVSCModelB(model);
return isGpt5PlusFamily(model) || isHiddenModelN(model) || isVSCModelA(model) || isVSCModelB(model);
}

/**
Expand All @@ -378,7 +378,7 @@ export function modelNeedsStrongReplaceStringHint(model: LanguageModelChat | ICh
* Model can take the simple, modern apply_patch instructions.
*/
export function modelSupportsSimplifiedApplyPatchInstructions(model: LanguageModelChat | IChatEndpoint): boolean {
return isGpt5PlusFamily(model) || isVSCModelA(model) || isVSCModelB(model);
return isGpt5PlusFamily(model) || isHiddenModelN(model) || isVSCModelA(model) || isVSCModelB(model);
}

export function isAnthropicFamily(model: LanguageModelChat | IChatEndpoint): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ConfigKey, IConfigurationService } from '../../../configuration/common/
import { DefaultsOnlyConfigurationService } from '../../../configuration/common/defaultsOnlyConfigurationService';
import { InMemoryConfigurationService } from '../../../configuration/test/common/inMemoryConfigurationService';
import type { IChatEndpoint } from '../../../networking/common/networking';
import { getModelCapabilityOverride, getVerbosityForModelSync, isGpt51Family, isGpt53Codex, isGpt54, isGpt55, isGpt56, isHiddenModelN, isKimiFamily, isOpenAIModel, modelCanUseApplyPatchExclusively, modelCanUseReplaceStringExclusively, modelPrefersJsonNotebookRepresentation, modelSupportCacheBreakPoints, modelSupportsApplyPatch, modelSupportsContextEditing, modelSupportsMultiReplaceString, modelSupportsPDFDocuments, modelSupportsReplaceString, modelSupportsToolSearch } from '../../common/chatModelCapabilities';
import { getModelCapabilityOverride, getVerbosityForModelSync, isGpt51Family, isGpt53Codex, isGpt54, isGpt55, isGpt56, isHiddenModelN, isKimiFamily, isOpenAIModel, modelCanUseApplyPatchExclusively, modelCanUseReplaceStringExclusively, modelPrefersJsonNotebookRepresentation, modelSupportCacheBreakPoints, modelSupportsApplyPatch, modelSupportsContextEditing, modelSupportsMultiReplaceString, modelSupportsPDFDocuments, modelSupportsReplaceString, modelSupportsSimplifiedApplyPatchInstructions, modelSupportsToolSearch } from '../../common/chatModelCapabilities';

function fakeModel(family: string, model: string = family) {
return { family, model } as unknown as IChatEndpoint;
Expand Down Expand Up @@ -65,6 +65,8 @@ describe('Hidden model N capabilities', () => {
isHidden: isHiddenModelN(model),
isGpt56: isGpt56(model),
applyPatch: modelSupportsApplyPatch(model),
applyPatchExclusively: modelCanUseApplyPatchExclusively(model),
simplifiedApplyPatchInstructions: modelSupportsSimplifiedApplyPatchInstructions(model),
jsonNotebook: modelPrefersJsonNotebookRepresentation(model),
pdf: modelSupportsPDFDocuments(model),
cacheBreakpoints: modelSupportCacheBreakPoints(model),
Expand All @@ -75,6 +77,8 @@ describe('Hidden model N capabilities', () => {
isHidden: true,
isGpt56: false,
applyPatch: true,
applyPatchExclusively: true,
simplifiedApplyPatchInstructions: true,
jsonNotebook: true,
pdf: true,
cacheBreakpoints: true,
Expand Down
Loading
Loading