fix: async knowledge writeIndex + 60s tool execution timeout

This commit is contained in:
root
2026-07-16 19:04:10 +08:00
parent f93b5eccb6
commit c951e75b39
2 changed files with 21 additions and 3 deletions

View File

@ -1027,6 +1027,22 @@ func (a *Agent) executeToolCall(tc agentAPI.ToolCall) (ret string) {
ret = fmt.Sprintf("工具 %s 执行崩溃: %v", tc.Name, r)
}
}()
done := make(chan string, 1)
go func() {
done <- a.executeToolCallInner(tc)
}()
select {
case result := <-done:
return result
case <-time.After(60 * time.Second):
log.Printf("[agent] tool %s timed out after 60s", tc.Name)
return fmt.Sprintf("工具 %s 执行超时60秒已取消", tc.Name)
}
}
func (a *Agent) executeToolCallInner(tc agentAPI.ToolCall) string {
switch {
case strings.HasPrefix(tc.Name, "memory_"):
return a.executeMemoryTool(tc)