Skip to content

Give Vercel AI SDK model and embedding calls a 10-second default heartbeat timeout - #510

Merged
campoy merged 1 commit into
mainfrom
feat/vercel-ai-sdk-default-heartbeat-timeout
Nov 13, 2026
Merged

campoy merged 1 commit into
mainfrom
feat/vercel-ai-sdk-default-heartbeat-timeout

Conversation

@campoy

@campoy campoy commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

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 (fix(vercel-ai-sdk): heartbeat while the model Activities wait on the provider #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 [Feature Request] Give Vercel AI SDK model and embedding calls a 10-second default heartbeat timeout #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.

…tbeat timeout

TemporalLanguageModel and TemporalEmbeddingModel set no heartbeat timeout, and
the model Activities start their heartbeat timer only when one is set. So a
cancel never reached a call waiting on the provider, and a lost Worker went
unnoticed until the 10-minute start-to-close timeout.

Default it to 10 seconds. A heartbeatTimeout set in the provider or model
options wins, and 0 turns it off. The README said the Activities send no
heartbeat without a heartbeatTimeout; it now gives the default and how to turn
it off.

Part of #491.
@campoy
campoy marked this pull request as ready for review November 13, 2026 00:55
@campoy
campoy requested a review from a team as a code owner November 13, 2026 00:55
@campoy
campoy merged commit 80f52c5 into main Nov 13, 2026
15 checks passed
@campoy
campoy deleted the feat/vercel-ai-sdk-default-heartbeat-timeout branch November 13, 2026 01:25
campoy added a commit that referenced this pull request Nov 16, 2026
…beat timeout (#552)

## What was changed

The Vercel AI SDK README now says how to upgrade from 1.0.0, and how to
roll back, now that the model and embedding Activities get a 10-second
heartbeat timeout by default (#510).

## Why?

1.0.0 schedules these Activities with no heartbeat timeout. Its
`invokeModel` and `invokeEmbeddingModel` never heartbeat, and its
`invokeModelStreaming` heartbeats only when a stream part arrives ([the
only `heartbeat()` call in
1.0.0](https://github.com/temporalio/ai-integrations/blob/typescript/vercel-ai-sdk/v1.0.0/typescript/vercel-ai-sdk/src/activities.ts#L285)).
But the timeout is recorded when a Workflow schedules the Activity, so
whichever Worker runs it has to heartbeat. During a rolling upgrade, a
call that a Workflow on the next version schedules and a 1.0.0 Worker
runs fails with a heartbeat timeout after 10 seconds, and so does each
retry.

Does replay break? No: core only compares an Activity's ID and type. But
a passing replay doesn't mean mixed versions work. So the README now
gives the same steps that #520 and #551 give for Google ADK Python and
google-genai:

- Upgrade the Workers that run the model Activities first. If the same
Workers run Workflows too, deploy with `heartbeatTimeout: 0` and remove
it in a later deploy.
- Before a rollback, deploy with `heartbeatTimeout: 0`, and wait for the
calls scheduled before that deploy to finish.
- Runs pinned with Worker Versioning avoid both.

## Checklist

1. No issue: a docs follow-up to #510, part of #491.

2. How was this tested:
Docs only. The conventions check and `git diff --check` pass. To check
the claims, I read 1.0.0's code: it sets no `heartbeatTimeout` default,
and its only `heartbeat()` call is in `invokeModelStreaming`'s stream
loop. On `main`, `TemporalProviderOptions.default` takes the
`ActivityOptions` the example sets. #520 measured the failure itself on
a local dev server: an Activity that doesn't heartbeat failed 10.02
seconds in, and both attempts of a retried one failed the same way.

3. Any docs updates needed?
This is the docs update. The 2.0.0 release notes should carry the same
upgrade step.
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.

[Feature Request] Give Vercel AI SDK model and embedding calls a 10-second default heartbeat timeout

3 participants