changed the backend api and removed the force exit

This commit is contained in:
Hari Krishna
2026-02-10 15:31:59 +05:30
parent 2e3f855e0d
commit b4e5d604e9
+25 -16
View File
@@ -1507,24 +1507,33 @@ func handleExecutionResult(workflowExecution shuffle.WorkflowExecution) {
if parsedAppname == "ai-agent" { if parsedAppname == "ai-agent" {
log.Printf("[INFO][%s] Running AI Agent action %s via backend API", workflowExecution.ExecutionId, action.ID) log.Printf("[INFO][%s] Running AI Agent action %s via backend API", workflowExecution.ExecutionId, action.ID)
fullUrl := fmt.Sprintf("%s/api/v1/agent/hybrid/execute?execution_id=%s&authorization=%s", fullUrl := fmt.Sprintf("%s/api/v1/agent?execution_id=%s&authorization=%s&action_id=%s",
baseUrl, workflowExecution.ExecutionId, workflowExecution.Authorization) baseUrl, workflowExecution.ExecutionId, workflowExecution.Authorization, action.ID)
serverUrl := os.Getenv("SHUFFLE_BACKEND_URL") serverUrl := os.Getenv("SHUFFLE_BACKEND_URL")
if len(serverUrl) > 0 { if len(serverUrl) > 0 {
fullUrl = fmt.Sprintf("%s/api/v1/agent/hybrid/execute?execution_id=%s&authorization=%s", fullUrl = fmt.Sprintf("%s/api/v1/agent?execution_id=%s&authorization=%s&action_id=%s",
serverUrl, workflowExecution.ExecutionId, workflowExecution.Authorization) serverUrl, workflowExecution.ExecutionId, workflowExecution.Authorization, action.ID)
}
inputParamValue := ""
for _, param := range action.Parameters {
if strings.ToLower(param.Name) == "input" {
inputParamValue = param.Value
break
}
} }
requestBody := map[string]interface{}{ requestBody := map[string]interface{}{
"id": action.ID, "id": action.ID,
"name": action.Name, "params": map[string]interface{}{
"label": action.Label, "tool_name": action.AppName,
"app_name": action.AppName, "tool_id": action.AppID,
"app_id": action.AppID, "environment": action.Environment,
"app_version": action.AppVersion, "input": map[string]interface{}{
"environment": action.Environment, "text": inputParamValue,
"parameters": action.Parameters, },
},
} }
requestBodyBytes, err := json.Marshal(requestBody) requestBodyBytes, err := json.Marshal(requestBody)
@@ -1545,8 +1554,8 @@ func handleExecutionResult(workflowExecution shuffle.WorkflowExecution) {
resp, err := client.Do(req) resp, err := client.Do(req)
if err != nil { if err != nil {
log.Printf("[ERROR][%s] Failed triggering AI Agent (timeout/error): %s", workflowExecution.ExecutionId, err) log.Printf("[ERROR][%s] Failed triggering AI Agent (timeout/error): %s", workflowExecution.ExecutionId, err)
log.Printf("[INFO][%s] Worker exiting (exit 0) - backend will requeue execution when agent completes", workflowExecution.ExecutionId) log.Printf("[INFO][%s] Exiting execution handler - backend will requeue when agent completes", workflowExecution.ExecutionId)
os.Exit(0) return
} }
defer resp.Body.Close() defer resp.Body.Close()
@@ -1557,8 +1566,8 @@ func handleExecutionResult(workflowExecution shuffle.WorkflowExecution) {
// log.Printf("[INFO][%s] AI Agent triggered: %s", workflowExecution.ExecutionId, string(body)) // log.Printf("[INFO][%s] AI Agent triggered: %s", workflowExecution.ExecutionId, string(body))
// } // }
log.Printf("[INFO][%s] Worker exiting (exit 0) - backend will requeue when agent completes", workflowExecution.ExecutionId) log.Printf("[INFO][%s] AI Agent triggered successfully - exiting execution handler, backend will requeue when agent completes", workflowExecution.ExecutionId)
os.Exit(0) return
} }
imageName := fmt.Sprintf("%s:%s_%s", baseimagename, parsedAppname, action.AppVersion) imageName := fmt.Sprintf("%s:%s_%s", baseimagename, parsedAppname, action.AppVersion)