I have not quite understood how to handle a user prompt that launches e.g. 2 functions.
After starting the run, and checking the steps (both of which are completed with the submit tool), in the message list I only see the assistant’s response to the last function
So far, I’ve only seen my tool functions called when a run returns with a “requires_action” status. The only time I’ve seen it not have a “requires_action” status is when the assistant concluded not to call any of my tool functions and either reuses the results of my last run or some other source (most likely because I did not require the assistant to use the tool functions).
BTW, I use non-streaming thread and follow with “create_and_poll” call. When processing the “requires_action”, my program loops through each tool functions requested, and then appends to an array of objects. Each object in the array has a “tool_call_id” and an “output” element.
for non-streaming, you are already polling when you are checking the run status. so as long as you handle requires action, that should be enough to handle parallel function call or consecutive function calls. it won’t complete until it finishes.
for streaming, it is kinda tricky but same principle. not sure which method you are using but you just need to make a loop, getting required actions, submit tools output and wait for response until it completes.
Blockquote but you just need to make a loop, getting required actions, submit tools output and wait for response until it completes.
That is what I am doing. I send submit tools to the two functions and in STEP RUNS I see them both completed, with a message created that only responds to the last of the 2 functions.
By monitoring LIST RUNS I see that at first the first one appears, and after executing it this one disappears and the second one appears.
I really don’t know how to handle this, it says in the documentation that the output to submit tool should only be sent once, but how do I send these 2 outputs without running a run? I don’t understand
So if I’m understanding your super-secret code , you are not accumulating all tool outputs to submit once. Instead you process one tool call and submit that output, and process the next tool and submit the output of that while using the same thread_id and run_id for both. Somehow, the assistant ignored the first tool output when the initial run completes. Does that summarize what you observed your assistant is doing?
Exactly. but I don’t know how to accumulate all the outputs and send them all at once, since for each function I have to do a submit tool to get my API to send me the response
If only get_orders responds. Why don’t you store the first output in a class variable and append it to the results of the second tool output before submitting the outputs to the LLM. Something like, if self.get_quotes is not None then append outputs to the API call and send it.
this is the problem. In list runs I only see the first function in required. Only after sending the output to the first function do I see the other function appear in list runs