Skip to content

handle EndTaskFrame, StopTaskFrame and CancelTaskFrame downstream#4006

Merged
aconchillo merged 2 commits intomainfrom
aleix/task-frame-flush-ordering
Mar 17, 2026
Merged

handle EndTaskFrame, StopTaskFrame and CancelTaskFrame downstream#4006
aconchillo merged 2 commits intomainfrom
aleix/task-frame-flush-ordering

Conversation

@aconchillo
Copy link
Contributor

@aconchillo aconchillo commented Mar 12, 2026

Summary

  • Fixed a race condition where EndTaskFrame (as a SystemFrame) could overtake in-flight frames and shut down the pipeline before pending work completed — e.g. an LLM function call response racing against EndFrame
  • EndTaskFrame and StopTaskFrame are now ControlFrames, so they flow through the pipeline behind pending frames, ensuring a full flush before shutdown
  • Added TaskSystemFrame(SystemFrame) base for CancelTaskFrame and InterruptionTaskFrame, which still need immediate propagation
  • The pipeline sink now catches EndTaskFrame and StopTaskFrame downstream and re-queues them upstream to the task source

Breaking Changes

  • TaskFrame is now a ControlFrame instead of SystemFrame. Custom code subclassing TaskFrame will see changed frame propagation behavior.
  • CancelTaskFrame and InterruptionTaskFrame now extend TaskSystemFrame instead of TaskFrame.

aconchillo added a commit that referenced this pull request Mar 12, 2026
@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 53.84615% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pipecat/pipeline/task.py 25.00% 12 Missing ⚠️
Files with missing lines Coverage Δ
src/pipecat/frames/frames.py 90.22% <100.00%> (+0.04%) ⬆️
src/pipecat/pipeline/task.py 79.95% <25.00%> (-1.24%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aconchillo aconchillo force-pushed the aleix/task-frame-flush-ordering branch from b546d5b to a62845b Compare March 12, 2026 06:21
aconchillo added a commit that referenced this pull request Mar 12, 2026
aconchillo added a commit that referenced this pull request Mar 12, 2026
@aconchillo aconchillo force-pushed the aleix/task-frame-flush-ordering branch from a62845b to 80b217f Compare March 12, 2026 18:32
EndTaskFrame and StopTaskFrame are now ControlFrames instead of
SystemFrames, so they flow through the pipeline and queue behind
pending work. This prevents races where EndFrame could overtake
in-flight frames (e.g. function call responses).

CancelTaskFrame and InterruptionTaskFrame remain SystemFrames
(via new TaskSystemFrame base): since they need immediate propagation.

The sink now catches EndTaskFrame, StopTaskFrame and CancelTaskFrame
downstream and re-queues it upstream to the task, ensuring the full
pipeline drains before shutdown begins.
@aconchillo aconchillo force-pushed the aleix/task-frame-flush-ordering branch from 80b217f to f6f08d1 Compare March 12, 2026 18:34
@aconchillo aconchillo changed the title Make EndTaskFrame a ControlFrame to ensure pipeline flush before shutdown handle EndTaskFrame, StopTaskFrame and CancelTaskFrame downstream Mar 12, 2026
Copy link
Contributor

@markbackman markbackman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Works cleanly when pushing EndTaskFrame upstream or downstream.

@aconchillo aconchillo merged commit 1a1d5e6 into main Mar 17, 2026
6 checks passed
@aconchillo aconchillo deleted the aleix/task-frame-flush-ordering branch March 17, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants