Skip to content

fix(vercel-ai-sdk): download prompt image and file URLs in the model Activity - #468

Merged
moetemp merged 5 commits into
mainfrom
fix/vercel-ai-sdk-prompt-file-urls
Nov 13, 2026
Merged

moetemp merged 5 commits into
mainfrom
fix/vercel-ai-sdk-prompt-file-urls

Conversation

@moetemp

@moetemp moetemp commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What changed?

This PR makes image and file URLs in a prompt work.

  • TemporalLanguageModel.supportedUrls accepts every URL, so generateText doesn't download in the Workflow.
  • The model Activities read the real model's supportedUrls. A URL the model supports goes to the model. The others are downloaded with createDownload() and sent as bytes.
  • A downloaded image gets the media type that its bytes show, as in generateText.
  • A model call that downloaded a file returns no request.body, so the bytes stay out of Event History.
  • New option download on AiSdkPlugin and createActivities, to replace the download function.
  • @ai-sdk/provider-utils is now a direct dependency, at the version ai already pins.

Fixes #AI-950

Why?

supportedUrls returned {}, so the AI SDK downloaded each URL in Workflow code. The sandbox has no network, and the Workflow task failed on every attempt.

createDownload() refuses local and private addresses. The download option is for users with an internal file server. I'm OK with dropping it if we don't want more API in 2.0.0.

Event History stores the URL, not the bytes. A retried Activity downloads again.

In-flight runs

The supportedUrls change is behind a Workflow patch. A Workflow could give generateText an experimental_download function that ran an Activity, and that Activity is in its Event History. Such an execution replays as it ran then. The new behavior starts with its first model call that isn't a replay.

How did you test it?

  • Unit tests. Workflow tests against a local HTTP server cover a model that supports no URLs and a model that supports the image URL.
  • A history recorded on the old behavior, where experimental_download ran an Activity, replays on this branch. It fails to replay without the patch gate.
  • make lint and make test pass in typescript/vercel-ai-sdk.

@moetemp
moetemp marked this pull request as ready for review November 12, 2026 06:47
@moetemp
moetemp requested a review from a team as a code owner November 12, 2026 06:47

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

Three findings covering replay compatibility, downloaded content in Activity result metadata, and image MIME normalization.

@moetemp
moetemp force-pushed the fix/vercel-ai-sdk-prompt-file-urls branch from cfc3706 to 6a47a28 Compare November 13, 2026 07:48
@moetemp
moetemp requested a review from brianstrauch November 13, 2026 07:53
The AI SDK downloaded them in Workflow code, where there is no network, and the Workflow task failed.
…s, detect image types

A history where experimental_download ran an Activity did not replay. The model Activity also returned the downloaded bytes in request.body, and kept a wrong media type for an image.
@moetemp
moetemp force-pushed the fix/vercel-ai-sdk-prompt-file-urls branch from 6a47a28 to 8546d0d Compare November 13, 2026 17:04
@moetemp
moetemp merged commit edccdca into main Nov 13, 2026
15 checks passed
@moetemp
moetemp deleted the fix/vercel-ai-sdk-prompt-file-urls branch November 13, 2026 17:17
campoy added a commit that referenced this pull request Nov 16, 2026
Replay is promised only within a major, and the next Vercel AI SDK
release is 2.0.0. Two patches only kept 1.x runs on their old paths, so
they go:

- vercel-ai-sdk-download-urls-in-model-activity (#468): the model always
  reports that it supports every URL, so the model Activity downloads them.
- vercel-ai-sdk-abort-signal-cancels-model-activity (#470): a caller's
  abortSignal always cancels the model Activity.

The README says which 1.x runs don't replay.
campoy added a commit that referenced this pull request Nov 16, 2026
…586)

## What was changed

The next Vercel AI SDK release is 2.0.0, so its current major is 2, and
replay is promised only within a major. Two patches only keep 1.x runs
on their old paths, so let's remove them before 2.0:

- `vercel-ai-sdk-download-urls-in-model-activity` (#468): the model
always reports that it supports every URL, so URL parts always go to the
model Activity, which downloads them.
- `vercel-ai-sdk-abort-signal-cancels-model-activity` (#470): a caller's
`abortSignal` always cancels the model Activity.

The README drops both patch notes and says which 1.x runs don't replay.

## What will you notice? (Breaking)

Two kinds of 1.x run don't replay on 2.0. Let them finish on 1.x Workers
before you upgrade, or keep them there with Worker Versioning:

- A run in which an `experimental_download` function scheduled an
Activity for a URL. On 2.0 the model call comes first: `[TMPRL1100]
Activity type of scheduled event 'downloadNotes' does not match activity
type of activity command 'invokeModel'`.
- A run in which a signal aborted while a model or embedding call ran.
On 1.x the abort sent no command, and on 2.0 it cancels the Activity, so
sdk-core fails the replay with `Fatal error in workflow machines:
ActivityMachine in state ScheduledActivityCancelCommandCreated says the
transition is invalid`.

A run on a `main` build since #468 or #470 that took the new path
recorded the marker, so it doesn't replay either. No release wrote those
markers.

## Why?

We decided that replay is promised only within a major, and that a gate
that only protects an older major's runs is removed before the next
major ships. The Vercel AI SDK plugin's next release is 2.0.0, so these
gates go before it.

## Checklist

1. No issue.

2. How was this tested:
- `make sync`, `make lint` and `make test` for
`typescript/vercel-ai-sdk`, in Docker with Node 24: 133 tests passed.
- Replay: the three 1.x histories that #565 stops replaying, run through
the replay tests #565 removes, on #565 and on this PR. On #565 all three
replay. On this PR, the `experimental_download` and abort histories fail
as above, and the one with a model call next to a plain Activity still
replays.

3. Any docs updates needed? The README changes are here.
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.

2 participants