fix(agent): reinitialize MCP and discovery tools after reload

This commit is contained in:
afjcjsbx
2026-04-12 21:37:19 +02:00
parent 6d03791929
commit 815e43e3ef
3 changed files with 85 additions and 0 deletions
+15
View File
@@ -1056,8 +1056,23 @@ func (al *AgentLoop) ReloadProviderAndConfig(
al.mu.Unlock()
oldMCPManager := al.mcp.reset()
al.hookRuntime.reset(al)
configureHookManagerFromConfig(al.hooks, cfg)
if err := al.ensureHooksInitialized(ctx); err != nil {
logger.WarnCF("agent", "Configured hooks failed to reinitialize after reload",
map[string]any{"error": err.Error()})
}
if oldMCPManager != nil {
if err := oldMCPManager.Close(); err != nil {
logger.WarnCF("agent", "Failed to close previous MCP manager during reload",
map[string]any{"error": err.Error()})
}
}
if err := al.ensureMCPInitialized(ctx); err != nil {
logger.WarnCF("agent", "MCP failed to reinitialize after reload",
map[string]any{"error": err.Error()})
}
// Close old provider after releasing the lock
// This prevents blocking readers while closing