fix: release input mute after async client tools

This commit is contained in:
Xin Wang
2026-08-06 00:12:34 +08:00
parent 0c0a51da95
commit 90bb27a377
2 changed files with 123 additions and 4 deletions
+22 -4
View File
@@ -257,8 +257,12 @@ class UserInputProcessor(FrameProcessor):
return
if self._should_ignore_input():
logger.debug("通话正在结束,忽略后续文字输入")
await self._emit_result(user_input.input_id, "error", "当前不能接收新的用户输入")
logger.debug("当前会话输入已暂停,忽略用户输入")
await self._emit_result(
user_input.input_id,
"error",
"当前暂不能接收新的用户输入",
)
return
await self._call_event_handler("on_user_input", user_input)
@@ -438,8 +442,22 @@ class ToolInterruptionUserMuteStrategy(BaseUserMuteStrategy):
elif isinstance(frame, FunctionCallResultFrame):
call = self._calls.get(frame.tool_call_id)
if call is not None:
call.tool_finished = True
self._release_completed()
properties = frame.properties
is_final = properties.is_final if properties else True
if is_final:
call.tool_finished = True
run_llm = (
properties.run_llm
if properties and properties.run_llm is not None
else frame.run_llm
)
if run_llm is False and not call.response_started:
# A tool-only result has no following bot response whose
# speech boundary could release the mute. If a preamble
# is already playing, BotStoppedSpeakingFrame still owns
# the release so allow_interruptions=False is respected.
call.response_finished = True
self._release_completed()
elif isinstance(frame, FunctionCallCancelFrame):
# A canceled call cannot reliably produce a follow-up response.
self._calls.pop(frame.tool_call_id, None)