Skip to content

fix(spans): Don't drop segments when title generation fails - #129084

Open
enochtangg wants to merge 2 commits into
masterfrom
enochtang/stream-1999-dont-drop-segments-on-title-failure
Open

enochtangg wants to merge 2 commits into
masterfrom
enochtang/stream-1999-dont-drop-segments-on-title-failure

Conversation

@enochtangg

@enochtangg enochtangg commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

When queuing the AI conversation title task fails, process_segment fails too, and every span in that segment is dropped. This wraps the title generation call in a try/except so a failure there only skips the title.

The error we're seeing is SENTRY-5SB5: UnicodeEncodeError: surrogates not allowed. Although infrequent, some AI messages end up with an emoji stored as two separate surrogate characters, and msgpack can't encode that when the title task is queued. The task fails with no retry, and the segment is lost.

`spawn_conversation_title_generation` runs inside `process_segment`, and
nothing caught its errors. When queuing the title task failed (for
example `UnicodeEncodeError` on a message with a split emoji), the whole
`process_segment` task failed and every span in the segment was dropped.

Titles are optional, so catch and log the error and keep processing the
segment.

Fixes SENTRY-5SB5
Refs STREAM-1999

Co-Authored-By: Claude <noreply@anthropic.com>
@enochtangg
enochtangg requested review from a team as code owners October 28, 2026 20:06
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants