From dbd74aaec8218a1b41fdf14d22d6a9728c0f7f3c Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 9 May 2025 12:15:56 +0800 Subject: [PATCH] fix: insert dummy messages only when replace_in_file is successful (#2020) --- lua/avante/llm.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/avante/llm.lua b/lua/avante/llm.lua index 5de1ffe..2059617 100644 --- a/lua/avante/llm.lua +++ b/lua/avante/llm.lua @@ -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()