Skip to content

fix(conversation): Remove trailing empty turn during sanitize#551

Merged
JeanMertz merged 3 commits intomainfrom
prr118
Apr 14, 2026
Merged

fix(conversation): Remove trailing empty turn during sanitize#551
JeanMertz merged 3 commits intomainfrom
prr118

Conversation

@JeanMertz
Copy link
Copy Markdown
Collaborator

When a turn is interrupted (e.g. the ChatRequest is popped before streaming begins), a lone TurnStart is left at the end of the stream. Previously, sanitize() did not account for this case, meaning the orphaned TurnStart would persist and corrupt the turn index after re-normalization.

trim_trailing_empty_turn is now called as part of sanitize(), cleaning up any trailing TurnStart that has no following events before normalize_turn_starts runs.

When a turn is interrupted (e.g. the `ChatRequest` is popped before
streaming begins), a lone `TurnStart` is left at the end of the stream.
Previously, `sanitize()` did not account for this case, meaning the
orphaned `TurnStart` would persist and corrupt the turn index after
re-normalization.

`trim_trailing_empty_turn` is now called as part of `sanitize()`,
cleaning up any trailing `TurnStart` that has no following events before
`normalize_turn_starts` runs.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz JeanMertz marked this pull request as ready for review April 14, 2026 07:02
Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz JeanMertz merged commit fbc9f1b into main Apr 14, 2026
13 checks passed
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.

1 participant