fix: disable compact history messages for dispatch agent (#1954)
This commit is contained in:
@@ -290,28 +290,34 @@ function M.generate_prompts(opts)
|
|||||||
|
|
||||||
local final_history_messages = {}
|
local final_history_messages = {}
|
||||||
if opts.history_messages then
|
if opts.history_messages then
|
||||||
if Config.history.max_tokens > 0 then remaining_tokens = math.min(Config.history.max_tokens, remaining_tokens) end
|
if opts.disable_compact_history_messages then
|
||||||
-- Traverse the history in reverse, keeping only the latest history until the remaining tokens are exhausted and the first message role is "user"
|
final_history_messages = vim.list_extend(final_history_messages, opts.history_messages)
|
||||||
local history_messages = {}
|
else
|
||||||
for i = #opts.history_messages, 1, -1 do
|
if Config.history.max_tokens > 0 then
|
||||||
local message = opts.history_messages[i]
|
remaining_tokens = math.min(Config.history.max_tokens, remaining_tokens)
|
||||||
local tokens = Utils.tokens.calculate_tokens(message.message.content)
|
|
||||||
remaining_tokens = remaining_tokens - tokens
|
|
||||||
if remaining_tokens > 0 then
|
|
||||||
table.insert(history_messages, 1, message)
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
|
-- Traverse the history in reverse, keeping only the latest history until the remaining tokens are exhausted and the first message role is "user"
|
||||||
|
local history_messages = {}
|
||||||
|
for i = #opts.history_messages, 1, -1 do
|
||||||
|
local message = opts.history_messages[i]
|
||||||
|
local tokens = Utils.tokens.calculate_tokens(message.message.content)
|
||||||
|
remaining_tokens = remaining_tokens - tokens
|
||||||
|
if remaining_tokens > 0 then
|
||||||
|
table.insert(history_messages, 1, message)
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #history_messages == 0 then
|
||||||
|
history_messages = vim.list_slice(opts.history_messages, #opts.history_messages - 1, #opts.history_messages)
|
||||||
|
end
|
||||||
|
|
||||||
|
dropped_history_messages = vim.list_slice(opts.history_messages, 1, #opts.history_messages - #history_messages)
|
||||||
|
|
||||||
|
-- prepend the history messages to the messages table
|
||||||
|
vim.iter(history_messages):each(function(msg) table.insert(final_history_messages, msg) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
if #history_messages == 0 then
|
|
||||||
history_messages = vim.list_slice(opts.history_messages, #opts.history_messages - 1, #opts.history_messages)
|
|
||||||
end
|
|
||||||
|
|
||||||
dropped_history_messages = vim.list_slice(opts.history_messages, 1, #opts.history_messages - #history_messages)
|
|
||||||
|
|
||||||
-- prepend the history messages to the messages table
|
|
||||||
vim.iter(history_messages):each(function(msg) table.insert(final_history_messages, msg) end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Utils.debug("opts.history_messages", opts.history_messages)
|
-- Utils.debug("opts.history_messages", opts.history_messages)
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ When you're done, provide a clear and concise summary of what you found.]]):gsub
|
|||||||
|
|
||||||
local stream_options = {
|
local stream_options = {
|
||||||
ask = true,
|
ask = true,
|
||||||
|
disable_compact_history_messages = true,
|
||||||
memory = memory_content,
|
memory = memory_content,
|
||||||
code_lang = "unknown",
|
code_lang = "unknown",
|
||||||
provider = Providers[Config.provider],
|
provider = Providers[Config.provider],
|
||||||
|
|||||||
@@ -349,6 +349,7 @@ vim.g.avante_login = vim.g.avante_login
|
|||||||
---@field update_snippets? string[]
|
---@field update_snippets? string[]
|
||||||
---@field prompt_opts? AvantePromptOptions
|
---@field prompt_opts? AvantePromptOptions
|
||||||
---@field session_ctx? table
|
---@field session_ctx? table
|
||||||
|
---@field disable_compact_history_messages? boolean
|
||||||
---
|
---
|
||||||
---@class AvanteLLMToolHistory
|
---@class AvanteLLMToolHistory
|
||||||
---@field tool_result? AvanteLLMToolResult
|
---@field tool_result? AvanteLLMToolResult
|
||||||
|
|||||||
Reference in New Issue
Block a user