-
Notifications
You must be signed in to change notification settings - Fork 28
Fix agent stuck in waiting state after completion #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17101,7 +17101,15 @@ func handleAgentDecisionStreamResult(workflowExecution WorkflowExecution, action | |
| // Handle agent decisionmaking. Use the same | ||
| log.Printf("[INFO][%s] With the agent being finished, we are asking it whether it would like to do anything else", workflowExecution.ExecutionId) | ||
|
|
||
| returnAction, err := HandleAiAgentExecutionStart(workflowExecution, actionResult.Action, true) | ||
| var originalAction Action | ||
| if foundActionResultIndex >= 0 && foundActionResultIndex < len(workflowExecution.Results) { | ||
| originalAction = workflowExecution.Results[foundActionResultIndex].Action | ||
| } else { | ||
| // Fallback in case of an issue | ||
| originalAction = actionResult.Action | ||
| } | ||
|
|
||
| returnAction, err := HandleAiAgentExecutionStart(workflowExecution, originalAction, true) | ||
| if err != nil { | ||
| log.Printf("[ERROR][%s] Failed handling agent execution start: %s", workflowExecution.ExecutionId, err) | ||
| } | ||
|
|
@@ -21407,8 +21415,16 @@ func PrepareSingleAction(ctx context.Context, user User, appId string, body []by | |
| workflowExecution.OrgId = user.ActiveOrg.Id | ||
| } | ||
|
|
||
| formattedAppName := strings.ReplaceAll(strings.ToLower(app.Name), " ", "_") | ||
|
|
||
| isInternalShuffleApp := false | ||
| switch formattedAppName { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something about just matching name seems off, but I'm not sure exactly why. I wonder if there is a way to "steal" the URL field/apikey by formatting an app in a certain way. Just need to think it over before merging 🤔
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think having a special verified field for apps built by support users would be better. Given that we're already overriding the URL field when injecting the auth, if we compare additionally to this special field and both are true, we can trust it. What do you think? |
||
| case "shuffle_datastore", "shuffle_org_management", "shuffle_app_management", "shuffle_workflow_management": | ||
| isInternalShuffleApp = true | ||
| } | ||
|
|
||
| // Fallback to inject AI creds if the user don't have any | ||
| if len(workflowExecution.OrgId) > 0 && strings.ReplaceAll(strings.ToLower(app.Name), " ", "_") == "shuffle_datastore" && len(action.AuthenticationId) == 0 { | ||
| if len(workflowExecution.OrgId) > 0 && isInternalShuffleApp && len(action.AuthenticationId) == 0 { | ||
| backendUrl := os.Getenv("BASE_URL") | ||
| if len(os.Getenv("SHUFFLE_CLOUDRUN_URL")) > 0 && strings.Contains(os.Getenv("SHUFFLE_CLOUDRUN_URL"), "http") { | ||
| backendUrl = os.Getenv("SHUFFLE_CLOUDRUN_URL") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the point of this? I'm always confused when we override actions, when things used to work without it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At line 8295 in ai, we are building actionResult, and inside of that we are setting the action's label name as fmt.Sprintf("Agent Decision %s", decision.RunDetails.Id). Then we call handleAgentDecisionStreamResult, and that one passes actionResult to HandleAiAgentExecutionStart. Now startNode is overwritten with an action with label, e.g., "Agent Decision RNnBU2aY". Due to this, the later nodes in workflow that are trying to refer to the AI agent node with its original label can't find it, resulting in being unable to get any data from the agent node at all.