Support loading ACP sessions if agent can (#2889)

This commit is contained in:
Jie Liu
2025-12-29 19:11:30 +08:00
committed by GitHub
parent 148998b1db
commit 7608dce00e

View File

@@ -1320,8 +1320,7 @@ function M._stream_acp(opts)
if not session_id then
M._create_acp_session_and_continue(opts, acp_client)
else
if opts.just_connect_acp_client then return end
M._continue_stream_acp(opts, acp_client, session_id)
M._load_acp_session_and_continue(opts, acp_client, session_id)
end
end)
return
@@ -1357,6 +1356,23 @@ function M._create_acp_session_and_continue(opts, acp_client)
end)
end
---@param opts AvanteLLMStreamOptions
---@param acp_client avante.acp.ACPClient
---@param session_id string
function M._load_acp_session_and_continue(opts, acp_client, session_id)
local project_root = Utils.root.get()
acp_client:load_session(session_id, project_root, {}, function(_, err)
if err then
-- Failed to load session, create a new one. It happens after switching acp providers
M._create_acp_session_and_continue(opts, acp_client)
return
end
if opts.just_connect_acp_client then return end
M._continue_stream_acp(opts, acp_client, session_id)
end)
end
---@param opts AvanteLLMStreamOptions
---@param acp_client avante.acp.ACPClient
---@param session_id string