powerful-dog-59275
09/08/2025, 1:32 PMgenerateReply() inside a Tool execute , and then return some instructions out of the tool, if you interrupt between the generateReply and the return, the agent will completely freeze and there appears to be no way of getting the Agent back. Its dead at that point. If you interrupt the agent between the generateReply and the tool return instructions, the whole agent is unrecoverable. Heres an example:
execute: async (_params, context) => {
const { utterance } = _params as { utterance: string };
const handle = context.sessionManager.session?.generateReply({
instructions: `Agent Instructions: You need to say this verbatim to the caller: ${utterance}`,
});
await handle?.waitForPlayout();
// Have the caller interrupt and say something after the generateReply utterance and between the tool return instruction utterance
return `Agent Instructions: Now inform the caller you are looking into their account settings.`;
},powerful-dog-59275
09/08/2025, 8:10 PMAgentStateChanged goes from speaking -> listening -> thinking -> Executing LLM tool call -> user interrupts/interjects something during the Execution the entire Agent freezes, and is unrecoverable. This is irregardless of using the generateReply
execute: async ({ location }, { ctx }) => {
//simulating an api call
await new Promise(resolve => setTimeout(resolve, 5000));
return { weather: 'sunny', temperatureF: 70 };
},powerful-dog-59275
09/08/2025, 8:28 PMrefined-appointment-81829
09/08/2025, 9:17 PMaloof-notebook-98064
09/08/2025, 9:18 PMpowerful-dog-59275
09/10/2025, 6:01 PMaloof-notebook-98064
09/11/2025, 9:55 PMpowerful-dog-59275
09/11/2025, 10:18 PMpowerful-dog-59275
09/12/2025, 3:29 PMaloof-notebook-98064
09/16/2025, 6:14 PMpowerful-dog-59275
09/16/2025, 6:14 PMaloof-notebook-98064
09/18/2025, 3:02 AM1.0.4powerful-dog-59275
09/18/2025, 11:56 AMpowerful-dog-59275
09/19/2025, 12:06 AM"Cannot call 'SpeechHandle.waitForPlayout()' from inside the function tool 'submit_answer'. This creates a circular wait: the speech handle is waiting for the function tool to complete, while the function tool is simultaneously waiting for the speech handle.\nTo wait for the assistant's spoken response prior to running this tool, use RunContext.wait_for_playout() instead."
If We then swap out the SpeechHandle for the suggested RunContext, this also never utters the speech.
This is especially noticeable if you have some sort of API call inside the Tool after the generateReply.
Any thoughts or help?aloof-notebook-98064
09/19/2025, 12:08 AMpowerful-dog-59275
09/19/2025, 12:08 AMpowerful-dog-59275
09/19/2025, 12:21 AMexecute: async ({ location }, { ctx }) => {
const handle = ctx.session?.generateReply({
instructions:
'AGENT INSTRUCTIONS: You must strictly say, "Got it Batman"',
toolChoice: 'none',
allowInterruptions: true,
});
await handle?.waitForPlayout();
return { weather: 'sunny', temperatureF: 70 };
},
So if i run this, then it throws,
function: "lookupWeather"
speech_id: "speech_cf618276-10b"
error: "Cannot call 'SpeechHandle.waitForPlayout()' from inside the function tool 'lookupWeather'. This creates a circular wait: the speech handle is waiting for the function tool to complete, while the function tool is simultaneously waiting for the speech handle.\nTo wait for the assistant's spoken response prior to running this tool, use RunContext.wait_for_playout() instead."powerful-dog-59275
09/19/2025, 12:22 AMvoice.RunContext.waitForPlayout
execute: async ({ location }, { ctx }) => {
ctx.session?.generateReply({
instructions:
'AGENT INSTRUCTIONS: You must strictly say, "Got it Batman"',
toolChoice: 'none',
allowInterruptions: true,
});
await voice.RunContext?.waitForPlayout();
return { weather: 'sunny', temperatureF: 70 };
},powerful-dog-59275
09/19/2025, 12:23 AMfunction: "lookupWeather"
speech_id: "speech_2107302e-ee6"
error: "voice.RunContext?.waitForPlayout is not a function"powerful-dog-59275
09/19/2025, 12:26 AMaloof-notebook-98064
09/19/2025, 3:26 AMaloof-notebook-98064
09/19/2025, 3:27 AMawait voice.RunContext?.waitForPlayout(); -> await ctx.waitForPlayout();powerful-dog-59275
09/19/2025, 12:05 PMsay() will throw error
exception occurred while executing tool
function: "lookupWeather"
speech_id: "speech_9a04c081-52b"
error: "trying to generate speech from text without a TTS model"powerful-dog-59275
09/19/2025, 12:06 PMRunContext for ctx.waitForPlayout() also does not work and skips generateReply speech
execute: async ({ location }, { ctx }) => {
ctx.session?.generateReply({
instructions:
'AGENT INSTRUCTIONS: You must strictly say, "Got it Batman"',
toolChoice: 'none',
allowInterruptions: true,
});
await ctx?.waitForPlayout();
return { weather: 'sunny', temperatureF: 70 };
}powerful-dog-59275
09/19/2025, 12:08 PMgenerateReply within a tool post 1.0.4?broad-hairdresser-84880
09/19/2025, 12:12 PMpowerful-dog-59275
09/19/2025, 12:17 PMpreambles no longer being spoken, Tool call return taking precedence over it.aloof-notebook-98064
09/19/2025, 4:36 PMaloof-notebook-98064
09/19/2025, 4:36 PMaloof-notebook-98064
09/19/2025, 4:37 PMpowerful-dog-59275
09/19/2025, 4:38 PMpowerful-dog-59275
09/19/2025, 4:38 PMpowerful-dog-59275
09/19/2025, 4:39 PMaloof-notebook-98064
09/19/2025, 4:39 PM