Enhance skill debugging and response structure by adding skill name and allowed tool codes, and refactor related data handling
This commit is contained in:
@@ -95,11 +95,19 @@ func (s *Service) Run(ctx context.Context, req Request) (*Summary, error) {
|
||||
collector.Data.Model.Provider = string(req.AIConfig.Provider)
|
||||
collector.Data.Model.Name = req.AIConfig.ModelName
|
||||
summary.SelectedSkillCode = ""
|
||||
summary.SelectedSkillName = ""
|
||||
summary.SkillRouteReason = strings.TrimSpace(req.SkillRouteReason)
|
||||
summary.SkillRouteTrace = strings.TrimSpace(req.SkillRouteTrace)
|
||||
if req.SelectedSkill != nil {
|
||||
summary.SelectedSkillCode = strings.TrimSpace(req.SelectedSkill.Code)
|
||||
summary.SelectedSkillName = strings.TrimSpace(req.SelectedSkill.Name)
|
||||
summary.SkillAllowedToolCodes = parseJSONArrayList(req.SelectedSkill.AllowedToolCodes)
|
||||
collector.Data.Skill.Code = summary.SelectedSkillCode
|
||||
collector.Data.Skill.Name = summary.SelectedSkillName
|
||||
collector.Data.Skill.AllowedToolCodes = append([]string(nil), summary.SkillAllowedToolCodes...)
|
||||
}
|
||||
collector.Data.Skill.RouteReason = summary.SkillRouteReason
|
||||
collector.Data.Skill.RouteTrace = summary.SkillRouteTrace
|
||||
|
||||
agent, err := s.agentFactory.BuildCustomerServiceAgent(ctx, req.AIAgent, req.AIConfig, req.SelectedSkill, filteredToolDefs, req.ExtraTools, req.ExtraToolCodes, collector)
|
||||
if err != nil {
|
||||
@@ -287,6 +295,22 @@ func filterToolDefinitionsBySkill(definitions []adapter.MCPToolDefinition, skill
|
||||
}
|
||||
|
||||
func parseJSONArraySet(raw string) map[string]struct{} {
|
||||
raw = strings.TrimSpace(raw)
|
||||
if raw == "" {
|
||||
return nil
|
||||
}
|
||||
items := parseJSONArrayList(raw)
|
||||
if len(items) == 0 {
|
||||
return nil
|
||||
}
|
||||
ret := make(map[string]struct{}, len(items))
|
||||
for _, item := range items {
|
||||
ret[item] = struct{}{}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func parseJSONArrayList(raw string) []string {
|
||||
raw = strings.TrimSpace(raw)
|
||||
if raw == "" {
|
||||
return nil
|
||||
@@ -295,13 +319,13 @@ func parseJSONArraySet(raw string) map[string]struct{} {
|
||||
if err := json.Unmarshal([]byte(raw), &items); err != nil {
|
||||
return nil
|
||||
}
|
||||
ret := make(map[string]struct{}, len(items))
|
||||
ret := make([]string, 0, len(items))
|
||||
for _, item := range items {
|
||||
item = strings.TrimSpace(item)
|
||||
if item == "" {
|
||||
continue
|
||||
}
|
||||
ret[item] = struct{}{}
|
||||
ret = append(ret, item)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -36,23 +36,25 @@ type InterruptContextSummary struct {
|
||||
}
|
||||
|
||||
type Summary struct {
|
||||
RunID string
|
||||
Status string
|
||||
ReplyText string
|
||||
SelectedSkillCode string
|
||||
SkillRouteReason string
|
||||
SkillRouteTrace string
|
||||
ModelName string
|
||||
PromptTokens int
|
||||
CompletionTokens int
|
||||
HistoryMessageCount int
|
||||
RetrieverCount int
|
||||
ToolCallCount int
|
||||
ToolCodes []string
|
||||
InvokedToolCodes []string
|
||||
CheckPointID string
|
||||
Interrupted bool
|
||||
Interrupts []InterruptContextSummary
|
||||
TraceData string
|
||||
ErrorMessage string
|
||||
RunID string
|
||||
Status string
|
||||
ReplyText string
|
||||
SelectedSkillCode string
|
||||
SelectedSkillName string
|
||||
SkillRouteReason string
|
||||
SkillRouteTrace string
|
||||
SkillAllowedToolCodes []string
|
||||
ModelName string
|
||||
PromptTokens int
|
||||
CompletionTokens int
|
||||
HistoryMessageCount int
|
||||
RetrieverCount int
|
||||
ToolCallCount int
|
||||
ToolCodes []string
|
||||
InvokedToolCodes []string
|
||||
CheckPointID string
|
||||
Interrupted bool
|
||||
Interrupts []InterruptContextSummary
|
||||
TraceData string
|
||||
ErrorMessage string
|
||||
}
|
||||
|
||||
@@ -21,9 +21,10 @@ type RetrieverTraceItem struct {
|
||||
}
|
||||
|
||||
type RuntimeTraceData struct {
|
||||
Version string `json:"version"`
|
||||
Status string `json:"status"`
|
||||
RunID string `json:"runId,omitempty"`
|
||||
Version string `json:"version"`
|
||||
Status string `json:"status"`
|
||||
RunID string `json:"runId,omitempty"`
|
||||
Skill SkillTraceData `json:"skill,omitempty"`
|
||||
Interrupt struct {
|
||||
CheckPointID string `json:"checkPointId,omitempty"`
|
||||
Items []InterruptTraceContext `json:"items,omitempty"`
|
||||
@@ -56,6 +57,14 @@ type RuntimeTraceData struct {
|
||||
} `json:"error"`
|
||||
}
|
||||
|
||||
type SkillTraceData struct {
|
||||
Code string `json:"code,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
RouteReason string `json:"routeReason,omitempty"`
|
||||
RouteTrace string `json:"routeTrace,omitempty"`
|
||||
AllowedToolCodes []string `json:"allowedToolCodes,omitempty"`
|
||||
}
|
||||
|
||||
type InterruptTraceContext struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
ID string `json:"id"`
|
||||
|
||||
Reference in New Issue
Block a user