Error using Asynchronous AI Agents in Workflow

Hi Retool Team - I am having some errors using AI Agents in Workflows. I understand this is in BETA, so perhaps something is not working correctly right now.
I need to be able to asynchronously launch an AI Agent and poll using the instructions here:

The workflow worked ok when i ran it step by step in the editor :+1: . But when I run the workflow using the "Run" button or by queuing the Workflow using the Workflow block, then it always fails in an unusual way :smiling_face_with_tear: . There are no errors in the log, so whatever the issue is, is not available to me to resolve - it just silently fails. I can see the AI Agent running in the background however, but after just over 60 seconds in the Workflow it just stops.

Here is a screenshot of the History showing the odd behaviour and lack of error messaging.

Just to clarify, it does Invoke the AI Agent in the background and that completes successfully, but the Workflow returns an error and dies during the Invoke step.

If you could look into this I would be very grateful. I can provide the id of the Workflow here:
83bfb70b-f0a7-4c92-b969-9aee9bc93c6f

Many Thanks,
Jon Steele

1 Like

Just FYI: I have created a Retool support ticket for this now. I will update with details if we find a resolution for the issue and share that here. Thanks

Hi @Jon_Steele, just following up from our support thread for others to see.

The polling loop in the guide from our docs is a starting template that throws an error after a fixed number of iterations, and the surrounding code has its own timeout. When the agent takes longer than the polling window, the loop exits or times out, and the way the result is structured could lead to the error not showing up in your run history.

I can't see if you changed the iterations or the sleep duration in your screenshot, but depending on those values, that could explain the ~60 second eventual timeout.

Ultimately, we released these docs in October for invoking an agent where polling wasn't necessary, and is easier to setup:

None of this is to say that the original method can't be used, but I believe it would take some more fine tuning to work for your use case.

1 Like

Hi @Mike_M yes I changed the polling so it would have taken a long time to throw the timeout error, that timeout throw was not in play. Also we know this to be the case as the Workflow did work when manually running the blocks 1 at a time in the editor. Do you see what I mean?

I think all that being the case, maybe we can agree that the async polling method does not currently work in workflows and should be avoided right now, with preference for the sync method.

Perhaps the docs can be updated to prevent others from trying to use async?

Thanks

1 Like