feat: enhance AI workflow with new ticket creation and fallback handling logic

This commit is contained in:
mlogclub
2026-06-25 18:28:16 +08:00
parent 22c241a4ad
commit 34d70e769f
8 changed files with 490 additions and 25 deletions
+8 -6
View File
@@ -137,17 +137,19 @@ func DefaultRegistry() *Registry {
},
OutputSchema: []VariableSpec{
output("ticketId", VariableTypeInteger, "Created ticket ID."),
output("ticketNo", VariableTypeString, "Created ticket number."),
output("created", VariableTypeBoolean, "Whether the ticket was created."),
output("message", VariableTypeString, "Customer-visible ticket creation result."),
},
},
NodeSpec{
Type: NodeTypeHandoffToHuman,
Title: "Handoff To Human",
Description: "Transfer the conversation to human support.",
RiskLevel: NodeRiskLevelHigh,
RequiresConfirmationPredecessor: true,
Type: NodeTypeHandoffToHuman,
Title: "Handoff To Human",
Description: "Transfer the conversation to human support.",
RiskLevel: NodeRiskLevelHigh,
InputSchema: []VariableSpec{
requiredInput("reason", VariableTypeString, "Handoff reason."),
requiredInput("confirmed", VariableTypeBoolean, "Confirmation result."),
optionalInput("confirmed", VariableTypeBoolean, "Confirmation result."),
},
OutputSchema: []VariableSpec{
output("handoffId", VariableTypeInteger, "Handoff operation ID."),
@@ -110,6 +110,30 @@ func TestValidateDefinitionAcceptsConfirmedCreateTicket(t *testing.T) {
}
}
func TestValidateDefinitionAcceptsDirectHandoffToHuman(t *testing.T) {
def := dsl.Definition{
SchemaVersion: 1,
EntryNodeID: "start_1",
Nodes: []dsl.Node{
{ID: "start_1", Type: "start"},
{ID: "handoff_1", Type: "handoff_to_human", Inputs: map[string]dsl.VariableSelector{
"reason": {NodeID: "start_1", Field: "userMessage"},
}},
{ID: "end_1", Type: "end"},
},
Edges: []dsl.Edge{
{ID: "e1", Source: "start_1", Target: "handoff_1"},
{ID: "e2", Source: "handoff_1", Target: "end_1"},
},
}
result := validator.ValidateDefinition(def, registry.DefaultRegistry())
if !result.Valid {
t.Fatalf("expected direct handoff_to_human to be valid, got %#v", result.Errors)
}
}
func TestValidateDefinitionRejectsConfirmedInputFromNonConfirmNode(t *testing.T) {
def := dsl.Definition{
SchemaVersion: 1,