fix: LLM 配置变更后立即生效 — 热重载 Provider Adapter

- AgentLoopEngine 新增 setAdapter() 热切换方法
- main.ts 提取 createAdapter 工厂函数
- IPC config:set 监听 LLM 相关 key 变更,触发热重载
- 覆盖 provider/model/apiKey/baseURL/numCtx 五个关键配置
This commit is contained in:
thzxx
2026-07-01 20:04:05 +08:00
parent 97a3d3d53b
commit ba85328c4f
3 changed files with 40 additions and 17 deletions
+7
View File
@@ -40,6 +40,7 @@ export function registerAllIPCHandlers(
sessionRecorder: SessionRecorder,
memoryManager: MemoryManager,
mcpManager: MCPManager,
reloadAdapter: () => void,
): void {
// ===== Agent 交互 =====
@@ -322,6 +323,12 @@ export function registerAllIPCHandlers(
outcome: 'success',
});
// LLM 相关配置变更时热重载 Adapter
if (['llm.provider', 'llm.model', 'llm.apiKey', 'llm.baseURL', 'ollama.numCtx'].includes(key)) {
reloadAdapter();
log.info(`[CONFIG] LLM config changed (${key}), adapter reloaded`);
}
return { success: true };
});