Hey, is there a way to do a truly async tool call,...
# agents
g
Hey, is there a way to do a truly async tool call, where the agent invokes the tool but continues on without waiting for a response. When the response is received, the agent is able to process that?
✅ 1
p
I havent tried, but this should do it
@function_tool async def search_web(self, query: str, run_ctx: RunContext) -> str: """Called when user asks to search the web. Args: query: The query to search the web for. """ logger.info(f"Searching the web for {query}") asyncio.ensure_future(self._a_long_running_task(query, run_ctx)) return "I am finding some results for you, continue your conversation with the user. Don't call this function again based on the user response" async def _a_long_running_task(self, query: str, run_ctx: RunContext) -> str: """Simulate a long running task.""" await asyncio.sleep(15) output = f"I got some results for {query}" run_ctx.session.interrupt() await run_ctx.session.say(output)
g
Thanks will take a look!
r
I think that is similar to what Mario shared above
g
Thanks, both of you -- cc: @future-glass-56154