fix: await message confirmation interruption

This commit is contained in:
Xin Wang
2026-08-03 17:11:43 +08:00
parent 67389fc5a1
commit c3cb410c17
5 changed files with 48 additions and 9 deletions

View File

@@ -95,6 +95,7 @@ class BrainRuntime:
set_vision_scope: Callable[[dict[str, Any]], None] | None = None
vision_function: Any = None
set_input_enabled: Callable[[bool], None] | None = None
interrupt_output: Callable[[], Awaitable[None]] | None = None
apply_turn_config: (
Callable[[bool, dict[str, Any]], Awaitable[None]] | None
) = None

View File

@@ -19,7 +19,6 @@ from pipecat.flows import (
NodeConfig,
)
from pipecat.frames.frames import (
InterruptionFrame,
LLMRunFrame,
LLMUpdateSettingsFrame,
OutputTransportMessageUrgentFrame,
@@ -1098,10 +1097,12 @@ class WorkflowBrain(BaseBrain):
completion_policy == MESSAGE_CONFIRMATION
and result.action == "confirmed"
):
# The client-tool result closes the confirmation gate, while
# InterruptionFrame closes any speech still owned by this
# Message before the next node can enqueue new output.
await runtime.queue_frame(InterruptionFrame())
if runtime.interrupt_output is None:
raise RuntimeError("当前管线不支持中断 Message 确认语音")
# Keep the client-tool result as the confirmation gate, then
# wait for the pipeline-owned interruption boundary before the
# next node is allowed to enqueue new output.
await runtime.interrupt_output()
await self._emit_trace(
"message_completed",
nodeId=node_id,