Co-authored-by: Alexis Tacnet <alexis@mistral.ai>
Co-authored-by: Clément Drouin <clement.drouin@mistral.ai>
Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com>
Co-authored-by: Lucas Marandat <31749711+lucasmrdt@users.noreply.github.com>
Co-authored-by: Maxime Dolores <maxime.dolores@ext.mistral.ai>
Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai>
Co-authored-by: Quentin <quentin.torroba@mistral.ai>
Co-authored-by: Val <102326092+vdeva@users.noreply.github.com>
Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com>
Co-authored-by: p.vezia <166131032+le-codeur-rapide@users.noreply.github.com>
Co-authored-by: Hiba Chaabnia <Hiba-Chaabnia@users.noreply.github.com>
Co-authored-by: Nikhil Bhima <nikhilbhima@users.noreply.github.com>
Co-authored-by: Nkipohcs <Nkipohcs@users.noreply.github.com>
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Mathias Gesbert 2026-06-04 18:26:35 +02:00 committed by GitHub
parent ad0d5c9520
commit 3f8487f761
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
197 changed files with 10819 additions and 2830 deletions

View file

@ -25,23 +25,24 @@ async def _act_and_collect(agent_loop, prompt: str) -> list[BaseEvent]:
def _write_file_tool_call(
path: str, content: str, *, call_id: str = "call_1", overwrite: bool = False
path: str, content: str, *, call_id: str = "call_1"
) -> ToolCall:
args = json.dumps({"path": path, "content": content, "overwrite": overwrite})
args = json.dumps({"path": path, "content": content})
return ToolCall(
id=call_id, index=0, function=FunctionCall(name="write_file", arguments=args)
)
def _search_replace_tool_call(
file_path: str, search: str, replace: str, *, call_id: str = "call_1"
def _edit_tool_call(
file_path: str, old_string: str, new_string: str, *, call_id: str = "call_1"
) -> ToolCall:
content = f"<<<<<<< SEARCH\n{search}\n=======\n{replace}\n>>>>>>> REPLACE"
args = json.dumps({"file_path": file_path, "content": content})
args = json.dumps({
"file_path": file_path,
"old_string": old_string,
"new_string": new_string,
})
return ToolCall(
id=call_id,
index=0,
function=FunctionCall(name="search_replace", arguments=args),
id=call_id, index=0, function=FunctionCall(name="edit", arguments=args)
)
@ -54,10 +55,10 @@ def _bash_tool_call(command: str, *, call_id: str = "call_1") -> ToolCall:
def _make_agent_loop(backend: FakeBackend):
config = build_test_vibe_config(
enabled_tools=["write_file", "search_replace", "bash"],
enabled_tools=["write_file", "edit", "bash"],
tools={
"write_file": {"permission": "always"},
"search_replace": {"permission": "always"},
"edit": {"permission": "always"},
"bash": {"permission": "always"},
},
system_prompt_id="tests",
@ -98,10 +99,10 @@ class TestRewindIntegration:
assert not target.exists()
async def test_search_replace_rewind_restores_previous_version(
async def test_edit_rewind_restores_previous_version(
self, tmp_working_directory: Path
) -> None:
"""Edit a pre-existing file with search_replace, rewind restores original."""
"""Edit a pre-existing file with edit, rewind restores original."""
target = tmp_working_directory / "config.yaml"
target.write_text("key: original\n", encoding="utf-8")
@ -110,9 +111,7 @@ class TestRewindIntegration:
mock_llm_chunk(
content="Updating config.",
tool_calls=[
_search_replace_tool_call(
str(target), "key: original", "key: modified"
)
_edit_tool_call(str(target), "key: original", "key: modified")
],
)
],
@ -129,11 +128,11 @@ class TestRewindIntegration:
assert target.read_text() == "key: original\n"
async def test_write_then_search_replace_rewind_to_middle(
async def test_write_then_edit_rewind_to_middle(
self, tmp_working_directory: Path
) -> None:
"""Turn 1 creates a file with write_file, turn 2 patches it with
search_replace. Rewind to turn 2 restores the turn 1 version.
edit. Rewind to turn 2 restores the turn 1 version.
"""
target = tmp_working_directory / "app.py"
@ -148,12 +147,12 @@ class TestRewindIntegration:
)
],
[mock_llm_chunk(content="Created.")],
# Turn 2: patch with search_replace
# Turn 2: patch with edit
[
mock_llm_chunk(
content="Updating.",
tool_calls=[
_search_replace_tool_call(
_edit_tool_call(
str(target),
" pass",
' print("hello")',
@ -222,9 +221,7 @@ class TestRewindIntegration:
mock_llm_chunk(
content="v2.",
tool_calls=[
_write_file_tool_call(
str(target), "v2", call_id="call_2", overwrite=True
)
_edit_tool_call(str(target), "v1", "v2", call_id="call_2")
],
)
],
@ -234,9 +231,7 @@ class TestRewindIntegration:
mock_llm_chunk(
content="v2bis.",
tool_calls=[
_write_file_tool_call(
str(target), "v2bis", call_id="call_3", overwrite=True
)
_edit_tool_call(str(target), "v1", "v2bis", call_id="call_3")
],
)
],