feat: add Graph Tool code and handoff reason to agent run log model and related components
This commit is contained in:
@@ -309,6 +309,8 @@ func (s *aiReplyService) writeRunLog(startedAt time.Time, message models.Message
|
||||
SkillRouteTrace: strings.TrimSpace(summarySkillRouteTrace(summary)),
|
||||
ToolSearchTrace: extractToolSearchTrace(summary),
|
||||
GraphToolTrace: extractGraphToolTrace(summary),
|
||||
GraphToolCode: firstGraphToolCode(summary),
|
||||
HandoffReason: extractHandoffReason(summary),
|
||||
PlannedToolCode: plannedToolCode,
|
||||
PlanReason: planReason,
|
||||
InterruptType: firstInterruptType(summary),
|
||||
@@ -597,6 +599,21 @@ func firstGraphToolCode(summary *Summary) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func extractHandoffReason(summary *Summary) string {
|
||||
trace := parseRuntimeTraceData(summary.TraceData)
|
||||
for _, item := range trace.GraphTools.Items {
|
||||
if strings.TrimSpace(item.ToolCode) != toolx.GraphHandoffConversationToolCode {
|
||||
continue
|
||||
}
|
||||
if len(item.Arguments) == 0 {
|
||||
return ""
|
||||
}
|
||||
reason, _ := item.Arguments["reason"].(string)
|
||||
return strings.TrimSpace(reason)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type runtimeTraceProjection struct {
|
||||
ToolSearch struct {
|
||||
Raw json.RawMessage `json:"-"`
|
||||
@@ -608,7 +625,8 @@ type runtimeTraceProjection struct {
|
||||
GraphTools struct {
|
||||
Raw json.RawMessage `json:"-"`
|
||||
Items []struct {
|
||||
ToolCode string `json:"toolCode"`
|
||||
ToolCode string `json:"toolCode"`
|
||||
Arguments map[string]any `json:"arguments"`
|
||||
} `json:"items"`
|
||||
} `json:"graphTools"`
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ func BuildAgentRunLog(item *models.AgentRunLog) response.AgentRunLogResponse {
|
||||
SkillRouteTrace: item.SkillRouteTrace,
|
||||
ToolSearchTrace: item.ToolSearchTrace,
|
||||
GraphToolTrace: item.GraphToolTrace,
|
||||
GraphToolCode: item.GraphToolCode,
|
||||
HandoffReason: item.HandoffReason,
|
||||
PlannedToolCode: item.PlannedToolCode,
|
||||
PlanReason: item.PlanReason,
|
||||
InterruptType: item.InterruptType,
|
||||
|
||||
@@ -26,6 +26,11 @@ func (c *AgentRunLogController) AnyList() *web.JsonResult {
|
||||
params.QueryFilter{ParamName: "aiAgentId"},
|
||||
params.QueryFilter{ParamName: "plannedAction"},
|
||||
params.QueryFilter{ParamName: "plannedSkillCode", Op: params.Like},
|
||||
params.QueryFilter{ParamName: "graphToolCode"},
|
||||
params.QueryFilter{ParamName: "interruptType"},
|
||||
params.QueryFilter{ParamName: "resumeSource"},
|
||||
params.QueryFilter{ParamName: "finalStatus"},
|
||||
params.QueryFilter{ParamName: "handoffReason", Op: params.Like},
|
||||
params.QueryFilter{ParamName: "finalAction"},
|
||||
params.QueryFilter{ParamName: "userMessage", Op: params.Like},
|
||||
).Desc("id")
|
||||
|
||||
@@ -952,6 +952,8 @@ type AgentRunLog struct {
|
||||
SkillRouteTrace string `gorm:"type:text"`
|
||||
ToolSearchTrace string `gorm:"type:text"`
|
||||
GraphToolTrace string `gorm:"type:text"`
|
||||
GraphToolCode string `gorm:"type:varchar(200);not null;default:'';index"`
|
||||
HandoffReason string `gorm:"type:varchar(500);not null;default:''"`
|
||||
PlannedToolCode string `gorm:"type:varchar(200);not null;default:'';index"`
|
||||
PlanReason string `gorm:"type:varchar(500);not null;default:''"`
|
||||
InterruptType string `gorm:"type:varchar(50);not null;default:'';index"`
|
||||
|
||||
@@ -50,6 +50,8 @@ type AgentRunLogResponse struct {
|
||||
SkillRouteTrace string `json:"skillRouteTrace"`
|
||||
ToolSearchTrace string `json:"toolSearchTrace"`
|
||||
GraphToolTrace string `json:"graphToolTrace"`
|
||||
GraphToolCode string `json:"graphToolCode"`
|
||||
HandoffReason string `json:"handoffReason"`
|
||||
PlannedToolCode string `json:"plannedToolCode"`
|
||||
PlanReason string `json:"planReason"`
|
||||
InterruptType string `json:"interruptType"`
|
||||
|
||||
Reference in New Issue
Block a user