Skip to content

feat(ai-monitoring): Return stored conversation titles from the list endpoint - #120665

Merged
vgrozdanic merged 1 commit into
masterfrom
feat/ai-conversation-list-titles
Jul 28, 2026
Merged

vgrozdanic merged 1 commit into
masterfrom
feat/ai-conversation-list-titles

Conversation

@vgrozdanic

@vgrozdanic vgrozdanic commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

Conversation titles have been written into AIConversationMetadata since title generation was hooked into the ingestion pipeline, but nothing ever read them back. The AI conversations list response now includes a title for each conversation.

The conversation details endpoint is deliberately untouched — adding a title there is a breaking change to its response shape and will be done as a follow up.

Resolving a title

This is where it gets a bit tricky, so bear with me....

Metadata rows are keyed on (project_id, sha256(conversation_id)), but the list endpoint groups by gen_ai.conversation.id across every project in the request, so a conversation on its own doesn't identify a row. The enrichment span query now also selects project.id, which gives the set of projects each conversation actually has spans in, and titles are matched against exactly those pairs.

This matters because a conversation id is only unique within a project. Matching on the id alone would let an unrelated conversation that happens to share an id in another project supply the title.

A conversation genuinely spanning several projects can have a row in each. The lowest project id with a stored title wins, so repeated requests return the same title rather than varying with row ordering. This is an edge case behavior, but we need to handle it :(

…endpoint

Titles generated into AIConversationMetadata were never read back. The AI conversations list response now carries a `title` field, resolved from the metadata row belonging to a project the conversation actually has spans in.

The field is always present and null when no title is stored, so existing clients are unaffected.
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 27, 2026
def _first_title(
titles: Mapping[tuple[str, int], str], conv_id: str, project_ids: Sequence[int]
) -> str | None:
"""Lowest project id with a stored title wins, so results are stable across requests."""

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.

technically conversation can span multiple projects, and we generate one title per conversation-project pair. It's an edge case, but let's rather handle it in a consistent way, than have some random bugs (if this ever even will happen)

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.

Wouldn't it be more coherent with how we generate these titles to pick the one that was generated first using title_source_timestamp?

@vgrozdanic
vgrozdanic marked this pull request as ready for review July 28, 2026 08:45
@vgrozdanic
vgrozdanic requested review from a team as code owners July 28, 2026 08:45
conversations_map, results["enrichment"]
)
self._apply_first_last_io(conversations_map, results["first_last_io"])
self._apply_titles(conversations_map, project_ids_by_conversation)

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.

Shall we feature flag this for rollout? Just in case something goes wrong

@vgrozdanic
vgrozdanic merged commit 37ddca3 into master Jul 28, 2026
89 checks passed
@vgrozdanic
vgrozdanic deleted the feat/ai-conversation-list-titles branch July 28, 2026 12:20
vgrozdanic added a commit that referenced this pull request Jul 29, 2026
…120746)

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`:

```jsonc
// 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.
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