Repository navigation
Breaking: vercel-ai-sdk: leave raw HTTP bodies out of model Activity results, add maxEmbeddingsPerCall - #469
Merged
Merged
Conversation
2 of 4 tasks
moetemp
marked this pull request as ready for review
November 12, 2026 06:49
moetemp
force-pushed
the
fix/vercel-ai-sdk-history-size
branch
2 times, most recently
from
November 12, 2026 06:51
eb556df to
144679e
Compare
brianstrauch
left a comment
Member
There was a problem hiding this comment.
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
force-pushed
the
fix/vercel-ai-sdk-history-size
branch
from
November 13, 2026 07:48
144679e to
7549e56
Compare
brianstrauch
approved these changes
Nov 13, 2026
moetemp
force-pushed
the
fix/vercel-ai-sdk-history-size
branch
from
November 13, 2026 17:04
7549e56 to
7326fe9
Compare
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
force-pushed
the
fix/vercel-ai-sdk-history-size
branch
from
November 13, 2026 17:21
7326fe9 to
be7d167
Compare
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.
What changed?
This PR cuts what the model Activities write to Event History.
invokeModel,invokeModelStreamingandinvokeEmbeddingModelreturn the result withoutrequest.bodyandresponse.body. Headers,id,modelIdandtimestampstay.maxEmbeddingsPerCallin theembeddingModeloptions. When it's set,embedManyruns 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.
embedManysent 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.bodyorresponse.body. They are nowundefined. Replay isn't affected.maxEmbeddingsPerCallsplits the values only. Each chunk gets the sameproviderOptions, so it doesn't fit provider options that hold one entry for each value, such asproviderOptions.google.content. The README says so and gives a substitute.How did you test it?
ActivityTaskCompletedpayload, and check theembedManychunks and their order.make lintandmake testpass intypescript/vercel-ai-sdk.generateObjectand middleware effects come from readingai7.0.127. I didn't test them.