How do I determine if the Assistant is done asking questions?

I am using the Assistants API for having an assistant ask the user some questions and once the necessary information has been gathered, I want to replace the user’s message input with a call to action button (eg “Continue”) which will take them to another part of the app.

In my assistant instructions I end it with: “After you have gathered all the necessary information, ask the user to click Continue to go to the next step.”

The above just results in the assistant returning this info but I do not see anything in the stream payload to allow me to determine that the current run is the one in which they are done asking questions.
I am wondering what the best way is to determine that the assistant has reached this step. Yes, I could parse the assistant text output and look for something like “continue to the next step” but that feels very fragile.
I have also tried telling the assistant to call a function, in which I guess I could cancel(?) the run, but that seems to always just results in some odd output from the assistant.

Any insights on what is the recommended way to determine if the assistant is done asking questions would be appreciated.

Thanks!

The correct way to do this is to create a function that the assistant can call when the task is over. So the assistant asks questions until it believes the conversation should be over, at which point it calls a function that lets you know the conversation should be over.

After calling the function, the assistant will be expecting an output from the function to then send a reply to the user, but if you are using the assistants API in your own app, you choose which messages to show to the user and which not to. You can choose to return to the assistant “The conversation was ended successfuly” or you can choose to not even send the response if you will not use the thread anymore because you already got what you wanted, a notification that the conversation is over. At this point, you can pop the user to the new part of your app.