Assistant Function Call and Forget

Hey, I want to implement a solution where I want the Assistant API to call an API based on user message and then do not do anything in return. The called API will do the rest of the work.

Example:

User Message:
“Create a new user”

Assistant:
<calls an API to create user and the API’s response is printed on the Chat Interface as is>

I do not want the API’s response to go to GPT model.

@visitwritersco - Why don’t you capture the run id and thread id and cancel the run within your function. Additionally, you may also add custom messages onto the thread for context something like “User created”. In this way you can preserve context on thread when prompted and display nothing if the run status is Cancelled. It’s a workaround that isn’t recommended, but it does preserve context by programmatically adding it.

Here’s the thing: something must be returned to the run as a tool return, which generates an AI response output to the user if it is done calling tools (remember, the user could say “create five new users”, or “create a new user, then proceed to doing the next function”, for more iterative tool calls).

Otherwise, you leave a thread in a state with the user input message still, and a run with status “requires_action” until you terminate or expire that. Running the thread again puts it in an indeterminate state where the “create user” task looks like it hasn’t been performed yet, or the AI has no idea this was done, risking more calls, so, therefore, the thread and past chat would just have to be abandoned.

With chat completions, you can manufacture your own context on follow-up user input. You can make your own tool return, your own assistant response that was not actually generated, your new user input, all in the next turn that continues a chat but yet shows that the user’s question happened and action was successful.

2 Likes

Instead of using tool calling, I think you can prompt Assistant to generate structured output based on the API JSON schema, and then you take it from there.

As a developer, you’re in complete control of what you send back as the tool call output.

However, you’re going to have to return something so that the run doesn’t keep waiting. Whether it’s a Boolean to indicate status or something else is entirely up to you.