Skip to content

feat(attributes): Add schema for gen_ai.extract output - #835

Merged
andreiborza merged 11 commits into
mainfrom
ab/gen-ai-extract-output-messages-schema
Nov 25, 2026
Merged

andreiborza merged 11 commits into
mainfrom
ab/gen-ai-extract-output-messages-schema

Conversation

@andreiborza

@andreiborza andreiborza commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

What

Adds an OpenAPI schema and generated types for the shape that gen_ai.output.messages has on gen_ai.extract spans. The schema follows the Cloudflare schemas for Clairic (input, output). truncated is now optional, because not all providers return it (for example the Vercel AI SDK).

Why

The extract shape from #728 had only a text description. SDKs and the product need types for it, as they have for the chat shape. #832 does the same for gen_ai.input.messages.

@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-conventions Ready Ready Preview Nov 25, 2026 11:38am UTC

Request Review

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Attributes

  • Add schema for gen_ai.extract output by andreiborza and claude in #835
  • Add schema for gen_ai.extract input by andreiborza and claude in #832
  • Add db.response.returned_rows by BYK with sentry-junior in #826
  • Add http.response.delivery_type and deprecate http.response_delivery_type by msonnb with sentry-junior in #825
  • Add schema for chat-based gen_ai.input.messages by alexander-alderman-webb in #820

Bug Fixes 🐛

  • (docs) Stop long attribute names from overflowing on mobile by JPeer264 and Lms24 with sentry-junior in #821

🤖 This preview updates automatically when you update the PR.

@andreiborza andreiborza changed the title feat(attributes): Add schema for extract-based gen_ai.output.messages feat(attributes): Add schema for gen_ai.extract output Nov 24, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 using default effort 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 a918122. Configure here.

@ArthurKnaus ArthurKnaus left a comment

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.

Looks good product wise 🙌

},
"type": "array"
},
"ExtractOutputMessage": {

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.

Let's call this ExtractResponse

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 ExtractResponse in e75a834

Comment on lines +17 to +24
"anyOf": [
{
"$ref": "./shared/gen_ai_chat_message.openapi.json#/components/schemas/ChatMessage"
},
{
"$ref": "#/components/schemas/ExtractOutputMessage"
}
]

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.

Analogous to #832 (comment) we can make this nicer if it's always a singleton

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.

Moved the union to list level with the one-item rule in 6dddc26

…put-messages-schema

# Conflicts:
#	python/src/sentry_conventions/attributes.py
@andreiborza
andreiborza merged commit 972eb6a into main Nov 25, 2026
16 checks passed
@andreiborza
andreiborza deleted the ab/gen-ai-extract-output-messages-schema branch November 25, 2026 11:49
andreiborza added a commit to getsentry/sentry-javascript that referenced this pull request Nov 25, 2026
## What

Vercel AI `experimental_extract` spans now record their input and output
messages in the shape that Cloudflare Workers AI already records for
Clairic. File data in the state is replaced with `[Blob substitute]`.

## Why

The `gen_ai.extract` schemas in getsentry/sentry-conventions#832 and
getsentry/sentry-conventions#835 describe the Clairic request and
response. Before this change, Vercel AI recorded the AI SDK's own shape,
so the product could not read it.

## State mapping

```mermaid
flowchart LR
  S["AI SDK state"] --> K{"Shape"}
  K -->|"string"| T1["one text part"]
  K -->|"JSON object"| J1["one JSON part"]
  K -->|"array of parts"| P["each part in order"]
  T1 --> TXT
  J1 --> TXT
  P -->|"text part"| TXT["append text, remember its offset"]
  P -->|"JSON part"| JS["stringify value"] --> TXT
  P -->|"image file part"| IMG["images: [Blob substitute]"]
  P -->|"PDF file part"| DOC["documents: [Blob substitute]"]
  TXT --> ST["state: texts joined with a blank line"]

  A["AI SDK answer source"] --> SK{"source.type"}
  SK -->|"text: part, start, end"| SP["span: offset of part + start, offset of part + end<br/>source: input"]
  SK -->|"file, part is an image"| SI["source: image"]
  SK -->|"file, part is a PDF"| SN["no source"]
```

## Sentry traces

Node script that calls `experimental_extract` on a mock Clairic model,
with a state of two text parts and one image.


[Before](https://sentry-sdks.sentry.io/explore/traces/trace/37a15b4563bd4fef80ab0f5607d907cb/?node=span-a0d1a2ba84388c45&targetId=a0d1a2ba84388c45),
`@sentry/[email protected]` records no extract span (released versions do not
have the extract instrumentation yet):

<img width="1568" height="77" alt="trace-before-extract-shape"
src="https://github.com/user-attachments/assets/df1995fb-a4ec-45a3-b478-de9fcdf9df21"
/>


[After](https://sentry-sdks.sentry.io/explore/traces/trace/2fa9b0e227164b4f8eb9d4d9e87bf908/?node=span-ad8c8a4067c07a75&targetId=ad8c8a4067c07a75),
the extraction view shows the joined state with the answer spans
highlighted:

<img width="1327" height="702" alt="trace-after-extract-shape"
src="https://github.com/user-attachments/assets/09fd4746-e8aa-48a8-88bc-3b835611b929"
/>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — 28b392c9 Deployed Nov 25, 2026 by vercel[bot]
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.

3 participants