The Observer pattern in Pipecat allows non-intrusive monitoring of frames as they flow through the pipeline. Observers can watch frame traffic without affecting the pipeline’s core functionality.
DEPRECATED: The old observer pattern with individual parameters
(on_push_frame(src, dst, frame, direction, timestamp)) is deprecated. Use
the new pattern with data objects (on_push_frame(data: FramePushed))
instead.
Base Observer
All observers must inherit from BaseObserver and can implement these methods:
on_push_frame(data: FramePushed): Called when a frame is pushed from one processor to another
on_process_frame(data: FrameProcessed): Called when a frame is being processed by a processor
on_pipeline_started(): Called after the StartFrame has been processed by all processors in the pipeline
Available Observers
Pipecat provides several built-in observers:
- LLMLogObserver: Logs LLM activity and responses
- TranscriptionLogObserver: Logs speech-to-text transcription events
- RTVIObserver: Converts internal frames to RTVI protocol messages for server to client messaging
- StartupTimingObserver: Measures processor startup times and transport readiness
- UserBotLatencyObserver: Measures user-to-bot response latency
- TurnTrackingObserver: Tracks conversation turns and events
Using Multiple Observers
You can attach multiple observers to a pipeline task. Each observer will be notified of all frames:
Example: Debug Observer
Here’s an example observer that logs interruptions and bot speaking events:
Common Use Cases
Observers are particularly useful for:
- Debugging frame flow
- Logging specific events
- Monitoring pipeline behavior
- Collecting metrics
- Converting internal frames to external messages