-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
Description
Please read this first
- Have you read the docs?Agents SDK docs - Yes
- Have you searched for related issues? Others may have had similar requests - Yes, no similar issues.
Describe the feature
With the current Realtime session implementation, when a function_call event is received, execution pauses until the function completes. This can cause long periods of silence if the function takes time to run. Supporting asynchronous function calls would allow the user to continue interacting with the model while the tool executes. According to the latest gpt-realtime release, the new model is well-equipped to handle such calls.
The update to the code is very straightforward.
This line:
openai-agents-python/src/agents/realtime/session.py
Lines 218 to 219 in cf1b933
| elif event.type == "function_call": | |
| await self._handle_tool_call(event) |
should be replaced with:
elif event.type == "function_call":
asyncio.create_task(self._handle_tool_call(event))or, in case of a parameter to control it:
elif event.type == "function_call":
if self.async:
asyncio.create_task(self._handle_tool_call(event))
else:
await self._handle_tool_call(event)