Skip to content

feat(ai-monitoring): Return conversation title behind apiVersion=2 - #120746

Merged
vgrozdanic merged 2 commits into
masterfrom
feat/conversation-details-title
Jul 29, 2026
Merged

vgrozdanic merged 2 commits into
masterfrom
feat/conversation-details-title

Conversation

@vgrozdanic

@vgrozdanic vgrozdanic commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

Follow up to #120665, which added title to the conversations list and left the details endpoint alone because adding one there breaks its response shape.

That endpoint returns a bare array of spans, so there is nowhere to put a field that describes the conversation rather than a span. Passing apiVersion=2 now returns an object instead, with the spans moved under spans:

// no apiVersion, or apiVersion=1 — unchanged
[ {span}, {span} ]

// apiVersion=2
{
  "conversationId": "abc",
  "title": "Refund a duplicate charge",  // null when nothing has been titled yet
  "spans": [ {span}, {span} ]
}

Requests that don't send the parameter keep the old array, so this lands without touching the UI. The frontend switches over in its own PR, and only once it pins apiVersion=2 explicitly does flipping the default become safe for cached bundles. An unsupported value is a 400 rather than a silent fallback. Pagination is unaffected either way — cursors live in the Link header, not the body.

The details endpoint returns a bare list of spans, which leaves no room for conversation-level fields. Passing apiVersion=2 now returns an object with conversationId, title, and the spans under data. Requests without the parameter keep the existing list response, so the shape can be broken in a follow up once clients have moved over.

Titles are keyed on (project_id, conversation_id_hash), so they are resolved against the projects of the returned spans. When a conversation id is titled in more than one project, the earliest title_source_timestamp wins, matching the earliest-span rule the title generation task already applies.
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 28, 2026
from rest_framework import serializers


class OrganizationAIConversationDetailsSerializer(serializers.Serializer):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This will go away once we have updated our clients (MCP and frontend to the newest version)

@vgrozdanic
vgrozdanic marked this pull request as ready for review July 29, 2026 09:20
@vgrozdanic
vgrozdanic requested a review from a team as a code owner July 29, 2026 09: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.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4627097. Configure here.

Comment thread src/sentry/ai_monitoring/utils.py Resolved

conversationId: str
title: str | None
data: list[dict[str, Any]]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does it make sense for us to call this something more specific, e.g. spans?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we can 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Renamed to spans.

Use a more specific key than data in the apiVersion=2 response body.
@vgrozdanic
vgrozdanic merged commit 4e5409a into master Jul 29, 2026
65 checks passed
@vgrozdanic
vgrozdanic deleted the feat/conversation-details-title branch July 29, 2026 12:04
vgrozdanic added a commit that referenced this pull request Aug 4, 2026
)

Before #120746 we had no way of
easily extending API response for conversation details, but now we do.
`apiVersion` was just a temporary hack to update all the known clients
to the new conversation response. Those clients are now updated, and we
can stop returning old response from the API endpoint.
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