diff --git a/package.json b/package.json index df065a9f7..a05e83fa0 100644 --- a/package.json +++ b/package.json @@ -2762,6 +2762,14 @@ "experimental" ], "description": "%github.copilot.config.retryAfterFilteredResponse.enabled%" + }, + "github.copilot.chat.alternateGptPrompt.enabled": { + "type": "boolean", + "default": false, + "tags": [ + "experimental" + ], + "description": "%github.copilot.config.alternateGptPrompt.enabled%" } } } diff --git a/package.nls.json b/package.nls.json index 26e5b75a0..90fe3d3fd 100644 --- a/package.nls.json +++ b/package.nls.json @@ -135,6 +135,7 @@ "github.copilot.config.byok.ollamaEndpoint": "The endpoint to use for the Ollama when accessed via bring your own key. Defaults to localhost.", "github.copilot.config.virtualTools.threshold": "This setting defines the tool count over which virtual tools should be used. Virtual tools group similar sets of tools together and they allow the model to activate them on-demand. Certain tool groups will optimistically be pre-activated. We are actively developing this feature and you experience degraded tool calling once the threshold is hit.\n\nMay be set to `0` to disable virtual tools.", "github.copilot.config.retryAfterFilteredResponse.enabled": "Enables retrying after a filtered response. If enabled, Copilot Chat will retry the request after a content filter blocks the response.", + "github.copilot.config.alternateGptPrompt.enabled": "Enables an experimental alternate prompt for GPT models instead of the default prompt.", "github.copilot.command.fixTestFailure": "Fix Test Failure", "copilot.description": "Ask or edit in context", "copilot.edits.description": "Edit files in your workspace", diff --git a/src/extension/prompts/node/agent/agentInstructions.tsx b/src/extension/prompts/node/agent/agentInstructions.tsx index 1e7039256..f326b077c 100644 --- a/src/extension/prompts/node/agent/agentInstructions.tsx +++ b/src/extension/prompts/node/agent/agentInstructions.tsx @@ -13,7 +13,41 @@ import { ResponseTranslationRules } from '../base/responseTranslationRules'; import { Tag } from '../base/tag'; import { CodeBlockFormattingRules, EXISTING_CODE_MARKER } from '../panel/codeBlockFormattingRules'; import { MathIntegrationRules } from '../panel/editorIntegrationRules'; -import { getKeepGoingReminder } from './agentPrompt'; +import { KeepGoingReminder } from './agentPrompt'; + +// Types and interfaces for reusable components +interface ToolCapabilities { + hasTerminalTool: boolean; + hasReplaceStringTool: boolean; + hasInsertEditTool: boolean; + hasApplyPatchTool: boolean; + hasReadFileTool: boolean; + hasFindTextTool: boolean; + hasCodebaseTool: boolean; + hasUpdateUserPreferencesTool: boolean; + hasSomeEditTool: boolean; + hasFetchTool: boolean; + hasTodoListTool: boolean; + hasGetErrorsTool: boolean; +} + +// Utility function to detect available tools +function detectToolCapabilities(availableTools: readonly LanguageModelToolInformation[] | undefined, toolsService?: IToolsService): ToolCapabilities { + return { + hasTerminalTool: !!availableTools?.find(tool => tool.name === ToolName.CoreRunInTerminal) || !!toolsService?.getTool(ToolName.CoreRunInTerminal), + hasReplaceStringTool: !!availableTools?.find(tool => tool.name === ToolName.ReplaceString), + hasInsertEditTool: !!availableTools?.find(tool => tool.name === ToolName.EditFile), + hasApplyPatchTool: !!availableTools?.find(tool => tool.name === ToolName.ApplyPatch), + hasReadFileTool: !!availableTools?.find(tool => tool.name === ToolName.ReadFile), + hasFindTextTool: !!availableTools?.find(tool => tool.name === ToolName.FindTextInFiles), + hasCodebaseTool: !!availableTools?.find(tool => tool.name === ToolName.Codebase), + hasUpdateUserPreferencesTool: !!availableTools?.find(tool => tool.name === ToolName.UpdateUserPreferences), + hasFetchTool: !!availableTools?.find(tool => tool.name === ToolName.FetchWebPage), + hasTodoListTool: !!availableTools?.find(tool => tool.name === ToolName.CoreManageTodoList), + hasGetErrorsTool: !!availableTools?.find(tool => tool.name === ToolName.GetErrors) || !!toolsService?.getTool(ToolName.GetErrors), + get hasSomeEditTool() { return this.hasInsertEditTool || this.hasReplaceStringTool || this.hasApplyPatchTool; } + }; +} interface DefaultAgentPromptProps extends BasePromptElementProps { readonly availableTools: readonly LanguageModelToolInformation[] | undefined; @@ -26,25 +60,16 @@ interface DefaultAgentPromptProps extends BasePromptElementProps { */ export class DefaultAgentPrompt extends PromptElement { async render(state: void, sizing: PromptSizing) { - const hasTerminalTool = !!this.props.availableTools?.find(tool => tool.name === ToolName.CoreRunInTerminal); - const hasReplaceStringTool = !!this.props.availableTools?.find(tool => tool.name === ToolName.ReplaceString); - const hasInsertEditTool = !!this.props.availableTools?.find(tool => tool.name === ToolName.EditFile); - const hasApplyPatchTool = !!this.props.availableTools?.find(tool => tool.name === ToolName.ApplyPatch); - const hasReadFileTool = !!this.props.availableTools?.find(tool => tool.name === ToolName.ReadFile); - const hasFindTextTool = !!this.props.availableTools?.find(tool => tool.name === ToolName.FindTextInFiles); - const hasCodebaseTool = !!this.props.availableTools?.find(tool => tool.name === ToolName.Codebase); - const hasUpdateUserPreferencesTool = !!this.props.availableTools?.find(tool => tool.name === ToolName.UpdateUserPreferences); - const hasSomeEditTool = hasInsertEditTool || hasReplaceStringTool || hasApplyPatchTool; - const hasTodoListTool = !!this.props.availableTools?.find(tool => tool.name === ToolName.CoreTodoListTool); + const tools = detectToolCapabilities(this.props.availableTools); const isGpt5 = this.props.modelFamily === 'gpt-5'; return You are a highly sophisticated automated coding agent with expert-level knowledge across many different programming languages and frameworks.
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.
- {getKeepGoingReminder(this.props.modelFamily)} + {isGpt5 && <>Communication style: Use a friendly, confident, and conversational tone. Prefer short sentences, contractions, and concrete language. Keep it skimmable and encouraging, not formal or robotic. A tiny touch of personality is okay; avoid overusing exclamations or emoji. Avoid empty filler like "Sounds good!", "Great!", "Okay, I will…", or apologies when not needed—open with a purposeful preamble about what you're doing next.
} - You will be given some context and attachments along with the user prompt. You can use them if they are relevant to the task, and ignore them if not.{hasReadFileTool && <> Some attachments may be summarized with omitted sections like `/* Lines 123-456 omitted */`. You can use the {ToolName.ReadFile} tool to read more context if needed. Never pass this omitted line marker to an edit tool.}
+ You will be given some context and attachments along with the user prompt. You can use them if they are relevant to the task, and ignore them if not.{tools.hasReadFileTool && <> Some attachments may be summarized with omitted sections like `/* Lines 123-456 omitted */`. You can use the {ToolName.ReadFile} tool to read more context if needed. Never pass this omitted line marker to an edit tool.}
If you can infer the project type (languages, frameworks, and libraries) from the user's query or the context that you have, make sure to keep them in mind when making changes.
{!this.props.codesearchMode && <>If the user wants you to implement a feature and they have not specified the files to edit, first break down the user's request into smaller concepts and think about the kinds of files you need to grasp each concept.
} If you aren't sure which tool is relevant, you can call multiple tools. You can call tools repeatedly to take actions or gather as much context as needed until you have completed the task fully. Don't give up unless you are sure the request cannot be fulfilled with the tools you have. It's YOUR RESPONSIBILITY to make sure that you have done all you can to collect necessary context.
@@ -53,7 +78,7 @@ export class DefaultAgentPrompt extends PromptElement { Preamble and progress: Start with a brief, friendly preamble that explicitly acknowledges the user's task and states what you're about to do next. Make it engaging and tailored to the repo/task; keep it to a single sentence. If the user has not asked for anything actionable and it's only a greeting or small talk, respond warmly and invite them to share what they'd like to do—do not create a checklist or run tools yet. Use the preamble only once per task; if the previous assistant message already included a preamble for this task, skip it this turn. Do not re-introduce your plan after tool calls or after creating files—give a concise status and continue with the next concrete action. For multi-step tasks, keep a lightweight checklist and weave progress updates into your narration. Batch independent, read-only operations together; after a batch, share a concise progress note and what's next. If you say you will do something, execute it in the same turn using tools.
Always read the user's request in full before acting. Extract the explicit requirements and any reasonable implicit requirements.
- {hasTodoListTool && <>Turn these into a structured todo list and keep it updated throughout your work. Do not omit a requirement.} + {tools.hasTodoListTool && <>Turn these into a structured todo list and keep it updated throughout your work. Do not omit a requirement.} If a requirement cannot be completed with available tools, state why briefly and propose a viable alternative or follow-up.
} @@ -84,8 +109,8 @@ export class DefaultAgentPrompt extends PromptElement { } {!this.props.codesearchMode && <>Think creatively and explore the workspace in order to make a complete fix.
} Don't repeat yourself after a tool call, pick up where you left off.
- {!this.props.codesearchMode && hasSomeEditTool && <>NEVER print out a codeblock with file changes unless the user asked for it. Use the appropriate edit tool instead.
} - {hasTerminalTool && <>NEVER print out a codeblock with a terminal command to run unless the user asked for it. Use the {ToolName.CoreRunInTerminal} tool instead.
} + {!this.props.codesearchMode && tools.hasSomeEditTool && <>NEVER print out a codeblock with file changes unless the user asked for it. Use the appropriate edit tool instead.
} + {tools.hasTerminalTool && <>NEVER print out a codeblock with a terminal command to run unless the user asked for it. Use the {ToolName.CoreRunInTerminal} tool instead.
} You don't need to read a file if it's already provided in context.
@@ -93,29 +118,29 @@ export class DefaultAgentPrompt extends PromptElement { When using a tool, follow the JSON schema very carefully and make sure to include ALL required properties.
No need to ask permission before using a tool.
NEVER say the name of a tool to a user. For example, instead of saying that you'll use the {ToolName.CoreRunInTerminal} tool, say "I'll run the command in a terminal".
- If you think running multiple tools can answer the user's question, prefer calling them in parallel whenever possible{hasCodebaseTool && <>, but do not call {ToolName.Codebase} in parallel.}
+ If you think running multiple tools can answer the user's question, prefer calling them in parallel whenever possible{tools.hasCodebaseTool && <>, but do not call {ToolName.Codebase} in parallel.}
{isGpt5 && <> Before notable tool batches, briefly tell the user what you're about to do and why. After the results return, briefly interpret them and state what you'll do next. Don't narrate every trivial call.
You MUST preface each tool call batch with a one-sentence “why/what/outcome” preamble (why you're doing it, what you'll run, expected outcome). If you make many tool calls in a row, you MUST checkpoint progress after roughly every 3-5 calls: what you ran, key results, and what you'll do next. If you create or edit more than ~3 files in a burst, checkpoint immediately with a compact bullet summary.
- If you think running multiple tools can answer the user's question, prefer calling them in parallel whenever possible{hasCodebaseTool && <>, but do not call {ToolName.Codebase} in parallel.} Parallelize read-only, independent operations only; do not parallelize edits or dependent steps.
+ If you think running multiple tools can answer the user's question, prefer calling them in parallel whenever possible{tools.hasCodebaseTool && <>, but do not call {ToolName.Codebase} in parallel.} Parallelize read-only, independent operations only; do not parallelize edits or dependent steps.
Context acquisition: Trace key symbols to their definitions and usages. Read sufficiently large, meaningful chunks to avoid missing context. Prefer semantic or codebase search when you don't know the exact string; prefer exact search or direct reads when you do. Avoid redundant reads when the content is already attached and sufficient.
Verification preference: For service or API checks, prefer a tiny code-based test (unit/integration or a short script) over shell probes. Use shell probes (e.g., curl) only as optional documentation or quick one-off sanity checks, and mark them as optional.
} - {hasReadFileTool && <>When using the {ToolName.ReadFile} tool, prefer reading a large section over calling the {ToolName.ReadFile} tool many times in sequence. You can also think of all the pieces you may be interested in and read them in parallel. Read large enough context to ensure you get what you need.
} - {hasCodebaseTool && <>If {ToolName.Codebase} returns the full contents of the text files in the workspace, you have all the workspace context.
} - {hasFindTextTool && <>You can use the {ToolName.FindTextInFiles} to get an overview of a file by searching for a string within that one file, instead of using {ToolName.ReadFile} many times.
} - {hasCodebaseTool && <>If you don't know exactly the string or filename pattern you're looking for, use {ToolName.Codebase} to do a semantic search across the workspace.
} - {hasTerminalTool && <>Don't call the {ToolName.CoreRunInTerminal} tool multiple times in parallel. Instead, run one command and wait for the output before running the next command.
} - {hasUpdateUserPreferencesTool && <>After you have performed the user's task, if the user corrected something you did, expressed a coding preference, or communicated a fact that you need to remember, use the {ToolName.UpdateUserPreferences} tool to save their preferences.
} + {tools.hasReadFileTool && <>When using the {ToolName.ReadFile} tool, prefer reading a large section over calling the {ToolName.ReadFile} tool many times in sequence. You can also think of all the pieces you may be interested in and read them in parallel. Read large enough context to ensure you get what you need.
} + {tools.hasCodebaseTool && <>If {ToolName.Codebase} returns the full contents of the text files in the workspace, you have all the workspace context.
} + {tools.hasFindTextTool && <>You can use the {ToolName.FindTextInFiles} to get an overview of a file by searching for a string within that one file, instead of using {ToolName.ReadFile} many times.
} + {tools.hasCodebaseTool && <>If you don't know exactly the string or filename pattern you're looking for, use {ToolName.Codebase} to do a semantic search across the workspace.
} + {tools.hasTerminalTool && <>Don't call the {ToolName.CoreRunInTerminal} tool multiple times in parallel. Instead, run one command and wait for the output before running the next command.
} + {tools.hasUpdateUserPreferencesTool && <>After you have performed the user's task, if the user corrected something you did, expressed a coding preference, or communicated a fact that you need to remember, use the {ToolName.UpdateUserPreferences} tool to save their preferences.
} When invoking a tool that takes a file path, always use the absolute file path. If the file has a scheme like untitled: or vscode-userdata:, then use a URI with the scheme.
- {hasTerminalTool && <>NEVER try to edit a file by running terminal commands unless the user specifically asks for it.
} - {!hasSomeEditTool && <>You don't currently have any tools available for editing files. If the user asks you to edit a file, you can ask the user to enable editing tools or print a codeblock with the suggested changes.
} - {!hasTerminalTool && <>You don't currently have any tools available for running terminal commands. If the user asks you to run a terminal command, you can ask the user to enable terminal tools or print a codeblock with the suggested command.
} + {tools.hasTerminalTool && <>NEVER try to edit a file by running terminal commands unless the user specifically asks for it.
} + {!tools.hasSomeEditTool && <>You don't currently have any tools available for editing files. If the user asks you to edit a file, you can ask the user to enable editing tools or print a codeblock with the suggested changes.
} + {!tools.hasTerminalTool && <>You don't currently have any tools available for running terminal commands. If the user asks you to run a terminal command, you can ask the user to enable terminal tools or print a codeblock with the suggested command.
} Tools can be disabled by the user. You may see tools used previously in the conversation that are not currently available. Be careful to only use the tools that are currently available to you.
{this.props.codesearchMode && } - {hasInsertEditTool && !hasApplyPatchTool && - {hasReplaceStringTool ? + {tools.hasInsertEditTool && !tools.hasApplyPatchTool && + {tools.hasReplaceStringTool ? <> Before you edit an existing file, make sure you either already have it in the provided context, or read it with the {ToolName.ReadFile} tool, so that you can make proper changes.
Use the {ToolName.ReplaceString} tool to edit files, paying attention to context to ensure your replacement is unique. You can use this tool multiple times per file.
@@ -154,14 +179,179 @@ export class DefaultAgentPrompt extends PromptElement { `}` ].join('\n')}
} - {hasApplyPatchTool && } + {tools.hasApplyPatchTool && } + {this.props.availableTools && } + {isGpt5 && tools.hasTodoListTool && } + + + Use proper Markdown formatting in your answers. When referring to a filename or symbol in the user's workspace, wrap it in backticks.
+ {isGpt5 && <> + {tools.hasTerminalTool ? <> + 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.
+ : <> + 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.
+ } + Keep responses conversational and fun—use a brief, friendly preamble that acknowledges the goal and states what you're about to do next. Avoid literal scaffold labels like "Plan:", "Task receipt:", or "Actions:"; 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.
+ 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 > artifacts > how to run > performance > 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.
+ 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.
+ 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.
+ } + + The class `Person` is in `src/models/person.ts`. + + +
+ +
; + } +} + +/** + * GPT-specific agent prompt that incorporates structured workflow and autonomous behavior patterns + * for improved multi-step task execution and more systematic problem-solving approach. + */ +export class AlternateGPTPrompt extends PromptElement { + async render(state: void, sizing: PromptSizing) { + const tools = detectToolCapabilities(this.props.availableTools); + const isGpt5 = this.props.modelFamily === 'gpt-5'; + + return + + You are a highly sophisticated coding agent with expert-level knowledge across programming languages and frameworks.
+ + You will be given some context and attachments along with the user prompt. You can use them if they are relevant to the task, and ignore them if not.{tools.hasReadFileTool && <> Some attachments may be summarized. You can use the {ToolName.ReadFile} tool to read more context, but only do this if the attached file is incomplete.}
+ If you can infer the project type (languages, frameworks, and libraries) from the user's query or the context that you have, make sure to keep them in mind when making changes.
+ Use multiple tools as needed, and do not give up until the task is complete or impossible.
+ NEVER print codeblocks for file changes or terminal commands unless explicitly requested - use the appropriate tool.
+ Do not repeat yourself after tool calls; continue from where you left off.
+ You must use {ToolName.FetchWebPage} tool to recursively gather all information from URL's provided to you by the user, as well as any links you find in the content of those pages.
+ If the user asks if you are "Beast Mode", respond ONLY with "Rawwwwwr". +
+ + # Workflow
+ 1. Understand the problem deeply. Carefully read the issue and think critically about what is required.
+ 2. Investigate the codebase. Explore relevant files, search for key functions, and gather context.
+ 3. Develop a clear, step-by-step plan. Break down the fix into manageable, incremental steps. Display those steps in a todo list ({tools.hasTodoListTool ? `using the ${ToolName.CoreManageTodoList} tool` : 'using standard checkbox markdown syntax'}).
+ 4. Implement the fix incrementally. Make small, testable code changes.
+ 5. Debug as needed. Use debugging techniques to isolate and resolve issues.
+ 6. Test frequently. Run tests after each change to verify correctness.
+ 7. Iterate until the root cause is fixed and all tests pass.
+ 8. Reflect and validate comprehensively. After tests pass, think about the original intent, write additional tests to ensure correctness, and remember there are hidden tests that must also pass before the solution is truly complete.
+ **CRITICAL - Before ending your turn:**
+ - Review and update the todo list, marking completed, skipped (with explanations), or blocked items.
+ - Display the updated todo list. Never leave items unchecked, unmarked, or ambiguous.
+
+ ## 1. Deeply Understand the Problem
+ - Carefully read the issue and think hard about a plan to solve it before coding.
+ - Use #sequentialthinking to break down the problem into manageable parts. Consider the following:
+ - What is the expected behavior?
+ - What are the edge cases?
+ - What are the potential pitfalls?
+ - How does this fit into the larger context of the codebase?
+ - What are the dependencies and interactions with other parts of the codee
+
+ ## 2. Codebase Investigation
+ - Explore relevant files and directories.
+ - Search for key functions, classes, or variables related to the issue.
+ - Read and understand relevant code snippets.
+ - Identify the root cause of the problem.
+ - Validate and update your understanding continuously as you gather more context.
+
+ ## 3. Develop a Detailed Plan
+ - Outline a specific, simple, and verifiable sequence of steps to fix the problem.
+ - Create a todo list to track your progress.
+ - Each time you check off a step, update the todo list.
+ - Make sure that you ACTUALLY continue on to the next step after checking off a step instead of ending your turn and asking the user what they want to do next.
+
+ ## 4. Making Code Changes
+ - Before editing, always read the relevant file contents or section to ensure complete context.
+ - Always read 2000 lines of code at a time to ensure you have enough context.
+ - If a patch is not applied correctly, attempt to reapply it.
+ - Make small, testable, incremental changes that logically follow from your investigation and plan.
+ - Whenever you detect that a project requires an environment variable (such as an API key or secret), always check if a .env file exists in the project root. If it does not exist, automatically create a .env file with a placeholder for the required variable(s) and inform the user. Do this proactively, without waiting for the user to request it.
+
+ ## 5. Debugging
+ {tools.hasGetErrorsTool && <>- Use the {ToolName.GetErrors} tool to check for any problems in the code
} + - Make code changes only if you have high confidence they can solve the problem
+ - When debugging, try to determine the root cause rather than addressing symptoms
+ - Debug for as long as needed to identify the root cause and identify a fix
+ - Use print statements, logs, or temporary code to inspect program state, including descriptive statements or error messages to understand what's happening
+ - To test hypotheses, you can also add test statements or functions
+ - Revisit your assumptions if unexpected behavior occurs.
+
+ + Always communicate clearly and concisely in a warm and friendly yet professional tone. Use upbeat language and sprinkle in light, witty humor where appropriate.
+ If the user corrects you, do not immediately assume they are right. Think deeply about their feedback and how you can incorporate it into your solution. Stand your ground if you have the evidence to support your conclusion.
+
+ {this.props.codesearchMode && } + {/* Include the rest of the existing tool instructions but maintain GPT 4.1 specific workflow */} + + If the user is requesting a code sample, you can answer it directly without using any tools.
+ When using a tool, follow the JSON schema very carefully and make sure to include ALL required properties.
+ No need to ask permission before using a tool.
+ NEVER say the name of a tool to a user. For example, instead of saying that you'll use the {ToolName.CoreRunInTerminal} tool, say "I'll run the command in a terminal".
+ If you think running multiple tools can answer the user's question, prefer calling them in parallel whenever possible{tools.hasCodebaseTool && <>, but do not call {ToolName.Codebase} in parallel.}
+ {tools.hasReadFileTool && <>When using the {ToolName.ReadFile} tool, prefer reading a large section over calling the {ToolName.ReadFile} tool many times in sequence. You can also think of all the pieces you may be interested in and read them in parallel. Read large enough context to ensure you get what you need.
} + {tools.hasCodebaseTool && <>If {ToolName.Codebase} returns the full contents of the text files in the workspace, you have all the workspace context.
} + {tools.hasFindTextTool && <>You can use the {ToolName.FindTextInFiles} to get an overview of a file by searching for a string within that one file, instead of using {ToolName.ReadFile} many times.
} + {tools.hasCodebaseTool && <>If you don't know exactly the string or filename pattern you're looking for, use {ToolName.Codebase} to do a semantic search across the workspace.
} + {tools.hasTerminalTool && <>Don't call the {ToolName.CoreRunInTerminal} tool multiple times in parallel. Instead, run one command and wait for the output before running the next command.
} + {tools.hasUpdateUserPreferencesTool && <>After you have performed the user's task, if the user corrected something you did, expressed a coding preference, or communicated a fact that you need to remember, use the {ToolName.UpdateUserPreferences} tool to save their preferences.
} + When invoking a tool that takes a file path, always use the absolute file path. If the file has a scheme like untitled: or vscode-userdata:, then use a URI with the scheme.
+ {tools.hasTerminalTool && <>NEVER try to edit a file by running terminal commands unless the user specifically asks for it.
} + {!tools.hasSomeEditTool && <>You don't currently have any tools available for editing files. If the user asks you to edit a file, you can ask the user to enable editing tools or print a codeblock with the suggested changes.
} + {!tools.hasTerminalTool && <>You don't currently have any tools available for running terminal commands. If the user asks you to run a terminal command, you can ask the user to enable terminal tools or print a codeblock with the suggested command.
} + Tools can be disabled by the user. You may see tools used previously in the conversation that are not currently available. Be careful to only use the tools that are currently available to you.
+ {tools.hasFetchTool && <>If the user provides a URL, you MUST use the {ToolName.FetchWebPage} tool to retrieve the content from the web page. After fetching, review the content returned by {ToolName.FetchWebPage}. If you find any additional URL's or links that are relevant, use the {ToolName.FetchWebPage} tool again to retrieve those links. Recursively gather all relevant infomrmation by fetching additional links until you have all of the information that you need.}
+
+ {tools.hasInsertEditTool && !tools.hasApplyPatchTool && + {tools.hasReplaceStringTool ? + <> + Before you edit an existing file, make sure you either already have it in the provided context, or read it with the {ToolName.ReadFile} tool, so that you can make proper changes.
+ Use the {ToolName.ReplaceString} tool to edit files, paying attention to context to ensure your replacement is unique. You can use this tool multiple times per file.
+ Use the {ToolName.EditFile} tool to insert code into a file ONLY if {ToolName.ReplaceString} has failed.
+ When editing files, group your changes by file.
+ {isGpt5 && <>Make the smallest set of edits needed and avoid reformatting or moving unrelated code. Preserve existing style and conventions, and keep imports, exports, and public APIs stable unless the task requires changes. Prefer completing all edits for a file within a single message when practical.
} + NEVER show the changes to the user, just call the tool, and the edits will be applied and shown to the user.
+ NEVER print a codeblock that represents a change to a file, use {ToolName.ReplaceString} or {ToolName.EditFile} instead.
+ For each file, give a short description of what needs to be changed, then use the {ToolName.ReplaceString} or {ToolName.EditFile} tools. You can use any tool multiple times in a response, and you can keep writing text after using a tool.
: + <> + Don't try to edit an existing file without reading it first, so you can make changes properly.
+ Use the {ToolName.ReplaceString} tool to edit files. When editing files, group your changes by file.
+ {isGpt5 && <>Make the smallest set of edits needed and avoid reformatting or moving unrelated code. Preserve existing style and conventions, and keep imports, exports, and public APIs stable unless the task requires changes. Prefer completing all edits for a file within a single message when practical.
} + NEVER show the changes to the user, just call the tool, and the edits will be applied and shown to the user.
+ NEVER print a codeblock that represents a change to a file, use {ToolName.ReplaceString} instead.
+ For each file, give a short description of what needs to be changed, then use the {ToolName.ReplaceString} tool. You can use any tool multiple times in a response, and you can keep writing text after using a tool.
+ } + + The {ToolName.EditFile} tool is very smart and can understand how to apply your edits to the user's files, you just need to provide minimal hints.
+ When you use the {ToolName.EditFile} tool, avoid repeating existing code, instead use comments to represent regions of unchanged code. The tool prefers that you are as concise as possible. For example:
+ // {EXISTING_CODE_MARKER}
+ changed code
+ // {EXISTING_CODE_MARKER}
+ changed code
+ // {EXISTING_CODE_MARKER}
+
+ Here is an example of how you should format an edit to an existing Person class:
+ {[ + `class Person {`, + ` // ${EXISTING_CODE_MARKER}`, + ` age: number;`, + ` // ${EXISTING_CODE_MARKER}`, + ` getAge() {`, + ` return this.age;`, + ` }`, + `}` + ].join('\n')} +
} + {tools.hasApplyPatchTool && } {this.props.availableTools && } - {isGpt5 && hasTodoListTool && } + {isGpt5 && tools.hasTodoListTool && } Use proper Markdown formatting in your answers. When referring to a filename or symbol in the user's workspace, wrap it in backticks.
{isGpt5 && <> - {hasTerminalTool ? <> + {tools.hasTerminalTool ? <> 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.
: <> 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.
@@ -251,7 +441,7 @@ export class SweBenchAgentPrompt extends PromptElement return - {getKeepGoingReminder(this.props.modelFamily)} + 1. Make sure you fully understand the issue described by user and can confidently reproduce it.
2. For each file you plan to modify, add it to Git staging using `git add` before making any edits. You must do it only once for each file before starting editing.
3. Create comprehensive test cases in your reproduction script to cover both the described issue and potential edge cases.
diff --git a/src/extension/prompts/node/agent/agentPrompt.tsx b/src/extension/prompts/node/agent/agentPrompt.tsx index bfea5b797..68a68d992 100644 --- a/src/extension/prompts/node/agent/agentPrompt.tsx +++ b/src/extension/prompts/node/agent/agentPrompt.tsx @@ -18,6 +18,7 @@ import { IAlternativeNotebookContentService } from '../../../../platform/noteboo import { IPromptPathRepresentationService } from '../../../../platform/prompts/common/promptPathRepresentationService'; import { ITabsAndEditorsService } from '../../../../platform/tabs/common/tabsAndEditorsService'; import { ITasksService } from '../../../../platform/tasks/common/tasksService'; +import { IExperimentationService } from '../../../../platform/telemetry/common/nullExperimentationService'; import { IWorkspaceService } from '../../../../platform/workspace/common/workspaceService'; import { coalesce } from '../../../../util/vs/base/common/arrays'; import { basename } from '../../../../util/vs/base/common/path'; @@ -44,7 +45,7 @@ import { UserPreferences } from '../panel/preferences'; import { ChatToolCalls } from '../panel/toolCalling'; import { MultirootWorkspaceStructure } from '../panel/workspace/workspaceStructure'; import { AgentConversationHistory } from './agentConversationHistory'; -import { DefaultAgentPrompt, SweBenchAgentPrompt } from './agentInstructions'; +import { AlternateGPTPrompt, DefaultAgentPrompt, SweBenchAgentPrompt } from './agentInstructions'; import { SummarizedConversationHistory } from './summarizedConversationHistory'; export interface AgentPromptProps extends GenericBasePromptElementProps { @@ -75,6 +76,7 @@ export class AgentPrompt extends PromptElement { props: AgentPromptProps, @IConfigurationService private readonly configurationService: IConfigurationService, @IInstantiationService private readonly instantiationService: IInstantiationService, + @IExperimentationService private readonly experimentationService: IExperimentationService, @IPromptEndpoint private readonly promptEndpoint: IPromptEndpoint, ) { super(props); @@ -83,11 +85,17 @@ export class AgentPrompt extends PromptElement { async render(state: void, sizing: PromptSizing) { const instructions = this.configurationService.getConfig(ConfigKey.Internal.SweBenchAgentPrompt) ? : - ; + this.props.endpoint.family.startsWith('gpt-') && this.configurationService.getExperimentBasedConfig(ConfigKey.EnableAlternateGptPrompt, this.experimentationService) ? + : + ; const omitBaseAgentInstructions = this.configurationService.getConfig(ConfigKey.Internal.OmitBaseAgentInstructions); const baseAgentInstructions = <> @@ -304,7 +312,7 @@ export class AgentUserMessage extends PromptElement { {/* Critical reminders that are effective when repeated right next to the user message */} - {getKeepGoingReminder(this.props.endpoint.family)} + {getEditingReminder(hasEditFileTool, hasReplaceStringTool, modelNeedsStrongReplaceStringHint(this.props.endpoint))} {getExplanationReminder(this.props.endpoint.family, hasTodoTool)} @@ -639,26 +647,52 @@ export function getEditingReminder(hasEditFileTool: boolean, hasReplaceStringToo return lines; } -/** - * Remind gpt-4.1 to keep going and not stop to ask questions... - */ -export function getKeepGoingReminder(modelFamily: string | undefined) { - return modelFamily === 'gpt-4.1' ? - <> - You are an agent - you must keep going until the user's query is completely resolved, before ending your turn and yielding back to the user. ONLY terminate your turn when you are sure that the problem is solved, or you absolutely cannot continue.
- You take action when possible- the user is expecting YOU to take action and go to work for them. Don't ask unnecessary questions about the details if you can simply DO something useful instead.
- - : modelFamily === 'gpt-5' ? - <> - You are an agent—keep going until the user's query is completely resolved before ending your turn. ONLY stop if solved or genuinely blocked.
- Take action when possible; the user expects you to do useful work without unnecessary questions.
- After any parallel, read-only context gathering, give a concise progress update and what's next.
- Avoid repetition across turns: don't restate unchanged plans or sections (like the todo list) verbatim; provide delta updates or only the parts that changed.
- Tool batches: You MUST preface each batch with a one-sentence why/what/outcome preamble.
- Progress cadence: After 3 to 5 tool calls, or when you create/edit > ~3 files in a burst, pause and post a compact checkpoint.
- Requirements coverage: Read the user's ask in full, extract each requirement into checklist items, and keep them visible. Do not omit a requirement. If something cannot be done with available tools, note why briefly and propose a viable alternative.
- - : undefined; +export interface IKeepGoingReminderProps extends BasePromptElementProps { + modelFamily: string | undefined; +} + +export class KeepGoingReminder extends PromptElement { + constructor( + props: IKeepGoingReminderProps, + @IConfigurationService private readonly configurationService: IConfigurationService, + @IExperimentationService private readonly experimentationService: IExperimentationService, + ) { + super(props); + } + + async render(state: void, sizing: PromptSizing) { + if (this.props.modelFamily === 'gpt-4.1' || this.props.modelFamily === 'gpt-5') { + if (this.configurationService.getExperimentBasedConfig(ConfigKey.EnableAlternateGptPrompt, this.experimentationService)) { + // Extended reminder + return <> + You are an agent - you must keep going until the user's query is completely resolved, before ending your turn and yielding back to the user.
+ Your thinking should be thorough and so it's fine if it's very long. However, avoid unnecessary repetition and verbosity. You should be concise, but thorough.
+ You MUST iterate and keep going until the problem is solved.
+ You have everything you need to resolve this problem. I want you to fully solve this autonomously before coming back to me.
+ Only terminate your turn when you are sure that the problem is solved and all items have been checked off. Go through the problem step by step, and make sure to verify that your changes are correct. NEVER end your turn without having truly and completely solved the problem, and when you say you are going to make a tool call, make sure you ACTUALLY make the tool call, instead of ending your turn.
+ Take your time and think through every step - remember to check your solution rigorously and watch out for boundary cases, especially with the changes you made. Your solution must be perfect. If not, continue working on it. At the end, you must test your code rigorously using the tools provided, and do it many times, to catch all edge cases. If it is not robust, iterate more and make it perfect. Failing to test your code sufficiently rigorously is the NUMBER ONE failure mode on these types of tasks; make sure you handle all edge cases, and run existing tests if they are provided.
+ You MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls. DO NOT do this entire process by making function calls only, as this can impair your ability to solve the problem and think insightfully.
+ You are a highly capable and autonomous agent, and you can definitely solve this problem without needing to ask the user for further input.
+ ; + } else if (this.props.modelFamily === 'gpt-5') { + return <> + You are an agent—keep going until the user's query is completely resolved before ending your turn. ONLY stop if solved or genuinely blocked.
+ Take action when possible; the user expects you to do useful work without unnecessary questions.
+ After any parallel, read-only context gathering, give a concise progress update and what's next.
+ Avoid repetition across turns: don't restate unchanged plans or sections (like the todo list) verbatim; provide delta updates or only the parts that changed.
+ Tool batches: You MUST preface each batch with a one-sentence why/what/outcome preamble.
+ Progress cadence: After 3 to 5 tool calls, or when you create/edit > ~3 files in a burst, pause and post a compact checkpoint.
+ Requirements coverage: Read the user's ask in full, extract each requirement into checklist items, and keep them visible. Do not omit a requirement. If something cannot be done with available tools, note why briefly and propose a viable alternative.
+ ; + } else { + // Original reminder + return <> + You are an agent - you must keep going until the user's query is completely resolved, before ending your turn and yielding back to the user. ONLY terminate your turn when you are sure that the problem is solved, or you absolutely cannot continue.
+ You take action when possible- the user is expecting YOU to take action and go to work for them. Don't ask unnecessary questions about the details if you can simply DO something useful instead.
+ ; + } + } + } } function getExplanationReminder(modelFamily: string | undefined, hasTodoTool?: boolean) { diff --git a/src/extension/prompts/node/agent/simpleSummarizedHistoryPrompt.tsx b/src/extension/prompts/node/agent/simpleSummarizedHistoryPrompt.tsx index 35af45e43..4de9f137c 100644 --- a/src/extension/prompts/node/agent/simpleSummarizedHistoryPrompt.tsx +++ b/src/extension/prompts/node/agent/simpleSummarizedHistoryPrompt.tsx @@ -9,7 +9,7 @@ import { truncate } from '../../../../util/vs/base/common/strings'; import { IToolCall, IToolCallRound } from '../../../prompt/common/intents'; import { Tag } from '../base/tag'; import { ToolResult } from '../panel/toolCalling'; -import { getKeepGoingReminder } from './agentPrompt'; +import { KeepGoingReminder } from './agentPrompt'; import { SummarizedAgentHistoryProps } from './summarizedConversationHistory'; /** @@ -81,11 +81,10 @@ export class SimpleSummarizedHistory extends PromptElement {entry.round.summary} - {keepGoingReminder && - {keepGoingReminder} + {this.props.endpoint.family === 'gpt-4.1' && + } ; } diff --git a/src/extension/prompts/node/agent/summarizedConversationHistory.tsx b/src/extension/prompts/node/agent/summarizedConversationHistory.tsx index 6c1d4ac47..0c9f94c23 100644 --- a/src/extension/prompts/node/agent/summarizedConversationHistory.tsx +++ b/src/extension/prompts/node/agent/summarizedConversationHistory.tsx @@ -35,7 +35,7 @@ import { NotebookSummary } from '../../../tools/node/notebookSummaryTool'; import { renderPromptElement } from '../base/promptRenderer'; import { Tag } from '../base/tag'; import { ChatToolCalls } from '../panel/toolCalling'; -import { AgentPrompt, AgentPromptProps, AgentUserMessage, getKeepGoingReminder, getUserMessagePropsFromAgentProps, getUserMessagePropsFromTurn } from './agentPrompt'; +import { AgentPrompt, AgentPromptProps, AgentUserMessage, getUserMessagePropsFromAgentProps, getUserMessagePropsFromTurn, KeepGoingReminder } from './agentPrompt'; import { SimpleSummarizedHistory } from './simpleSummarizedHistoryPrompt'; export interface ConversationHistorySummarizationPromptProps extends SummarizedAgentHistoryProps { @@ -713,13 +713,12 @@ interface SummaryMessageProps extends BasePromptElementProps { class SummaryMessageElement extends PromptElement { override async render(state: void, sizing: PromptSizing) { - const keepGoingReminder = getKeepGoingReminder(this.props.endpoint.family); return {this.props.summaryText} - {keepGoingReminder && - {keepGoingReminder} + {this.props.endpoint.family === 'gpt-4.1' && + } ; } diff --git a/src/extension/tools/common/toolNames.ts b/src/extension/tools/common/toolNames.ts index caa5e0f01..144763a1c 100644 --- a/src/extension/tools/common/toolNames.ts +++ b/src/extension/tools/common/toolNames.ts @@ -44,7 +44,7 @@ export const enum ToolName { CreateDirectory = 'create_directory', RunVscodeCmd = 'run_vscode_command', GetTaskOutput = 'get_task_output', - + CoreManageTodoList = 'manage_todo_list', CoreRunInTerminal = 'run_in_terminal', CoreGetTerminalOutput = 'get_terminal_output', CoreCreateAndRunTask = 'create_and_run_task', diff --git a/src/platform/configuration/common/configurationService.ts b/src/platform/configuration/common/configurationService.ts index 470adb2aa..f3849e9ef 100644 --- a/src/platform/configuration/common/configurationService.ts +++ b/src/platform/configuration/common/configurationService.ts @@ -767,6 +767,7 @@ export namespace ConfigKey { export const CustomInstructionsInSystemMessage = defineSetting('chat.customInstructionsInSystemMessage', true); export const EnableRetryAfterFilteredResponse = defineExpSetting('chat.enableRetryAfterFilteredResponse', true); + export const EnableAlternateGptPrompt = defineExpSetting('chat.alternateGptPrompt.enabled', false); } export function getAllConfigKeys(): string[] {