@@ -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 )
0 commit comments