Skip to content

Commit 893cf4d

Browse files
authored
add Claude Sonnet 4.5 prompt and configuration support (#1218)
1 parent f24cd1a commit 893cf4d

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,6 +3076,14 @@
30763076
],
30773077
"description": "%github.copilot.config.grokCodeAlternatePrompt%"
30783078
},
3079+
"github.copilot.chat.claudeSonnet45AlternatePrompt": {
3080+
"type": "string",
3081+
"default": "default",
3082+
"tags": [
3083+
"experimental"
3084+
],
3085+
"description": "%github.copilot.config.claudeSonnet45AlternatePrompt%"
3086+
},
30793087
"github.copilot.chat.useResponsesApi": {
30803088
"type": "boolean",
30813089
"default": false,

src/extension/prompts/node/agent/agentInstructions.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,41 @@ export class SweBenchAgentPrompt extends PromptElement<DefaultAgentPromptProps>
10261026
}
10271027
}
10281028

1029+
/**
1030+
* Minimal v2 prompt for Claude Sonnet 4.5
1031+
*/
1032+
export class ClaudeSonnet45PromptV2 extends PromptElement<DefaultAgentPromptProps> {
1033+
async render(state: void, sizing: PromptSizing) {
1034+
const tools = detectToolCapabilities(this.props.availableTools);
1035+
1036+
return <InstructionMessage>
1037+
<Tag name='instructions'>
1038+
You are a highly sophisticated automated coding agent with expert-level knowledge across many different programming languages and frameworks.<br />
1039+
The user will ask a question, or ask you to perform a task, and it may require lots of research to answer correctly. There is a selection of tools that let you perform actions or retrieve helpful context to answer the user's question.<br />
1040+
</Tag>
1041+
<Tag name='outputFormatting'>
1042+
Use proper Markdown formatting in your answers. When referring to a filename or symbol in the user's workspace, wrap it in backticks.<br />
1043+
{tools[ToolName.CoreRunInTerminal] ? <>
1044+
When commands are required, run them yourself in a terminal and summarize the results. Do not print runnable commands unless the user asks. If you must show them for documentation, make them clearly optional and keep one command per line.<br />
1045+
</> : <>
1046+
When sharing setup or run steps for the user to execute, render commands in fenced code blocks with an appropriate language tag (`bash`, `sh`, `powershell`, `python`, etc.). Keep one command per line; avoid prose-only representations of commands.<br />
1047+
</>}
1048+
Keep responses conversational and fun—use a brief, friendly preamble that acknowledges the goal and states what you're about to do next. Do NOT include literal scaffold labels like "Plan", "Answer", "Acknowledged", "Task receipt", or "Actions", "Goal" ; instead, use short paragraphs and, when helpful, concise bullet lists. Do not start with filler acknowledgements (e.g., "Sounds good", "Great", "Okay, I will…"). For multi-step tasks, maintain a lightweight checklist implicitly and weave progress into your narration.<br />
1049+
For section headers in your response, use level-2 Markdown headings (`##`) for top-level sections and level-3 (`###`) for subsections. Choose titles dynamically to match the task and content. Do not hard-code fixed section names; create only the sections that make sense and only when they have non-empty content. Keep headings short and descriptive (e.g., "actions taken", "files changed", "how to run", "performance", "notes"), and order them naturally (actions &gt; artifacts &gt; how to run &gt; performance &gt; notes) when applicable. You may add a tasteful emoji to a heading when it improves scannability; keep it minimal and professional. Headings must start at the beginning of the line with `## ` or `### `, have a blank line before and after, and must not be inside lists, block quotes, or code fences.<br />
1050+
When listing files created/edited, include a one-line purpose for each file when helpful. In performance sections, base any metrics on actual runs from this session; note the hardware/OS context and mark estimates clearly—never fabricate numbers. In "Try it" sections, keep commands copyable; comments starting with `#` are okay, but put each command on its own line.<br />
1051+
If platform-specific acceleration applies, include an optional speed-up fenced block with commands. Close with a concise completion summary describing what changed and how it was verified (build/tests/linters), plus any follow-ups.<br />
1052+
<Tag name='example'>
1053+
The class `Person` is in `src/models/person.ts`.<br />
1054+
The function `calculateTotal` is defined in `lib/utils/math.ts`.<br />
1055+
You can find the configuration in `config/app.config.json`.
1056+
</Tag>
1057+
<MathIntegrationRules />
1058+
</Tag>
1059+
<ResponseTranslationRules />
1060+
</InstructionMessage>;
1061+
}
1062+
}
1063+
10291064
export class ApplyPatchFormatInstructions extends PromptElement {
10301065
render() {
10311066
return <>

src/extension/prompts/node/agent/agentPrompt.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { UserPreferences } from '../panel/preferences';
4545
import { ChatToolCalls } from '../panel/toolCalling';
4646
import { MultirootWorkspaceStructure } from '../panel/workspace/workspaceStructure';
4747
import { AgentConversationHistory } from './agentConversationHistory';
48-
import { AlternateGPTPrompt, CodexStyleGPT5CodexPrompt, CodexStyleGPTPrompt, DefaultAgentPrompt, DefaultAgentPromptV2, SweBenchAgentPrompt } from './agentInstructions';
48+
import { AlternateGPTPrompt, ClaudeSonnet45PromptV2, CodexStyleGPT5CodexPrompt, CodexStyleGPTPrompt, DefaultAgentPrompt, DefaultAgentPromptV2, SweBenchAgentPrompt } from './agentInstructions';
4949
import { SummarizedConversationHistory } from './summarizedConversationHistory';
5050

5151
export interface AgentPromptProps extends GenericBasePromptElementProps {
@@ -204,6 +204,24 @@ export class AgentPrompt extends PromptElement<AgentPromptProps> {
204204
}
205205
}
206206

207+
if (this.props.endpoint.family.startsWith('claude-sonnet-4.5')) {
208+
const promptType = this.configurationService.getExperimentBasedConfig(ConfigKey.ClaudeSonnet45AlternatePrompt, this.experimentationService);
209+
switch (promptType) {
210+
case 'v2':
211+
return <ClaudeSonnet45PromptV2
212+
availableTools={this.props.promptContext.tools?.availableTools}
213+
modelFamily={this.props.endpoint.family}
214+
codesearchMode={this.props.codesearchMode}
215+
/>;
216+
default:
217+
return <DefaultAgentPrompt
218+
availableTools={this.props.promptContext.tools?.availableTools}
219+
modelFamily={this.props.endpoint.family}
220+
codesearchMode={this.props.codesearchMode}
221+
/>;
222+
}
223+
}
224+
207225
if (this.props.endpoint.family.startsWith('gpt-') && this.configurationService.getExperimentBasedConfig(ConfigKey.EnableAlternateGptPrompt, this.experimentationService)) {
208226
return <AlternateGPTPrompt
209227
availableTools={this.props.promptContext.tools?.availableTools}

src/platform/configuration/common/configurationService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ export namespace ConfigKey {
808808
export const Gpt5AlternatePrompt = defineExpSetting<string>('chat.gpt5AlternatePrompt', 'default');
809809
export const Gpt5CodexAlternatePrompt = defineExpSetting<'default' | 'codex'>('chat.gpt5CodexAlternatePrompt', 'codex');
810810
export const GrokCodeAlternatePrompt = defineExpSetting<string>('chat.grokCodeAlternatePrompt', 'default');
811+
export const ClaudeSonnet45AlternatePrompt = defineExpSetting<string>('chat.claudeSonnet45AlternatePrompt', 'default');
811812
export const ExecutePromptEnabled = defineSetting<boolean>('chat.executePrompt.enabled', false);
812813
}
813814

0 commit comments

Comments
 (0)