Skip to content

feat(conversations): Support reasoning/thinking message parts#117401

Merged
obostjancic merged 5 commits into
masterfrom
ognjenbostjancic/tet-2453-support-thinking-messages-in-product
Jun 15, 2026
Merged

feat(conversations): Support reasoning/thinking message parts#117401
obostjancic merged 5 commits into
masterfrom
ognjenbostjancic/tet-2453-support-thinking-messages-in-product

Conversation

@obostjancic

@obostjancic obostjancic commented Jun 11, 2026

Copy link
Copy Markdown
Member

Adds support for the OTel-aligned reasoning part type ({"type": "reasoning", "content": "..."}) so the Conversations UI can show a model's thinking separately from its answer.

Both the Python and TypeScript message normalizers now bucket reasoning parts apart from user-facing text and expose them as a distinct reasoning_text / reasoningText field. Reasoning is excluded from the collapsed text output, the conversation list lastOutput, and the "Copy as Markdown" export, so it never leaks into the answer. In the chat view, messagesPanel.tsx renders a collapsed-by-default "Thinking..." toggle above the assistant content.

Given a message with [{"type": "reasoning", ...}, {"type": "text", ...}], the answer shows only the text while the reasoning lives behind the toggle.

CleanShot 2026-06-12 at 13 18 23@2x

Closes TET-2453

@linear-code

linear-code Bot commented Jun 11, 2026

Copy link
Copy Markdown

TET-2453

@github-actions github-actions Bot added Scope: Frontend Automatically applied to PRs that change frontend components Scope: Backend Automatically applied to PRs that change backend components labels Jun 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

Add support for the OTel-aligned `reasoning` part type in both
Python and TypeScript message normalizers. Reasoning content is
separated from user-facing text so the Conversations UI can render
it in a collapsed, dimmed section.

Changes:
- ai_message_normalizer.py: Add reasoning_parts bucket and
  reasoning_text to AIOutputResult
- aiMessageNormalizer.ts: Mirror Python changes for reasoning parts
- conversationMessages.ts: Extract reasoning into ConversationMessage,
  exclude from markdown export
- messagesPanel.tsx: Add collapsible Thinking section with muted styling

Refs TET-2453
@obostjancic obostjancic force-pushed the ognjenbostjancic/tet-2453-support-thinking-messages-in-product branch from d4adeb0 to 588b4c5 Compare June 11, 2026 09:53
Render the reasoning 'Thinking...' label in muted monospace italic with a
trailing collapse caret, and rebuild the section from core layout/text
primitives (Button, Flex, Container, Text) instead of styled components.

Use the link button variant to drop the hover background and vertically
center the caret, and color the caret via the icon's muted variant.

Refs TET-2453
Co-Authored-By: Claude <noreply@anthropic.com>
Replace the repeated inline turn objects in the turnsToMessages and
mergeEmptyTurns specs with a makeTurn factory so new turn fields (like
reasoning) only need a default in one place. Also cover reasoning flowing
through to the assistant message.

Refs TET-2453
Co-Authored-By: Claude <noreply@anthropic.com>
Ognjen Bostjancic and others added 2 commits June 12, 2026 13:18
Merge the three agentName tests and two modelName tests into two
attribute-driven cases via an assistantFromAttributes helper, and drop
reasoning assertions that were duplicated across the parse, turn, and
integration layers. Reasoning is now covered once at the unit (parse) layer,
once at the turn layer, and via the markdown-exclusion test.

Refs TET-2453
Co-Authored-By: Claude <noreply@anthropic.com>
@obostjancic obostjancic marked this pull request as ready for review June 12, 2026 11:20
@obostjancic obostjancic requested review from a team as code owners June 12, 2026 11:20

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 40ab2f1. Configure here.

duration,
agentName: agentName || undefined,
modelName: modelName || undefined,
reasoning: turn.reasoning || undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reasoning-only turns omit assistant

Medium Severity

turnsToMessages only emits an assistant row when there is user-facing assistantContent or tool calls. A generation span with reasoning but no text and no tools never passes that gate, so parseAssistantContent can return reasoning that never reaches the UI or markdown pipeline.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 40ab2f1. Configure here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure if we would even want to show said spans.

@constantinius constantinius left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm! 🚀

@obostjancic obostjancic merged commit 4dc7114 into master Jun 15, 2026
74 checks passed
@obostjancic obostjancic deleted the ognjenbostjancic/tet-2453-support-thinking-messages-in-product branch June 15, 2026 10:44
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 Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants