feat: add recommended action, risk level, and ticket draft readiness to AgentRunLogResponse and related components
This commit is contained in:
@@ -3,6 +3,7 @@ package builders
|
||||
import (
|
||||
"cs-agent/internal/models"
|
||||
"cs-agent/internal/pkg/dto/response"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -11,38 +12,65 @@ func BuildAgentRunLog(item *models.AgentRunLog) response.AgentRunLogResponse {
|
||||
return response.AgentRunLogResponse{}
|
||||
}
|
||||
hitlStatus, hitlStatusName, hitlSummary := resolveAgentRunLogHITL(item)
|
||||
recommendedAction, riskLevel, ticketDraftReady := resolveGraphOutcome(item.GraphToolTrace)
|
||||
return response.AgentRunLogResponse{
|
||||
ID: item.ID,
|
||||
ConversationID: item.ConversationID,
|
||||
MessageID: item.MessageID,
|
||||
AIAgentID: item.AIAgentID,
|
||||
AIConfigID: item.AIConfigID,
|
||||
UserMessage: item.UserMessage,
|
||||
PlannedAction: item.PlannedAction,
|
||||
PlannedSkillCode: item.PlannedSkillCode,
|
||||
PlannedSkillName: item.PlannedSkillName,
|
||||
SkillRouteTrace: item.SkillRouteTrace,
|
||||
ToolSearchTrace: item.ToolSearchTrace,
|
||||
GraphToolTrace: item.GraphToolTrace,
|
||||
GraphToolCode: item.GraphToolCode,
|
||||
HandoffReason: item.HandoffReason,
|
||||
PlannedToolCode: item.PlannedToolCode,
|
||||
PlanReason: item.PlanReason,
|
||||
InterruptType: item.InterruptType,
|
||||
ResumeSource: item.ResumeSource,
|
||||
HitlStatus: hitlStatus,
|
||||
HitlStatusName: hitlStatusName,
|
||||
HitlSummary: hitlSummary,
|
||||
FinalAction: item.FinalAction,
|
||||
FinalStatus: item.FinalStatus,
|
||||
ReplyText: item.ReplyText,
|
||||
ErrorMessage: item.ErrorMessage,
|
||||
LatencyMs: item.LatencyMs,
|
||||
TraceData: item.TraceData,
|
||||
CreatedAt: item.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
ID: item.ID,
|
||||
ConversationID: item.ConversationID,
|
||||
MessageID: item.MessageID,
|
||||
AIAgentID: item.AIAgentID,
|
||||
AIConfigID: item.AIConfigID,
|
||||
UserMessage: item.UserMessage,
|
||||
PlannedAction: item.PlannedAction,
|
||||
PlannedSkillCode: item.PlannedSkillCode,
|
||||
PlannedSkillName: item.PlannedSkillName,
|
||||
SkillRouteTrace: item.SkillRouteTrace,
|
||||
ToolSearchTrace: item.ToolSearchTrace,
|
||||
GraphToolTrace: item.GraphToolTrace,
|
||||
GraphToolCode: item.GraphToolCode,
|
||||
RecommendedAction: recommendedAction,
|
||||
RiskLevel: riskLevel,
|
||||
TicketDraftReady: ticketDraftReady,
|
||||
HandoffReason: item.HandoffReason,
|
||||
PlannedToolCode: item.PlannedToolCode,
|
||||
PlanReason: item.PlanReason,
|
||||
InterruptType: item.InterruptType,
|
||||
ResumeSource: item.ResumeSource,
|
||||
HitlStatus: hitlStatus,
|
||||
HitlStatusName: hitlStatusName,
|
||||
HitlSummary: hitlSummary,
|
||||
FinalAction: item.FinalAction,
|
||||
FinalStatus: item.FinalStatus,
|
||||
ReplyText: item.ReplyText,
|
||||
ErrorMessage: item.ErrorMessage,
|
||||
LatencyMs: item.LatencyMs,
|
||||
TraceData: item.TraceData,
|
||||
CreatedAt: item.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
}
|
||||
|
||||
func resolveGraphOutcome(raw string) (recommendedAction, riskLevel string, ticketDraftReady bool) {
|
||||
raw = strings.TrimSpace(raw)
|
||||
if raw == "" {
|
||||
return "", "", false
|
||||
}
|
||||
var payload struct {
|
||||
Items []struct {
|
||||
RecommendedAction string `json:"recommendedAction"`
|
||||
RiskLevel string `json:"riskLevel"`
|
||||
TicketDraftReady bool `json:"ticketDraftReady"`
|
||||
} `json:"items"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(raw), &payload); err != nil {
|
||||
return "", "", false
|
||||
}
|
||||
for _, item := range payload.Items {
|
||||
if strings.TrimSpace(item.RecommendedAction) != "" || strings.TrimSpace(item.RiskLevel) != "" || item.TicketDraftReady {
|
||||
return strings.TrimSpace(item.RecommendedAction), strings.TrimSpace(item.RiskLevel), item.TicketDraftReady
|
||||
}
|
||||
}
|
||||
return "", "", false
|
||||
}
|
||||
|
||||
func resolveAgentRunLogHITL(item *models.AgentRunLog) (status, statusName, summary string) {
|
||||
if item == nil {
|
||||
return "", "", ""
|
||||
|
||||
@@ -42,34 +42,37 @@ type SkillDebugRunResponse struct {
|
||||
}
|
||||
|
||||
type AgentRunLogResponse struct {
|
||||
ID int64 `json:"id"`
|
||||
ConversationID int64 `json:"conversationId"`
|
||||
MessageID int64 `json:"messageId"`
|
||||
AIAgentID int64 `json:"aiAgentId"`
|
||||
AIConfigID int64 `json:"aiConfigId"`
|
||||
UserMessage string `json:"userMessage"`
|
||||
PlannedAction string `json:"plannedAction"`
|
||||
PlannedSkillCode string `json:"plannedSkillCode"`
|
||||
PlannedSkillName string `json:"plannedSkillName"`
|
||||
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"`
|
||||
ResumeSource string `json:"resumeSource"`
|
||||
HitlStatus string `json:"hitlStatus"`
|
||||
HitlStatusName string `json:"hitlStatusName"`
|
||||
HitlSummary string `json:"hitlSummary"`
|
||||
FinalAction string `json:"finalAction"`
|
||||
FinalStatus string `json:"finalStatus"`
|
||||
ReplyText string `json:"replyText"`
|
||||
ErrorMessage string `json:"errorMessage"`
|
||||
LatencyMs int64 `json:"latencyMs"`
|
||||
TraceData string `json:"traceData"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
ID int64 `json:"id"`
|
||||
ConversationID int64 `json:"conversationId"`
|
||||
MessageID int64 `json:"messageId"`
|
||||
AIAgentID int64 `json:"aiAgentId"`
|
||||
AIConfigID int64 `json:"aiConfigId"`
|
||||
UserMessage string `json:"userMessage"`
|
||||
PlannedAction string `json:"plannedAction"`
|
||||
PlannedSkillCode string `json:"plannedSkillCode"`
|
||||
PlannedSkillName string `json:"plannedSkillName"`
|
||||
SkillRouteTrace string `json:"skillRouteTrace"`
|
||||
ToolSearchTrace string `json:"toolSearchTrace"`
|
||||
GraphToolTrace string `json:"graphToolTrace"`
|
||||
GraphToolCode string `json:"graphToolCode"`
|
||||
RecommendedAction string `json:"recommendedAction"`
|
||||
RiskLevel string `json:"riskLevel"`
|
||||
TicketDraftReady bool `json:"ticketDraftReady"`
|
||||
HandoffReason string `json:"handoffReason"`
|
||||
PlannedToolCode string `json:"plannedToolCode"`
|
||||
PlanReason string `json:"planReason"`
|
||||
InterruptType string `json:"interruptType"`
|
||||
ResumeSource string `json:"resumeSource"`
|
||||
HitlStatus string `json:"hitlStatus"`
|
||||
HitlStatusName string `json:"hitlStatusName"`
|
||||
HitlSummary string `json:"hitlSummary"`
|
||||
FinalAction string `json:"finalAction"`
|
||||
FinalStatus string `json:"finalStatus"`
|
||||
ReplyText string `json:"replyText"`
|
||||
ErrorMessage string `json:"errorMessage"`
|
||||
LatencyMs int64 `json:"latencyMs"`
|
||||
TraceData string `json:"traceData"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
}
|
||||
|
||||
type AgentRunGraphSummaryResponse struct {
|
||||
|
||||
@@ -440,6 +440,13 @@ export default function DashboardAgentRunLogsPage() {
|
||||
转人工原因:{item.handoffReason}
|
||||
</div>
|
||||
) : null}
|
||||
{item.recommendedAction ? (
|
||||
<div className="line-clamp-1 text-xs text-muted-foreground">
|
||||
分流建议:{item.recommendedAction}
|
||||
{item.riskLevel ? ` / ${item.riskLevel} risk` : ""}
|
||||
{item.ticketDraftReady ? " / 草稿已就绪" : ""}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
) : (
|
||||
"-"
|
||||
@@ -529,6 +536,9 @@ export default function DashboardAgentRunLogsPage() {
|
||||
`plannedSkillCode: ${activeLog.plannedSkillCode || "-"}`,
|
||||
`plannedSkillName: ${activeLog.plannedSkillName || "-"}`,
|
||||
`graphToolCode: ${activeLog.graphToolCode || "-"}`,
|
||||
`recommendedAction: ${activeLog.recommendedAction || "-"}`,
|
||||
`riskLevel: ${activeLog.riskLevel || "-"}`,
|
||||
`ticketDraftReady: ${activeLog.ticketDraftReady ? "true" : "false"}`,
|
||||
`plannedToolCode: ${activeLog.plannedToolCode || "-"}`,
|
||||
`planReason: ${activeLog.planReason || "-"}`,
|
||||
`handoffReason: ${activeLog.handoffReason || "-"}`,
|
||||
|
||||
@@ -399,6 +399,9 @@ export type AgentRunLog = {
|
||||
toolSearchTrace: string
|
||||
graphToolTrace: string
|
||||
graphToolCode: string
|
||||
recommendedAction: string
|
||||
riskLevel: string
|
||||
ticketDraftReady: boolean
|
||||
handoffReason: string
|
||||
plannedToolCode: string
|
||||
planReason: string
|
||||
|
||||
Reference in New Issue
Block a user