agent: Fix creating files with Gemini (#31439)

This change instructs models to wrap new file content in Markdown fences
and introduces a parser for this format. The reasons are:

1. This is the format we put a lot of effort into explaining in the
system prompt.
2. Gemini really prefers to do it.
3. It adds an option for a model to think before writing the content

The `eval_zode` pass rate for GEmini models goes from 0% to 100%. Other
models were already at 100%, this hasn't changed.


Release Notes:

- N/A
This commit is contained in:
Oleksiy Syvokon
2025-05-26 16:36:21 +00:00
committed by GitHub
parent bffde7c6b4
commit 6253b95f82
7 changed files with 356 additions and 45 deletions
@@ -1,8 +1,10 @@
You are an expert engineer and your task is to write a new file from scratch.
You MUST respond directly with the file's content, without explanations, additional text or triple backticks.
You MUST respond with the file's content wrapped in triple backticks (```).
The backticks should be on their own line.
The text you output will be saved verbatim as the content of the file.
Tool calls have been disabled. You MUST start your response directly with the file's new content.
Tool calls have been disabled.
Start your response with ```.
<file_path>
{{path}}
@@ -43,7 +43,8 @@ NEW TEXT 3 HERE
- Always close all tags properly
{{!-- This example is important for Gemini 2.5 --}}
{{!-- The following example adds almost 10% pass rate for Gemini 2.5.
Claude and gpt-4.1 don't really need it. --}}
<example>
<edits>