-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Best practices for long running tools? #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am thinking about this actively, but I want to make sure to do it right - so it may take a couple of weeks. For now, your main options are:
If you (or anyone) has suggestions on implementation, open to it! |
Thanks for the reply - its not clear what the right approach is. Tne idea I'm exploring right now:
The LLM could be instructed to use the ID to check in on the progress and get the intermediate outputs while its progressing and report back to the user. It would allow the LLM to work on other things in parallel and keep the user appraised of the progress? |
That could work - it totally depends on the UX you want. For example - Deep Research in ChatGPT kicks off a process, and sends occasional updates to the frontend to display to the user. But the user can't send messages while things are in progress. On the other hand, if you wanted to allow the user to be able to keep chatting while the task ran, your approach sounds great to me. |
The part that I'm not sure how to implement with my approach is the case where you trigger this long-running task, the LLM responds to the user, and then the user walks away, which means the LLM never gets a chance to come check on the task progress. So you may never get a status update until the user comes back and triggers another interaction with the agent. |
There's a few pieces there:
I guess I'd say - the LLM should only check on the task progress for the user. As long as the user is still active, you can periodically check for updates and update the message history. If they walk away, then only update the history when the task is done. (Sorry if this is abstract - I'm speaking in general terms since I don't know the specifics of your application) |
@rm-openai Thanks for providing this idea. Recently, I am trying to use this SDK to build a voice agent. I encountered into similar case too, where:
According to examples given in SDK docs, the voice agent will not interact with the user until it gets the tool result. Could you kindly give any suggestions on this case? |
@rm-openai Here is my test which simply return the tool call result with "Waiting...". And then push back the execution result to LLM.
Directly return long running tool output to request waiting:
-> LLM ->
Re-insert the previous tool call message and the real execution result:
-> LLM ->
This example shows it's possible to put the tool execution in background. And waiting an executing notification pushing back up agent. |
I'm building a few tools which require waiting on long running operations (10's of minutes or so), and I'm looking for suggestions on the best way to implement those in this framework.
One idea I have is to have the tool return a pointer that says, "Come back and check in in the future, and I can give you some intermediate results possibly."
Is there anything like this already built into the SDK or anything coming?
The text was updated successfully, but these errors were encountered: