fix: insert dummy messages only when replace_in_file is successful (#2020)

This commit is contained in:
yetone
2025-05-09 12:15:56 +08:00
committed by GitHub
parent ba272bbf11
commit dbd74aaec8

View File

@@ -173,7 +173,7 @@ function M.generate_prompts(opts)
end
end
--- For models like gpt-4o, the input parameter of replace_in_file is treated as the latest file content, so here we need to insert a fake view tool call to ensure it uses the latest file content
if is_replace_func_call and path then
if is_replace_func_call and path and not message.message.content[1].is_error then
local lines = Utils.read_file_from_buf_or_disk(path)
local get_diagnostics_tool_use_id = Utils.uuid()
local view_tool_use_id = Utils.uuid()