feat: add Graph Tool tracing and logging support in agent run logs

This commit is contained in:
mlogclub
2026-04-10 15:47:58 +08:00
parent 3db7bec662
commit d953625a2b
9 changed files with 101 additions and 0 deletions
@@ -67,6 +67,7 @@ func (f *AgentFactory) BuildCustomerServiceAgent(ctx context.Context, aiAgent *m
ToolCode: item.ToolCode,
ServerCode: item.ServerCode,
ToolName: item.ToolName,
SourceType: "mcp",
}
}
for modelName, toolCode := range extraToolCodes {
@@ -87,6 +88,7 @@ func (f *AgentFactory) BuildCustomerServiceAgent(ctx context.Context, aiAgent *m
ToolCode: toolCode,
ServerCode: serverCode,
ToolName: toolName,
SourceType: resolveToolSourceType(toolCode),
}
}
handlers = append(handlers, einocallbacks.NewRuntimeTraceHandler(collector, toolMetadataBy))
@@ -109,6 +111,20 @@ func (f *AgentFactory) BuildCustomerServiceAgent(ctx context.Context, aiAgent *m
return &einoagents.CustomerServiceAgent{Inner: inner}, nil
}
func resolveToolSourceType(toolCode string) string {
toolCode = strings.TrimSpace(toolCode)
switch {
case toolCode == toolx.BuiltinToolSearchToolCode:
return toolx.BuiltinToolCatalogServerCode
case strings.HasPrefix(toolCode, toolx.GraphToolCatalogServerCode+"/"):
return toolx.GraphToolCatalogServerCode
case strings.HasPrefix(toolCode, toolx.BuiltinToolCatalogServerCode+"/"):
return toolx.BuiltinToolCatalogServerCode
default:
return "mcp"
}
}
func buildAgentInstruction(aiAgent *models.AIAgent, selectedSkill *models.SkillDefinition, toolDefinitions []einoadapter.MCPToolDefinition, extraToolCodes map[string]string) string {
baseInstruction := ""
if aiAgent != nil {