Skip to content

feat(attributes): Add schema for gen_ai.extract input - #832

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

andreiborza merged 15 commits into
mainfrom
ab/gen-ai-extract-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.input.messages has on gen_ai.extract spans. The schema follows the Cloudflare schemas for Clairic (input, output). The convention text now also names documents, which SDKs must replace in the same way as images.

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.

…` and `gen_ai.output.messages`

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@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 10:07am 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 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.

@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.

@andreiborza andreiborza changed the title feat(attributes): Add schema for extract-based gen_ai.input.messages and gen_ai.output.messages feat(attributes): Add schema for extract-based gen_ai.input.messages Nov 24, 2026
@andreiborza andreiborza changed the title feat(attributes): Add schema for extract-based gen_ai.input.messages feat(attributes): Add schema for gen_ai.extract input 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 ba3f47a. Configure here.

},
"type": "array"
},
"ExtractInputMessage": {

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'd call it ExtractRequest because message make this sound too similar to a chat message.

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 ExtractRequest in 86d16e0

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

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.

If it's always a singleton extraction request we should do this

Suggested change
"anyOf": [
{
"$ref": "./shared/gen_ai_chat_message.openapi.json#/components/schemas/ChatMessage"
},
{
"$ref": "#/components/schemas/ExtractInputMessage"
}
]
"anyOf": [
{
"items": {
"$ref": "./shared/gen_ai_chat_message.openapi.json#/components/schemas/ChatMessage"
},
"type": "array"
},
{
"items": {
"$ref": "#/components/schemas/ExtractInputMessage"
},
"maxItems": 1,
"minItems": 1,
"type": "array"
}
]

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.

Applied in 64bf493

@andreiborza
andreiborza merged commit 1464f2e into main Nov 25, 2026
20 checks passed
@andreiborza
andreiborza deleted the ab/gen-ai-extract-messages-schema branch November 25, 2026 11:36
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 — 64bf4933 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