Skip to content

Breaking: vercel-ai-sdk: leave raw HTTP bodies out of model Activity results, add maxEmbeddingsPerCall - #469

Merged
moetemp merged 2 commits into
mainfrom
fix/vercel-ai-sdk-history-size
Nov 13, 2026
Merged

moetemp merged 2 commits into
mainfrom
fix/vercel-ai-sdk-history-size

Conversation

@moetemp

@moetemp moetemp commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What changed?

This PR cuts what the model Activities write to Event History.

  • invokeModel, invokeModelStreaming and invokeEmbeddingModel return the result without request.body and response.body. Headers, id, modelId and timestamp stay.
  • New opt-in option maxEmbeddingsPerCall in the embeddingModel options. When it's set, embedMany runs one Activity per chunk.

Fixes #AI-951

Why?

The bodies repeat the prompt and the content. With a 20,000-character prompt, the Activity result is 24,520 bytes with the bodies and 2,299 bytes without.

embedMany sent all values to one Activity. With 1536 dimensions, 70 values give a 2.11 MB result, which is over the 2 MB limit. The default stays as it is, because a new default would break replay.

This is breaking for Workflow code that reads request.body or response.body. They are now undefined. Replay isn't affected.

maxEmbeddingsPerCall splits the values only. Each chunk gets the same providerOptions, so it doesn't fit provider options that hold one entry for each value, such as providerOptions.google.content. The README says so and gives a substitute.

How did you test it?

  • Unit tests. They decode the ActivityTaskCompleted payload, and check the embedMany chunks and their order.
  • make lint and make test pass in typescript/vercel-ai-sdk.
  • The generateObject and middleware effects come from reading ai 7.0.127. I didn't test them.

@moetemp
moetemp marked this pull request as ready for review November 12, 2026 06:49
@moetemp
moetemp requested a review from a team as a code owner November 12, 2026 06:49
@moetemp
moetemp force-pushed the fix/vercel-ai-sdk-history-size branch 2 times, most recently from eb556df to 144679e Compare November 12, 2026 06:51

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

Found one P2 issue with multimodal embedding batching.

campoy added a commit that referenced this pull request Nov 13, 2026
…tbeat timeout (#510)

## What was changed

`TemporalLanguageModel` and `TemporalEmbeddingModel` now give their
Activities (`invokeModel`, `invokeModelStreaming` and
`invokeEmbeddingModel`) a 10-second `heartbeatTimeout` when the options
don't set one. `TemporalProvider` builds its models with its `default`,
`languageModel` and `embeddingModel` options, so it gets the default
too.

- The Activities already heartbeat on a timer at half the timeout
(#465), so they don't change.
- A `heartbeatTimeout` you set wins, and `heartbeatTimeout: 0` turns it
off. The default is applied with `??`, so a 0 passes through, and
Temporal schedules it as no heartbeat timeout.
- The README said the Activities send no heartbeat without a
`heartbeatTimeout`. It now gives the default and how to turn it off.

The MCP Activities don't heartbeat yet, so they still get no heartbeat
timeout.

## Why?

Without a heartbeat timeout, these Activities never heartbeat while they
wait on the provider. So a cancel never reaches the call, and a lost
Worker goes unnoticed until the 10-minute start-to-close timeout. #491
has the details, and the measurements behind 10 seconds.

Does this break anything? Not replay: when core replays a scheduled
Activity, it only compares its ID and type. I recorded a History for
each of the three Activities without this change, and all three replay
with it. But a call that didn't set `heartbeatTimeout` now heartbeats,
which in Temporal Cloud is at most one Action every 8 seconds of a
running call. And a Worker whose event loop is blocked for about 10
seconds now fails the call with a heartbeat timeout, and retries it.

This goes well with #470, which passes the Activity's cancellation
signal to the model. Without a heartbeat timeout, that signal never
fires while the call waits on the provider.

This PR and #469 both change the `proxyActivities` options in
`TemporalEmbeddingModel.doEmbed`. Whichever merges second keeps both.

## Checklist

1. Closes #509

2. How was this tested:
- `Model activity (<call>) heartbeats while the provider is slow` now
runs each call three times and reads the Activity's heartbeat timeout
from History: 1 second when set (which passes only if the Activity
heartbeats, since each call takes 2 seconds), 10 seconds by default, and
none with `0`. Without the change, all three tests fail on the default:
     ```
     Difference (- actual, + expected):

       [
     -   undefined,
     +   10000,
       ]
     ```
- With `||` in place of `??`, the `0` case gets 10 seconds and fails, so
the test covers the opt-out too.
- Locally, `make test` (86 passed, 1 skipped), `make lint` and the
conventions check pass, on Node 24.

3. Any docs updates needed?
The README is updated here. Release notes should mention the new
default, and how to turn it off.
@moetemp
moetemp force-pushed the fix/vercel-ai-sdk-history-size branch from 144679e to 7549e56 Compare November 13, 2026 07:48
@moetemp
moetemp requested a review from brianstrauch November 13, 2026 07:55
@moetemp
moetemp force-pushed the fix/vercel-ai-sdk-history-size branch from 7549e56 to 7326fe9 Compare November 13, 2026 17:04
The bodies repeated the prompt and the content in Event History. Added an opt-in maxEmbeddingsPerCall so embedMany can stay under the payload limit.
@moetemp
moetemp force-pushed the fix/vercel-ai-sdk-history-size branch from 7326fe9 to be7d167 Compare November 13, 2026 17:21
@moetemp
moetemp merged commit 07f5be8 into main Nov 13, 2026
15 checks passed
@moetemp
moetemp deleted the fix/vercel-ai-sdk-history-size branch November 13, 2026 17:32
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