feat: refactor tool catalog to use NewRuntimeStaticTool for dynamic tool creation

This commit is contained in:
mlogclub
2026-04-14 09:56:52 +08:00
parent 200631cc0b
commit 3254ba1bf4
2 changed files with 24 additions and 11 deletions
@@ -21,20 +21,13 @@ func newToolCatalog() *toolCatalog {
}
func buildRuntimeStaticTools() []registry.Tool {
builders := map[string]func() registry.Tool{
toolx.GraphTriageServiceRequest.Code: func() registry.Tool { return tools.NewTriageServiceRequestTool() },
toolx.GraphAnalyzeConversation.Code: func() registry.Tool { return tools.NewAnalyzeConversationTool() },
toolx.GraphPrepareTicketDraft.Code: func() registry.Tool { return tools.NewPrepareTicketDraftTool() },
toolx.GraphCreateTicketConfirm.Code: func() registry.Tool { return tools.NewCreateTicketGraphTool() },
toolx.GraphHandoffConversation.Code: func() registry.Tool { return tools.NewHandoffGraphTool() },
}
ret := make([]registry.Tool, 0, len(builders))
ret := make([]registry.Tool, 0, len(toolx.ListRuntimeStaticToolSpecs()))
for _, spec := range toolx.ListRuntimeStaticToolSpecs() {
build := builders[strings.TrimSpace(spec.Code)]
if build == nil {
tool := tools.NewRuntimeStaticTool(spec.Code)
if tool == nil {
continue
}
ret = append(ret, build())
ret = append(ret, tool)
}
return ret
}