From aa4fa9c89dd7e169847fac5a41aeeea3dcc31c79 Mon Sep 17 00:00:00 2001 From: yetone Date: Tue, 24 Jun 2025 19:15:49 +0800 Subject: [PATCH] fix: refine attempt_completion prompts (#2320) --- lua/avante/llm_tools/attempt_completion.lua | 2 +- lua/avante/llm_tools/insert.lua | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/avante/llm_tools/attempt_completion.lua b/lua/avante/llm_tools/attempt_completion.lua index bdcc2c8..a672c3f 100644 --- a/lua/avante/llm_tools/attempt_completion.lua +++ b/lua/avante/llm_tools/attempt_completion.lua @@ -12,7 +12,7 @@ M.name = "attempt_completion" M.description = [[ After each tool use, the user will respond with the result of that tool use, i.e. if it succeeded or failed, along with any reasons for failure. Once you've received the results of tool uses and can confirm that the task is complete, use this tool to present the result of your work to the user. Optionally you may provide a CLI command to showcase the result of your work. The user may respond with feedback if they are not satisfied with the result, which you can use to make improvements and try again. -IMPORTANT NOTE: This tool CANNOT be used until you've confirmed from the user that any previous tool uses were successful. Failure to do so will result in code corruption and system failure. Before using this tool, you must ask yourself in tags if you've confirmed from the user that any previous tool uses were successful. If not, then DO NOT use this tool. +IMPORTANT NOTE: This tool CANNOT be used until you've confirmed from the user that any previous tool uses were successful. Failure to do so will result in code corruption and system failure. Before using this tool, you must ask yourself in `think` tool calling if you've confirmed from the user that any previous tool uses were successful. If not, then DO NOT use this tool. ]] M.support_streaming = true diff --git a/lua/avante/llm_tools/insert.lua b/lua/avante/llm_tools/insert.lua index 9f7d168..be17cdf 100644 --- a/lua/avante/llm_tools/insert.lua +++ b/lua/avante/llm_tools/insert.lua @@ -77,6 +77,8 @@ function M.func(opts, on_log, on_complete, session_ctx) return { { line_, Highlights.INCOMING } } end) :totable() + local line_count = vim.api.nvim_buf_line_count(bufnr) + if opts.insert_line > line_count - 1 then opts.insert_line = line_count - 1 end vim.api.nvim_buf_set_extmark(bufnr, ns_id, opts.insert_line, 0, { virt_lines = virt_lines, hl_eol = true,