handle EndTaskFrame, StopTaskFrame and CancelTaskFrame downstream#4006
Merged
aconchillo merged 2 commits intomainfrom Mar 17, 2026
Merged
handle EndTaskFrame, StopTaskFrame and CancelTaskFrame downstream#4006aconchillo merged 2 commits intomainfrom
aconchillo merged 2 commits intomainfrom
Conversation
aconchillo
added a commit
that referenced
this pull request
Mar 12, 2026
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
b546d5b to
a62845b
Compare
aconchillo
added a commit
that referenced
this pull request
Mar 12, 2026
aconchillo
added a commit
that referenced
this pull request
Mar 12, 2026
a62845b to
80b217f
Compare
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.
80b217f to
f6f08d1
Compare
markbackman
approved these changes
Mar 17, 2026
Contributor
markbackman
left a comment
There was a problem hiding this comment.
LGTM. Works cleanly when pushing EndTaskFrame upstream or downstream.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EndTaskFrame(as aSystemFrame) could overtake in-flight frames and shut down the pipeline before pending work completed — e.g. an LLM function call response racing againstEndFrameEndTaskFrameandStopTaskFrameare nowControlFrames, so they flow through the pipeline behind pending frames, ensuring a full flush before shutdownTaskSystemFrame(SystemFrame)base forCancelTaskFrameandInterruptionTaskFrame, which still need immediate propagationEndTaskFrameandStopTaskFramedownstream and re-queues them upstream to the task sourceBreaking Changes
TaskFrameis now aControlFrameinstead ofSystemFrame. Custom code subclassingTaskFramewill see changed frame propagation behavior.CancelTaskFrameandInterruptionTaskFramenow extendTaskSystemFrameinstead ofTaskFrame.