How to Retry a Gemini Module Until Output Is Valid (With a Conditional Break)

I’m trying to build a loop in Make where a Google Gemini module keeps retrying until it returns a valid output.

Right now, Gemini sometimes returns a null, incomplete, or incorrect response. I’m checking the output using a text parser and a few conditions. If those conditions fail, it means Gemini didn’t generate the required output. Also, please note Gemini module doesn’t throw error in such cases.

What I want is:
If the output is invalid → retry Gemini again, and keep retrying until the output is correct.

I tried using the Repeater module, but it always repeats a fixed number of times and I couldn’t find a way to break the loop once the output becomes valid. I’ve been stuck on this for a week.

Is there a way to build a retry loop with a conditional break in Make?
Or is there another pattern/module I should be using to achieve this behavior?

Any guidance would be greatly appreciated.

Hey there,

you can’t create a do-until loop inside a scenario unfortunately (or any loop for that matter).

What you can try is create a subscenario that keeps retriggering itself until the output is valid and then returns it to the main scenario.

Hmm… so no way to achieve this?

1 Like

To achieve a “loop” with your repeater module, you need to “close” the loop with an aggregator module.

To “break” out of a “loop”, you’ll need to use a module to throw an error, to proceed down an error route.

Have you seen these previous discussions?

Your question may have already been answered in these similar threads:

You can search this forum for existing answers, and also use the documentation in the Help Centre to get to a solution faster, and also help keep the forum organised. Thanks for your cooperation!

Still require assistance?

If the previous threads above does not answer your question, please edit your question and provide additional details to demonstrate the difference between your question and the duplicate discussions.

Hope this helps! If you are still having trouble, please provide more details.

@samliew