deferred_user_turn_stop_strategy

Wrapper that defers a stop strategy’s finalization to another strategy.

class pipecat.turns.user_stop.deferred_user_turn_stop_strategy.DeferredUserTurnStopStrategy(inner: BaseUserTurnStopStrategy, **kwargs)[source]

Bases: BaseUserTurnStopStrategy

Wraps a stop strategy and suppresses its on_user_turn_stopped event.

Event subscriptions added to the wrapper are forwarded directly to the inner strategy, except for on_user_turn_stopped, which is dropped. The inner strategy’s frame-side and inference-triggered events therefore reach external listeners (the controller, etc.) unchanged; finalization is left to another strategy in the chain such as LLMTurnCompletionUserTurnStopStrategy.

Use the deferred() helper for ergonomic construction:

stop=[
    deferred(TurnAnalyzerUserTurnStopStrategy(turn_analyzer=...)),
    LLMTurnCompletionUserTurnStopStrategy(),
]
__init__(inner: BaseUserTurnStopStrategy, **kwargs)[source]

Initialize the deferred wrapper.

Parameters:
  • inner – The strategy whose finalization should be deferred.

  • **kwargs – Additional keyword arguments forwarded to the base class.

property inner: BaseUserTurnStopStrategy

Return the wrapped strategy.

add_event_handler(event_name: str, handler)[source]

Forward event subscriptions to the inner strategy.

on_user_turn_stopped is silently dropped — that’s the whole point of the wrapper. Every other event handler is attached to the inner strategy directly, so the inner’s events reach the listener without any per-event proxy method on the wrapper.

async setup(task_manager: BaseTaskManager)[source]

Set up the inner strategy.

async cleanup()[source]

Clean up the inner strategy.

async reset()[source]

Reset the inner strategy for a new user turn.

async process_frame(frame: Frame) ProcessFrameResult | None[source]

Forward frame processing to the inner strategy.

pipecat.turns.user_stop.deferred_user_turn_stop_strategy.deferred(strategy: BaseUserTurnStopStrategy) DeferredUserTurnStopStrategy[source]

Defer this stop strategy’s finalization to another strategy.

Wraps strategy in a DeferredUserTurnStopStrategy: the inner strategy continues to drive inference-triggered events, but its on_user_turn_stopped event is suppressed. Use when another strategy in the chain (e.g. LLMTurnCompletionUserTurnStopStrategy) owns finalization.

Example:

stop=[
    deferred(TurnAnalyzerUserTurnStopStrategy(turn_analyzer=...)),
    LLMTurnCompletionUserTurnStopStrategy(),
]
Parameters:

strategy – The stop strategy to defer.

Returns:

A wrapper that exposes the inner strategy’s behavior with finalization suppressed.