fix: do not pick tool use messages when use ReAct (#2333)

This commit is contained in:
yetone
2025-06-25 20:59:35 +08:00
committed by GitHub
parent ad8b24e3bc
commit 5b2a0e6118

View File

@@ -5,7 +5,7 @@ local Split = require("nui.split")
local event = require("nui.utils.autocmd").event local event = require("nui.utils.autocmd").event
local PPath = require("plenary.path") local PPath = require("plenary.path")
local Provider = require("avante.providers") local Providers = require("avante.providers")
local Path = require("avante.path") local Path = require("avante.path")
local Config = require("avante.config") local Config = require("avante.config")
local Diff = require("avante.diff") local Diff = require("avante.diff")
@@ -165,7 +165,7 @@ function Sidebar:open(opts)
end end
if not vim.g.avante_login or vim.g.avante_login == false then if not vim.g.avante_login or vim.g.avante_login == false then
api.nvim_exec_autocmds("User", { pattern = Provider.env.REQUEST_LOGIN_PATTERN }) api.nvim_exec_autocmds("User", { pattern = Providers.env.REQUEST_LOGIN_PATTERN })
vim.g.avante_login = true vim.g.avante_login = true
end end
@@ -2202,6 +2202,8 @@ function Sidebar:get_history_messages_for_api(opts)
if opts.all then return history_messages0 end if opts.all then return history_messages0 end
local use_ReAct_prompt = Providers[Config.provider].use_ReAct_prompt ~= nil
history_messages0 = vim history_messages0 = vim
.iter(history_messages0) .iter(history_messages0)
:filter(function(message) return message.state ~= "generating" end) :filter(function(message) return message.state ~= "generating" end)
@@ -2411,6 +2413,7 @@ function Sidebar:get_history_messages_for_api(opts)
end end
end end
if not use_ReAct_prompt then
local picked_messages = {} local picked_messages = {}
local max_tool_use_count = 25 local max_tool_use_count = 25
local tool_use_count = 0 local tool_use_count = 0
@@ -2466,6 +2469,7 @@ function Sidebar:get_history_messages_for_api(opts)
end end
history_messages = picked_messages history_messages = picked_messages
end
local final_history_messages = {} local final_history_messages = {}
for _, msg in ipairs(history_messages) do for _, msg in ipairs(history_messages) do