From 45abe977e401046ea10ae6401a5116481ef94196 Mon Sep 17 00:00:00 2001
From: Bee <68532117+abeatrix@users.noreply.github.com>
Date: Tue, 28 Oct 2025 18:10:30 -0700
Subject: [PATCH] update: use diff edit tools for gpt-5 (#7147)
GPT-5 with native tool calling support has updated to use the new apply_patch tool. Before we can confirm the new tool works consistently, the old GPT-5 variant without native tool calling enabled should continue to use the current file edit tools.
---
.../__snapshots__/openai_gpt_5-basic.snap | 103 ++++++++----------
.../openai_gpt_5-no-browser.snap | 103 ++++++++----------
.../openai_gpt_5-no-focus-chain.snap | 101 +++++++----------
.../__snapshots__/openai_gpt_5-no-mcp.snap | 103 ++++++++----------
.../system-prompt/variants/gpt-5/config.ts | 5 +-
5 files changed, 177 insertions(+), 238 deletions(-)
diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-basic.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-basic.snap
index 1583261b..c436d3db 100644
--- a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-basic.snap
+++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-basic.snap
@@ -49,69 +49,54 @@ Usage:
Checklist here (optional)
-## apply_patch
-Description: This is a custom utility that makes it more convenient to add, remove, move, or edit code files. `apply_patch` effectively allows you to execute a diff/patch against a file, but the format of the diff specification is unique to this task, so pay careful attention to these instructions. To use the `apply_patch` command, you should pass a message of the following structure as "input":
-
-%%bash
-apply_patch <<"EOF"
-*** Begin Patch
-[YOUR_PATCH]
-*** End Patch
-EOF
-
-Where [YOUR_PATCH] is the actual content of your patch, specified in the following V4A diff format.
-
-*** [ACTION] File: [path/to/file] -> ACTION can be one of Add, Update, or Delete.
-For each snippet of code that needs to be changed, repeat the following:
-[context_before] -> See below for further instructions on context.
-- [old_code] -> Precede the old code with a minus sign.
-+ [new_code] -> Precede the new, replacement code with a plus sign.
-[context_after] -> See below for further instructions on context.
-
-For instructions on [context_before] and [context_after]:
-- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change’s [context_after] lines in the second change’s [context_before] lines.
-- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:
-@@ class BaseClass
-[3 lines of pre-context]
-- [old_code]
-+ [new_code]
-[3 lines of post-context]
-
-- If a code block is repeated so many times in a class or function such that even a single @@ statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple `@@` statements to jump to the right context. For instance:
-
-@@ class BaseClass
-@@ def method():
-[3 lines of pre-context]
-- [old_code]
-+ [new_code]
-[3 lines of post-context]
-
-Note, then, that we do not use line numbers in this diff format, as the context is enough to uniquely identify code. An example of a message that you might pass as "input" to this function, in order to apply a patch, is shown below.
-
-%%bash
-apply_patch <<"EOF"
-*** Begin Patch
-*** Update File: pygorithm/searching/binary_search.py
-@@ class BaseClass
-@@ def search():
-- pass
-+ raise NotImplementedError()
-
-@@ class Subclass
-@@ def search():
-- pass
-+ raise NotImplementedError()
-
-*** End Patch
-EOF
+## write_to_file
+Description: Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
-- input: (required) The apply_patch command that you wish to execute.
+- path: (required) The path of the file to write to (relative to the current working directory /test/project)
+- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
Usage:
-
-
+
+File path here
+Your file content hereChecklist here (optional)
-
+
+
+## replace_in_file
+Description: Request to replace sections of content in an existing file using SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file.
+Parameters:
+- path: (required) The path of the file to modify (relative to the current working directory /test/project)
+- diff: (required) One or more SEARCH/REPLACE blocks following this exact format:
+ ```
+ ------- SEARCH
+ [exact content to find]
+ =======
+ [new content to replace with]
+ +++++++ REPLACE
+ ```
+ Critical rules:
+ 1. SEARCH content must match the associated file section to find EXACTLY:
+ * Match character-for-character including whitespace, indentation, line endings
+ * Include all comments, docstrings, etc.
+ 2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.
+ * Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.
+ * Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.
+ * When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.
+ 3. Keep SEARCH/REPLACE blocks concise:
+ * Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.
+ * Include just the changing lines, and a few surrounding lines if needed for uniqueness.
+ * Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.
+ * Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
+ 4. Special operations:
+ * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
+ * To delete code: Use empty REPLACE section
+- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
+Usage:
+
+File path here
+Search and replace blocks here
+Checklist here (optional)
+
## search_files
Description: Request to perform a regex search across files in a specified directory, providing context-rich results. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.
diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-browser.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-browser.snap
index 272ed0c7..f0f91ff3 100644
--- a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-browser.snap
+++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-browser.snap
@@ -49,69 +49,54 @@ Usage:
Checklist here (optional)
-## apply_patch
-Description: This is a custom utility that makes it more convenient to add, remove, move, or edit code files. `apply_patch` effectively allows you to execute a diff/patch against a file, but the format of the diff specification is unique to this task, so pay careful attention to these instructions. To use the `apply_patch` command, you should pass a message of the following structure as "input":
-
-%%bash
-apply_patch <<"EOF"
-*** Begin Patch
-[YOUR_PATCH]
-*** End Patch
-EOF
-
-Where [YOUR_PATCH] is the actual content of your patch, specified in the following V4A diff format.
-
-*** [ACTION] File: [path/to/file] -> ACTION can be one of Add, Update, or Delete.
-For each snippet of code that needs to be changed, repeat the following:
-[context_before] -> See below for further instructions on context.
-- [old_code] -> Precede the old code with a minus sign.
-+ [new_code] -> Precede the new, replacement code with a plus sign.
-[context_after] -> See below for further instructions on context.
-
-For instructions on [context_before] and [context_after]:
-- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change’s [context_after] lines in the second change’s [context_before] lines.
-- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:
-@@ class BaseClass
-[3 lines of pre-context]
-- [old_code]
-+ [new_code]
-[3 lines of post-context]
-
-- If a code block is repeated so many times in a class or function such that even a single @@ statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple `@@` statements to jump to the right context. For instance:
-
-@@ class BaseClass
-@@ def method():
-[3 lines of pre-context]
-- [old_code]
-+ [new_code]
-[3 lines of post-context]
-
-Note, then, that we do not use line numbers in this diff format, as the context is enough to uniquely identify code. An example of a message that you might pass as "input" to this function, in order to apply a patch, is shown below.
-
-%%bash
-apply_patch <<"EOF"
-*** Begin Patch
-*** Update File: pygorithm/searching/binary_search.py
-@@ class BaseClass
-@@ def search():
-- pass
-+ raise NotImplementedError()
-
-@@ class Subclass
-@@ def search():
-- pass
-+ raise NotImplementedError()
-
-*** End Patch
-EOF
+## write_to_file
+Description: Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
-- input: (required) The apply_patch command that you wish to execute.
+- path: (required) The path of the file to write to (relative to the current working directory /test/project)
+- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
Usage:
-
-
+
+File path here
+Your file content hereChecklist here (optional)
-
+
+
+## replace_in_file
+Description: Request to replace sections of content in an existing file using SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file.
+Parameters:
+- path: (required) The path of the file to modify (relative to the current working directory /test/project)
+- diff: (required) One or more SEARCH/REPLACE blocks following this exact format:
+ ```
+ ------- SEARCH
+ [exact content to find]
+ =======
+ [new content to replace with]
+ +++++++ REPLACE
+ ```
+ Critical rules:
+ 1. SEARCH content must match the associated file section to find EXACTLY:
+ * Match character-for-character including whitespace, indentation, line endings
+ * Include all comments, docstrings, etc.
+ 2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.
+ * Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.
+ * Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.
+ * When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.
+ 3. Keep SEARCH/REPLACE blocks concise:
+ * Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.
+ * Include just the changing lines, and a few surrounding lines if needed for uniqueness.
+ * Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.
+ * Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
+ 4. Special operations:
+ * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
+ * To delete code: Use empty REPLACE section
+- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
+Usage:
+
+File path here
+Search and replace blocks here
+Checklist here (optional)
+
## search_files
Description: Request to perform a regex search across files in a specified directory, providing context-rich results. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.
diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-focus-chain.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-focus-chain.snap
index faa3410b..9c77a32d 100644
--- a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-focus-chain.snap
+++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-focus-chain.snap
@@ -44,67 +44,50 @@ Usage:
File path here
-## apply_patch
-Description: This is a custom utility that makes it more convenient to add, remove, move, or edit code files. `apply_patch` effectively allows you to execute a diff/patch against a file, but the format of the diff specification is unique to this task, so pay careful attention to these instructions. To use the `apply_patch` command, you should pass a message of the following structure as "input":
-
-%%bash
-apply_patch <<"EOF"
-*** Begin Patch
-[YOUR_PATCH]
-*** End Patch
-EOF
-
-Where [YOUR_PATCH] is the actual content of your patch, specified in the following V4A diff format.
-
-*** [ACTION] File: [path/to/file] -> ACTION can be one of Add, Update, or Delete.
-For each snippet of code that needs to be changed, repeat the following:
-[context_before] -> See below for further instructions on context.
-- [old_code] -> Precede the old code with a minus sign.
-+ [new_code] -> Precede the new, replacement code with a plus sign.
-[context_after] -> See below for further instructions on context.
-
-For instructions on [context_before] and [context_after]:
-- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change’s [context_after] lines in the second change’s [context_before] lines.
-- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:
-@@ class BaseClass
-[3 lines of pre-context]
-- [old_code]
-+ [new_code]
-[3 lines of post-context]
-
-- If a code block is repeated so many times in a class or function such that even a single @@ statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple `@@` statements to jump to the right context. For instance:
-
-@@ class BaseClass
-@@ def method():
-[3 lines of pre-context]
-- [old_code]
-+ [new_code]
-[3 lines of post-context]
-
-Note, then, that we do not use line numbers in this diff format, as the context is enough to uniquely identify code. An example of a message that you might pass as "input" to this function, in order to apply a patch, is shown below.
-
-%%bash
-apply_patch <<"EOF"
-*** Begin Patch
-*** Update File: pygorithm/searching/binary_search.py
-@@ class BaseClass
-@@ def search():
-- pass
-+ raise NotImplementedError()
-
-@@ class Subclass
-@@ def search():
-- pass
-+ raise NotImplementedError()
-
-*** End Patch
-EOF
+## write_to_file
+Description: Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
-- input: (required) The apply_patch command that you wish to execute.
+- path: (required) The path of the file to write to (relative to the current working directory /test/project)
+- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.
Usage:
-
-
-
+
+File path here
+Your file content here
+
+
+## replace_in_file
+Description: Request to replace sections of content in an existing file using SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file.
+Parameters:
+- path: (required) The path of the file to modify (relative to the current working directory /test/project)
+- diff: (required) One or more SEARCH/REPLACE blocks following this exact format:
+ ```
+ ------- SEARCH
+ [exact content to find]
+ =======
+ [new content to replace with]
+ +++++++ REPLACE
+ ```
+ Critical rules:
+ 1. SEARCH content must match the associated file section to find EXACTLY:
+ * Match character-for-character including whitespace, indentation, line endings
+ * Include all comments, docstrings, etc.
+ 2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.
+ * Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.
+ * Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.
+ * When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.
+ 3. Keep SEARCH/REPLACE blocks concise:
+ * Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.
+ * Include just the changing lines, and a few surrounding lines if needed for uniqueness.
+ * Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.
+ * Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
+ 4. Special operations:
+ * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
+ * To delete code: Use empty REPLACE section
+Usage:
+
+File path here
+Search and replace blocks here
+
## search_files
Description: Request to perform a regex search across files in a specified directory, providing context-rich results. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.
diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-mcp.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-mcp.snap
index 8f0ea1b3..0bfe1d9b 100644
--- a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-mcp.snap
+++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-mcp.snap
@@ -49,69 +49,54 @@ Usage:
Checklist here (optional)
-## apply_patch
-Description: This is a custom utility that makes it more convenient to add, remove, move, or edit code files. `apply_patch` effectively allows you to execute a diff/patch against a file, but the format of the diff specification is unique to this task, so pay careful attention to these instructions. To use the `apply_patch` command, you should pass a message of the following structure as "input":
-
-%%bash
-apply_patch <<"EOF"
-*** Begin Patch
-[YOUR_PATCH]
-*** End Patch
-EOF
-
-Where [YOUR_PATCH] is the actual content of your patch, specified in the following V4A diff format.
-
-*** [ACTION] File: [path/to/file] -> ACTION can be one of Add, Update, or Delete.
-For each snippet of code that needs to be changed, repeat the following:
-[context_before] -> See below for further instructions on context.
-- [old_code] -> Precede the old code with a minus sign.
-+ [new_code] -> Precede the new, replacement code with a plus sign.
-[context_after] -> See below for further instructions on context.
-
-For instructions on [context_before] and [context_after]:
-- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change’s [context_after] lines in the second change’s [context_before] lines.
-- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:
-@@ class BaseClass
-[3 lines of pre-context]
-- [old_code]
-+ [new_code]
-[3 lines of post-context]
-
-- If a code block is repeated so many times in a class or function such that even a single @@ statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple `@@` statements to jump to the right context. For instance:
-
-@@ class BaseClass
-@@ def method():
-[3 lines of pre-context]
-- [old_code]
-+ [new_code]
-[3 lines of post-context]
-
-Note, then, that we do not use line numbers in this diff format, as the context is enough to uniquely identify code. An example of a message that you might pass as "input" to this function, in order to apply a patch, is shown below.
-
-%%bash
-apply_patch <<"EOF"
-*** Begin Patch
-*** Update File: pygorithm/searching/binary_search.py
-@@ class BaseClass
-@@ def search():
-- pass
-+ raise NotImplementedError()
-
-@@ class Subclass
-@@ def search():
-- pass
-+ raise NotImplementedError()
-
-*** End Patch
-EOF
+## write_to_file
+Description: Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
Parameters:
-- input: (required) The apply_patch command that you wish to execute.
+- path: (required) The path of the file to write to (relative to the current working directory /test/project)
+- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.
- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
Usage:
-
-
+
+File path here
+Your file content hereChecklist here (optional)
-
+
+
+## replace_in_file
+Description: Request to replace sections of content in an existing file using SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file.
+Parameters:
+- path: (required) The path of the file to modify (relative to the current working directory /test/project)
+- diff: (required) One or more SEARCH/REPLACE blocks following this exact format:
+ ```
+ ------- SEARCH
+ [exact content to find]
+ =======
+ [new content to replace with]
+ +++++++ REPLACE
+ ```
+ Critical rules:
+ 1. SEARCH content must match the associated file section to find EXACTLY:
+ * Match character-for-character including whitespace, indentation, line endings
+ * Include all comments, docstrings, etc.
+ 2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.
+ * Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.
+ * Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.
+ * When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.
+ 3. Keep SEARCH/REPLACE blocks concise:
+ * Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.
+ * Include just the changing lines, and a few surrounding lines if needed for uniqueness.
+ * Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.
+ * Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
+ 4. Special operations:
+ * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
+ * To delete code: Use empty REPLACE section
+- task_progress: (optional) A checklist showing task progress after this tool use is completed. (See 'Updating Task Progress' section for more details)
+Usage:
+
+File path here
+Search and replace blocks here
+Checklist here (optional)
+
## search_files
Description: Request to perform a regex search across files in a specified directory, providing context-rich results. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.
diff --git a/src/core/prompts/system-prompt/variants/gpt-5/config.ts b/src/core/prompts/system-prompt/variants/gpt-5/config.ts
index 2b26b55e..5566df95 100644
--- a/src/core/prompts/system-prompt/variants/gpt-5/config.ts
+++ b/src/core/prompts/system-prompt/variants/gpt-5/config.ts
@@ -8,7 +8,7 @@ import { GPT_5_TEMPLATE_OVERRIDES } from "./template"
// Type-safe variant configuration using the builder pattern
export const config = createVariant(ModelFamily.GPT_5)
- .description("Prompt tailored to GPT-5 with native tool use support")
+ .description("Prompt tailored to GPT-5 with text-based tools")
.version(1)
.tags("gpt", "gpt-5", "advanced", "production")
.labels({
@@ -47,7 +47,8 @@ export const config = createVariant(ModelFamily.GPT_5)
.tools(
ClineDefaultTool.BASH,
ClineDefaultTool.FILE_READ,
- ClineDefaultTool.APPLY_PATCH,
+ ClineDefaultTool.FILE_NEW,
+ ClineDefaultTool.FILE_EDIT,
ClineDefaultTool.SEARCH,
ClineDefaultTool.LIST_FILES,
ClineDefaultTool.LIST_CODE_DEF,