Repository navigation
fix(ai-sdk): log AI SDK v7 inline file data as attachments - #2752
Open
Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits into
Open
Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits into
Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits into
Conversation
- Keep the AI SDK v7 `{ type: "data", data }` envelope when logging inline
file bytes as attachments, matching the decision-image logging shape.
- Add a streamText image-file e2e operation (v5+, tagged data on v7) that
asserts file bytes are logged as attachments on both the parent and
model spans. It fails without the fix.
- Replace the plugin unit test and two live-API wrapper image tests with
this e2e coverage, and drop the unused test-image.png fixture.
- Move the scenario off the deprecated gpt-4.1-nano and gpt-4o-mini to
gpt-5.4-nano (v3 keeps gpt-4o-mini because its provider sends
max_tokens), send prior tool items inline with store: false, and
re-record all cassettes and snapshots.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00c7c14911
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
build off of #2751
fixes #2750
Problem
With AI SDK v7, file parts carry their bytes in a tagged wrapper
(
SharedV4FileData):The AI SDK plugin only turned bare bytes into attachments, so it copied
this wrapper into the span as is.
deepCopyEventthen turned theUint8Arrayinto an object with one key per byte. 1 MB of image becameabout 120 MB of heap on every model call
(#2750).
The plugin fix in #2751 had only a unit test. No e2e scenario sent a v7
tagged file part, so the real
streamTextpath was never tested.Solution
The plugin now converts the inner bytes to an attachment and keeps the
v7 wrapper around it. The logged span has the same shape as the v7 input
and matches how decision images are already logged:
The
ai-sdk-instrumentationscenario gets a newai-sdk-stream-image-file-operation. It streams a real 32x32 red PNG toOpenAI and checks that the top-level call span and the model call span
each log one PNG attachment and no raw bytes. v7 sends the tagged form;
v5 and v6 send plain bytes. The test fails without the fix.
Other changes in this commit:
ai-sdk.test.ts, which the new e2e test covers. Delete their unusedtest-image.pngfixture.gpt-4.1-nano(deprecated) andgpt-4o-miniwithgpt-5.4-nano-2026-03-17. AI SDK v3 stays ongpt-4o-minibecause itsOpenAI provider sends
max_tokens, which GPT-5 models reject.providerOptions: { openai: { store: false } }on multi-step toolcalls for AI SDK v5+. This sends earlier tool calls in full instead of
by ID, so recording also works for OpenAI orgs with Zero Data Retention.