@@ -165,7 +165,7 @@ function M.select_model(chat)
165165 local acp_models = M .list_acp_models (chat .acp_connection )
166166 models_list = acp_models and acp_models .availableModels or nil
167167 if not acp_models or not models_list then
168- return log :debug (" No models to select for the HTTP adapter" )
168+ return log :debug (" No models to select for the ACP adapter" )
169169 end
170170 current_model = acp_models .currentModelId
171171 end
@@ -233,18 +233,22 @@ function M.callback(chat)
233233 return
234234 end
235235
236- if current_adapter ~= selected_adapter then
237- chat .acp_connection = nil -- Ensure we reset this
238- chat :change_adapter (selected_adapter )
239- end
236+ local function on_adapter_ready ()
237+ -- Only force a system prompt update if the user isn't ignoring it. This
238+ -- occurs when a user has initiated a chat from the prompt library
239+ if not chat .opts .ignore_system_prompt then
240+ M .update_system_prompt (chat )
241+ end
240242
241- -- Only force a system prompt update if the user isn't ignoring it. This
242- -- occurs when a user has initiated a chat from the prompt library
243- if not chat .opts .ignore_system_prompt then
244- M .update_system_prompt (chat )
243+ return M .select_model (chat )
245244 end
246245
247- return M .select_model (chat )
246+ if current_adapter ~= selected_adapter then
247+ chat .acp_connection = nil -- Ensure we reset this
248+ chat :change_adapter (selected_adapter , on_adapter_ready )
249+ else
250+ return on_adapter_ready ()
251+ end
248252 end )
249253end
250254
0 commit comments