Skip to content

Commit 0c4df21

Browse files
Merge branch 'Shuffle:main' into timeout-fix
2 parents 3822912 + 31248c9 commit 0c4df21

14 files changed

Lines changed: 8045 additions & 1722 deletions

ai.go

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7457,6 +7457,33 @@ func HandleAiAgentExecutionStart(ctx context.Context, execution WorkflowExecutio
74577457
userMessage = oldAgentOutput.OriginalInput
74587458
}
74597459

7460+
// If the user continued the agent after a finish decision (via "Add more details"),
7461+
// the new input is stored in the "continue" field of the injected "ask" decision.
7462+
// Override userMessage so the LLM acts on the new instruction instead of the original one.
7463+
// Iterate from the end so we deterministically pick the most recent continuation.
7464+
for i := len(mappedResult.Decisions) - 1; i >= 0; i-- {
7465+
mappedDecision := mappedResult.Decisions[i]
7466+
if mappedDecision.Action != "ask" {
7467+
continue
7468+
}
7469+
7470+
foundContinuation := false
7471+
for _, field := range mappedDecision.Fields {
7472+
if field.Key == "continue" && len(field.Answer) > 0 {
7473+
if debug {
7474+
log.Printf("[DEBUG][%s] AI Agent continuation: overriding userMessage with 'continue' answer (length=%d)", execution.ExecutionId, len(field.Answer))
7475+
}
7476+
7477+
userMessage = field.Answer
7478+
foundContinuation = true
7479+
break
7480+
}
7481+
}
7482+
if foundContinuation {
7483+
break
7484+
}
7485+
}
7486+
74607487
if hasFailure {
74617488
log.Printf("[WARNING][%s] AI Agent: Detected failure in previous decisions. Last finished index: %d", execution.ExecutionId, lastFinishedIndex)
74627489

@@ -7878,6 +7905,8 @@ You are the Action Execution Agent for the Shuffle platform. You receive tools (
78787905
}
78797906
}
78807907

7908+
// Fix e.g. injected JSON and other quote/newline mechanics that aren't compatible
7909+
// Problem: The input data itself can be a reference.
78817910
completionRequest.Messages = append(completionRequest.Messages, openai.ChatCompletionMessage{
78827911
Role: openai.ChatMessageRoleUser,
78837912
Content: fmt.Sprintf("USER REQUEST: %s", userMessage),
@@ -8059,6 +8088,7 @@ You are the Action Execution Agent for the Shuffle platform. You receive tools (
80598088

80608089
resultMapping.ExecutionId = execution.ExecutionId
80618090
resultMapping.Authorization = execution.Authorization
8091+
// Waiting 3
80628092
resultMapping.Status = "WAITING"
80638093
resultMapping.Action = startNode
80648094
resultMapping.Action.Name = "agent"
@@ -8090,7 +8120,9 @@ You are the Action Execution Agent for the Shuffle platform. You receive tools (
80908120
continue
80918121
}
80928122

8093-
log.Printf("[DEBUG][%s] AI Agent: Found body parameter which MAY contain the right user input. LEN: %d", execution.ExecutionId, len(param.Value))
8123+
if debug {
8124+
log.Printf("[DEBUG][%s] AI Agent: Found body parameter which MAY contain the right user input. LEN: %d", execution.ExecutionId, len(param.Value))
8125+
}
80948126

80958127
if len(param.Value) > 0 {
80968128
parsedAgentInput = param.Value
@@ -8319,7 +8351,8 @@ You are the Action Execution Agent for the Shuffle platform. You receive tools (
83198351

83208352
ExecutionId: execution.ExecutionId,
83218353
NodeId: startNode.ID,
8322-
StartedAt: time.Now().Unix(),
8354+
StartedAt: time.Now().UnixMicro(),
8355+
CompletedAt: 0,
83238356

83248357
Memory: memorizationEngine,
83258358

@@ -8328,6 +8361,7 @@ You are the Action Execution Agent for the Shuffle platform. You receive tools (
83288361

83298362
if len(errorMessage) > 0 {
83308363
agentOutput.Output = errorMessage
8364+
agentOutput.Status = "FAILURE"
83318365
}
83328366

83338367
if createNextActions == true {
@@ -8394,6 +8428,7 @@ You are the Action Execution Agent for the Shuffle platform. You receive tools (
83948428
execution.Results[resultIndex].Result = string(agentOutputMarshalled)
83958429
}
83968430

8431+
// Waiting 1
83978432
execution.Results[resultIndex].Status = "WAITING"
83988433

83998434
// Update the result in cache as actions are self-corrective
@@ -8499,6 +8534,8 @@ You are the Action Execution Agent for the Shuffle platform. You receive tools (
84998534
}
85008535

85018536
decision.RunDetails.StartedAt = time.Now().Unix()
8537+
8538+
// Waiting 2
85028539
decision.RunDetails.Status = "WAITING"
85038540

85048541
agentOutput.Decisions[decisionIndex] = decision
@@ -8575,10 +8612,9 @@ You are the Action Execution Agent for the Shuffle platform. You receive tools (
85758612
}
85768613

85778614
agentOutput.Decisions[decisionIndex].RunDetails.StartedAt = time.Now().Unix()
8578-
agentOutput.Decisions[decisionIndex].RunDetails.Status = "RUNNING"
8579-
8580-
8581-
8615+
//agentOutput.Decisions[decisionIndex].RunDetails.Status = "RUNNING"
8616+
agentOutput.Decisions[decisionIndex].RunDetails.Status = "WAITING"
8617+
agentOutput.Status = "WAITING"
85828618

85838619
} else if decision.Category != "standalone" {
85848620
// Do we run the singul action directly?
@@ -8617,6 +8653,13 @@ You are the Action Execution Agent for the Shuffle platform. You receive tools (
86178653
Result: string(marshalledDecision),
86188654
}
86198655

8656+
for _, action := range execution.Workflow.Actions {
8657+
if action.ID == actionResult.Action.ID {
8658+
actionResult.Action = action
8659+
break
8660+
}
8661+
}
8662+
86208663
// This is required as the result for the agent isn't set yet on the first run. Minor delay to wait up a bit
86218664
if decisionIndex == 0 {
86228665
go func() {
@@ -8928,17 +8971,21 @@ func GenerateSingulWorkflows(resp http.ResponseWriter, request *http.Request) {
89288971
initialising := false
89298972
workflow, workflowErr := GetWorkflow(ctx, workflowId)
89308973
if workflowErr != nil || workflow.ID == "" {
8931-
log.Printf("[WARNING] Failed to get workflow by ID '%s' in GenerateSingulWorkflows: %s", workflowId, workflowErr)
8974+
//log.Printf("[WARNING] Failed to get workflow by ID '%s' in GenerateSingulWorkflows: %s", workflowId, workflowErr)
89328975
initialising = true
89338976
}
89348977

89358978
if categoryAction.ActionName == "remove" || categoryAction.ActionName == "disable" || categoryAction.ActionName == "stop" {
8979+
8980+
89368981
if workflowErr == nil && workflow.OrgId == user.ActiveOrg.Id {
89378982
// Delete the workflow
89388983
err = DeleteKey(ctx, "workflow", workflowId)
89398984
if err != nil {
89408985
log.Printf("[ERROR] Failed deleting workflow with ID %s in GenerateSingulWorkflows: %s", workflowId, err)
89418986
}
8987+
8988+
DeleteCache(ctx, fmt.Sprintf("%s_%s_workflows", "", user.ActiveOrg.Id))
89428989
} else {
89438990
log.Printf("[INFO] No existing workflow with ID %s to remove for category '%s'", workflowId, categoryAction.Label)
89448991
resp.WriteHeader(http.StatusOK)

app_upload/go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ require (
4242
github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42 // indirect
4343
github.com/containerd/errdefs v1.0.0 // indirect
4444
github.com/containerd/errdefs/pkg v0.3.0 // indirect
45-
github.com/coreos/go-oidc/v3 v3.17.0 // indirect
4645
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
4746
github.com/davecgh/go-spew v1.1.1 // indirect
4847
github.com/distribution/reference v0.6.0 // indirect
@@ -54,7 +53,7 @@ require (
5453
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
5554
github.com/felixge/httpsnoop v1.0.4 // indirect
5655
github.com/frikky/kin-openapi v0.42.0 // indirect
57-
github.com/frikky/schemaless v0.0.28 // indirect
56+
github.com/frikky/schemaless v0.0.33 // indirect
5857
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
5958
github.com/ghodss/yaml v1.0.0 // indirect
6059
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect

app_upload/go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151X
9393
github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk=
9494
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
9595
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
96-
github.com/coreos/go-oidc/v3 v3.17.0 h1:hWBGaQfbi0iVviX4ibC7bk8OKT5qNr4klBaCHVNvehc=
97-
github.com/coreos/go-oidc/v3 v3.17.0/go.mod h1:wqPbKFrVnE90vty060SB40FCJ8fTHTxSwyXJqZH+sI8=
9896
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
9997
github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s=
10098
github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
@@ -129,8 +127,8 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2
129127
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
130128
github.com/frikky/kin-openapi v0.42.0 h1:d5Z6vnuQ6RnCCPIxZaDL+TH2ODLxT8abytOt+Zh+Kd0=
131129
github.com/frikky/kin-openapi v0.42.0/go.mod h1:ev9OZAw7Bv5p0w93j91++6a1ElPzGcCofst+kmrWsj4=
132-
github.com/frikky/schemaless v0.0.28 h1:gdurMqBwtvY4Y/5pcxn8bdGCJn/eolKGz+c5DcidLkI=
133-
github.com/frikky/schemaless v0.0.28/go.mod h1:m9s+6gALXhA5ZERCrJw+jI2rRtTPNa8mkl4vav9sxnY=
130+
github.com/frikky/schemaless v0.0.33 h1:5Soj6VQc+ozqLh4R6MatWOl/atAeNpdon+nV5EKwjOI=
131+
github.com/frikky/schemaless v0.0.33/go.mod h1:m9s+6gALXhA5ZERCrJw+jI2rRtTPNa8mkl4vav9sxnY=
134132
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
135133
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
136134
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=

app_upload/stitcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,8 +1007,8 @@ func main() {
10071007
bucketName = os.Args[5]
10081008
}
10091009

1010-
appname := "shuffle-ai"
1011-
appversion := "1.0.0"
1010+
appname := "shuffle-tools"
1011+
appversion := "1.2.0"
10121012
err := deployConfigToBackend(appfolder, appname, appversion)
10131013
if err != nil {
10141014
log.Printf("[WARNING] Failed uploading config: %s", err)

0 commit comments

Comments
 (0)