Replies: 12 comments 26 replies
-
I also get this a lot +1 |
Beta Was this translation helpful? Give feedback.
-
I also started having problems last night. I was using copilot (sonnet-4) and openai (o3). Some errors:
I'm guessing it's likely prompt issues [as noted above]. I'll try and tweak and report back if I get it working. Also, |
Beta Was this translation helpful? Give feedback.
-
I've read the GPT-4.1 prompting guide as mentioned by @pratyushmittal in his original Refactor @files tool to use diffs for update PR and they seems to say that we should better use the tools's description instead of a separate system prompt.... They example with a python tool actually have the full Patch specifications inside the tool description. I then tried and move most of the system prompt into the tool description, and that indeed seems to help a lot! I'll test a bit more tomorrow but, so far, I didn't had the case anymore where the LLM put his Patch inside a 'normal' message instead of in a tool call. I only had one error due to a missing 'end' tag but It seems to be way less frequent. here are my tool_description and the system_prompt TOOL_DESCRIPTION
PROMPT
|
Beta Was this translation helpful? Give feedback.
-
@Jufralice really appreciate your diligence and hard work on this. Some interesting points you raise. I've noticed that GitHub Copilot Chat also has the majority of tool detail in a non-system prompt too. Sharing that for reference: If you share GPT-4.1 prompting guide with CodeCompanion (via the |
Beta Was this translation helpful? Give feedback.
-
Hi @olimorris, I tried to ask the LLM for suggestions on how to improve the prompts (passing it the prompting guide via the /fetch command). I then again moved most of the system_prompt (including the Patch Format) into the tool description and now... all my tests succeed! It always correctly call the tool. I think that we can then indeed conclude that, at least for gemini-2.5-flash, the Patch Format needs to be in the tool's description. I then tried to remove the proposed example of the tool call from the prompt to see if that was absolutely needed. Most of my tests still succeeded but I also got more failures. I then noticed that the LLM nearly never asked for multiple code block changes in my buffer (it uses to call the tool for one change and say that he will do the rest in a next turn). The remaining issue that I from time to time have is that the LLM sometimes put line numbers in the @Identifier markers... But I suspect that it's because the buffer I shared with him does contains the line numbers. Anyway, that tool works way better with these changes now! Thanks a lot. |
Beta Was this translation helpful? Give feedback.
-
The recent changes in 2025-06-16.23_35_23.-.WezTerm.mp4 |
Beta Was this translation helpful? Give feedback.
-
@Jufralice @olimorris Great work on this! About to give 17.1.1 a test. I did want to mention that I frequently get similar issue, related to tool calling prompt engineering, for the @read_file tool where it will request lines past the last line of the file (see below) I see this constantly with gpt-4.1. Much less with more capable models but still an issue with all of them to some degree.
|
Beta Was this translation helpful? Give feedback.
-
Hi @olimorris , You can reproduce the issues with this scenario (using a file from the codecompanion plugin):
(I intentionally use a quite vague prompt in this example, to force the LLM to think more since that seems to help to reproduce these issues. I use a more specific prompt when I tested in my personal project but I can't share the file here.) I tested that prompt 15times from the master branch, 15times from this #1628 PR branch, and 15times from a merge of this #1628 PR and this #1663 PR From main branch
From the #1628 PR branch (where we moved some of the tool's system promt into the tool's description)
From the #1628 PR branch merged with the #1663 PR branch (that allow empty line before @@ focus)
We can then see that in this scenario we have no more errors due to the tool not being called when we moved some parts of the system prompt into the tool's description. Do you see similar results if you test with this scenario? |
Beta Was this translation helpful? Give feedback.
-
adding to the conversation here, after struggling a lot with making diff from chat with gemini work, i found out it works beautifully when triggered inline. so the trick that I've been using is just asking inline question and then set buffer as context. not sure if this helps or known but noticed today. |
Beta Was this translation helpful? Give feedback.
-
I don't remember where I saw it but I remember the Aider developer mentioning that Gemini does better with full file edits versus something like gpt 4.1 doing better with diff patches. Point is, it does not surprise me Gemini models may be struggling with diff patches. |
Beta Was this translation helpful? Give feedback.
-
FYI, some useful links to how Copilot Chat implements patching: They reference: https://cookbook.openai.com/examples/gpt4-1_prompting_guide#reference-implementation-apply_patchpy |
Beta Was this translation helpful? Give feedback.
-
does the gemini CLI write file tool help here https://github.com/google-gemini/gemini-cli/blob/main/packages/core/src/tools/write-file.ts ? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
The recent replacement of the @editor tool by the @insert_edit_into_file tool seems to be a great improvement.
Thanks a lot for the great work.
However, this new tool does not seems to work for some adapters like 'gemini-2.5-flash-preview-05-20'
The LLM will most of the time respond with a 'normal' llm response message (including his 'Patch' block inside the response message) instead of actually calling the tool using the function_call schema.
Or some other times (after I reply to the LLM that he must call the tool) it will eventually call the tool, but fail to use the Patch Format correctly (by missing the *** Begin Patch and *** End Patch surrounding lines).
I guess that we should be able to fix that issue by tweaking the system prompt of this tool.
I did some experiments without success so far:
current system prompt
new system prompt
Unfortunately, nothing seems to solve the issue and the LLM continues to reply with the PATCH response inside a normal response message instead of actually calling the tool.
The above addition mentioning the use of 'function_call' actually seems to make things worse since the gemini adapter then returns an internal error.
I tried to formulate this sentence in a few other ways but nothing seems to help.
If anybody find a way to fix that prompt for the gemini flash adapter, I'm more than interested.
Thanks a lot.
Beta Was this translation helpful? Give feedback.
All reactions