Repository navigation
feat(attributes): Add schema for gen_ai.extract input - #832
Conversation
…` and `gen_ai.output.messages` Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Attributes
Bug Fixes 🐛
🤖 This preview updates automatically when you update the PR. |
gen_ai.input.messages and gen_ai.output.messagesgen_ai.input.messages
gen_ai.input.messagesgen_ai.extract input
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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": { |
There was a problem hiding this comment.
I'd call it ExtractRequest because message make this sound too similar to a chat message.
| "anyOf": [ | ||
| { | ||
| "$ref": "./shared/gen_ai_chat_message.openapi.json#/components/schemas/ChatMessage" | ||
| }, | ||
| { | ||
| "$ref": "#/components/schemas/ExtractInputMessage" | ||
| } | ||
| ] |
There was a problem hiding this comment.
If it's always a singleton extraction request we should do this
| "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" | |
| } | |
| ] |
## 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]>

What
Adds an OpenAPI schema and generated types for the shape that
gen_ai.input.messageshas ongen_ai.extractspans. The schema follows the Cloudflare schemas for Clairic (input, output). The convention text now also namesdocuments, 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.