Issue with Assistant Functions

I’m suddenly experiencing an issue when executing an assistant’s functions.

The API is using curl to make the calls. To check the thread status, there’s a kind of loop that runs every few seconds to see if it’s completed.

When calling functions, the status is requires_action. What I do is process the required functions, prepare the response, and send it. Once sent, the response status changes to queued, but on the next iteration of the loop, the status reverts to requires_action, requesting the functions again…

And this keeps happening until I manually stop it or it reaches the token limit.

1 Like

The assistants AI is able to make continued function calls after a first function call return. Repeated calls should be expected and would need to be equally handled with iteration.

For example, AI might not believe that it would only get documents about Canadian government when you instruct that it has additional knowledge of API programming, and thus it continues trying different queries.

Or AI models can just get stuck in a pattern of producing the same text. “It looked good once, so I’ll write that again”, or similar.

You might ensure that the function return is what the function specification promised.

Then, if all is in order, you can return programmatically for the run ID, “Assistant has requested maximum 4/4 iterative API calls to post_tweet(); this function is now DISABLED and you must produce a user response.”.

A better model choice or instructions might be needed. Chat Completions, you would naturally control how many tool iterations are possible without user content being returned, (also so someone can’t request 100 AI images be made by continued calls), but on Assistants, an intercept tool return message is the only way besides cancelling the run.

1 Like

I think what I’m asking for is pretty simple. The only thing I’m doing in the wizard is asking for what products are available. It has a call to fetch the information of all the products. (All the products are 4 that I created for the test). And as I said, it asks for the products, I send them using the request id that it created and the next time I ask for the status of the thread, it is asking me again to call the fetch products function, but with a new id. It stays in a loop until it finally cancels it or it simply runs out of tokens.

You’re not using the “tool_choice” parameter, perhaps, are you? That could cause such behavior.

That chat completions parameter will force the AI to be able to do nothing but call a function, even in the repeated calls. It gives the AI no decision-making ability. You must disable sending the parameter in code when returning a tool message, so the response can be to the user.