great-gpu-99842
10/29/2025, 9:12 AMuser: "I want to know the weather in Tokyo"
assistant → function call: get_weather("Tokyo")
assistant → "the weather is good" # this is paint message not generated from tool call output
tool → get_weather result: {"temp": 22, "condition": "Sunny"}
assistant → "The weather in Tokyo is 22°C and sunny."
I try to ask chatgpt the reason for this behavior, it replies
While your tool is still processing, the model can still continue generating messages — for example:
System messages like "Let me check that for you…"
Clarification or reasoning text (if streaming is on)
Partial outputs, if the LLM is continuing a response stream
This is because LiveKit Agents are concurrent — the function tool runs in one task, while the model's conversation stream remains open in another.
Can you guys confirm whether the answer is valid or not?
If valid, then it should be a very serious bug in livekit agent right?
since we expect livekit agent performa as below:
eg.
user: "I want to know the weather in Tokyo"
assistant → function call: get_weather("Tokyo")
tool → get_weather result: {"temp": 22, "condition": "Sunny"}
assistant → "The weather in Tokyo is 22°C and sunny."lively-winter-88668
10/29/2025, 10:44 AMgpt-realtime model, and the only response comes from the tool output. How are you getting the duplicate responses?great-gpu-99842
10/30/2025, 6:00 AMAgent(llm=openai.realtime.RealtimeModel(
model="gpt-realtime",
voice="marin",
turn_detection= SemanticVad(
type="semantic_vad",
create_response=True,
interrupt_response=True,
eagerness="low",
)
temperature=0.6,
input_audio_noise_reduction="far_field",
input_audio_transcription=AudioTranscription(language=lang, model="whisper-1"),
max_session_duration=20 * 60,
))
with yougreat-gpu-99842
10/30/2025, 6:11 AMgreat-gpu-99842
11/04/2025, 12:31 AMlively-winter-88668
11/04/2025, 8:52 AMon_user_turn_completedgreat-gpu-99842
11/06/2025, 9:34 AMlively-winter-88668
11/06/2025, 10:11 AMgreat-gpu-99842
11/06/2025, 10:55 AMgreat-gpu-99842
11/06/2025, 11:36 AMgreat-gpu-99842
11/06/2025, 11:44 AMgpt-realtime model, can you add long sleep time inside the function tool?
I suspect it happens when long time processing in function calllively-winter-88668
11/07/2025, 2:14 PMgpt-realtime . Added a 10 second delay to the temperature conversion function call, await asyncio.sleep(10) , and repeatedly asked for temperature conversions. Consistently the agent would wait 10 seconds, then respond to my question - what behaviour do you see differently?great-gpu-99842
11/11/2025, 7:37 AMgreat-gpu-99842
11/14/2025, 4:20 AMgreat-gpu-99842
11/14/2025, 4:23 AMlively-winter-88668
11/14/2025, 11:08 AMasyncio.sleep(10) the speech continues but the weather is not returned for the required 10 seconds. For a real weather API call, an async HTTP client could be used.colossal-airport-32984
11/14/2025, 2:44 PMuser: "I want to know the weather in Tokyo"
assistant → function call: get_weather("Tokyo")
PARALLEL: assistant → "Let me tell you the weather" # this message not generated from tool call output
PARALLEL: tool → get_weather result: {"temp": 22, "condition": "Sunny"}
assistant → "The weather in Tokyo is 22°C and sunny. "
But what maybe a lot of developers might want in this situation is
user: "I want to know the weather in Tokyo"
assistant → function call: get_weather("Tokyo")
tool → get_weather result: {"temp": 22, "condition": "Sunny"}
assistant → "The weather in Tokyo is 22°C and sunny."
Now that's not to say that all developers would want that, but in our use case, its definately desirable, as in our business case we are seeing sometimes something less user friendly like
user: "I want to know the weather in Tokyo"
assistant → function call: get_weather("Tokyo")
PARALLEL: assistant → "I do not know the weather."
PARALLEL: tool → get_weather result: {"temp": 22, "condition": "Sunny"}
assistant → "The weather in Tokyo is 22°C and sunny. "
so we definately would prefer the model to not say anything until tool calls are complete.
Whether the agent pauses or not, as you say, likely comes down to whether the tool call is blocking the asycio loop or not, but that is not our main concern. What we are wondering is if there is a way to ensure that order of operation is tool call --> message
My understanding of the underlying OpenAI Realtime model is that it can generate both messages and tool calls simultanously, and as far as I can see they expose no options to constraint it to prioritise tool calls, so as far as I can see we can either
• Set the code to interrupt the speech whlilst tool call is generating
user: "I want to know the weather in Tokyo"
assistant → function call: get_weather("Tokyo")
PARALLEL: assistant → "Let me-" # INTERRUPT via session.interrupt
PARALLEL: tool → get_weather result: {"temp": 22, "condition": "Sunny"}
assistant → "The weather in Tokyo is 22°C and sunny. "
• Or try and prompt the realtime API "Please always call the get_weather() without generating a speech message simulatnously - although I have no idea if that would work
I also just wanted to confirm that indeed the intention is that we wait for messages to complete whilst in background performing tool calls?
The reason we raise this to the livekit team rather than simply raising a PR internally, is that it looks to me like this issue has got more common recently for us- we assume due to https://github.com/livekit/agents/pull/3511 - as it seems like that PR removes the INTERRUPT in favour of await for the initial message to complete - does that agree with your understanding?
I think this is a valid design choice, but it seems to me that depending on the use case, developers may prefer the old behaviour - so having this as an option ("await_message_completion_during_tool_call: bool") might be favourable?colossal-airport-32984
11/16/2025, 10:10 PMcolossal-airport-32984
11/16/2025, 10:12 PMcolossal-airport-32984
11/17/2025, 6:18 AMresponse.output_item.added" events for clarity - Terry shared them with me so I attach them here
In the example Terry shared the pure message "of course! let me" and the function call for "lookup_weather" are added consecutively before any further livekit logs occur - which at least confirms our suspicion that the openai model is creating both message and tool call at once (and then livekit is awaiting the former message to finish even while a new message from tool call is ready)
2025-11-17 11:00:00,630 - DEBUG __mp_main__ - Response output item added: type=message {"item_type": "message", "item_id": "item_Ccip6vtfzDLWeDwOEHibO", "response_id": "resp_Ccip6N6o5erKW1FbqGMJ3", "pid": 15830, "job_id": "AJ_SjrGpqeDd6ry"}
2025-11-17 11:00:01,652 - DEBUG __mp_main__ - Response output item added: type=function_call {"item_type": "function_call", "item_id":lively-winter-88668
11/17/2025, 11:15 AMawait_message_completion_during_tool_call does sound like a good idea to me, based on your explanation but I'm not in a position to say whether it is practical from an implementation standpoint. I recommend raising an issue in the agent repo, flagging that this is a regression caused by https://github.com/livekit/agents/pull/3511 (maybe 'regression' is the wrong word, but you know what I mean). At this point, it feels like it needs the eyes of the engineering team but although they often do respond in this community forum, obviously they have a lot of asks on their time.colossal-airport-32984
11/17/2025, 11:17 AMcolossal-airport-32984
11/17/2025, 4:09 PMjolly-air-155
11/18/2025, 2:58 AM