Repository navigation
Give Strands TypeScript model calls a 10-second default heartbeat timeout - #508
Merged
Merged
Conversation
…eout TemporalModel, and so TemporalAgent, scheduled the model activities without a heartbeat timeout unless activityOptions set one, and the activities heartbeat only when it's set. So a cancel never reached a running model call, and a lost worker went unnoticed until the start-to-close timeout. Default it to 10 seconds. The model activities already heartbeat on a timer at half the timeout. Setting it to 0 still turns heartbeats off. The model config read runs synchronously and can't heartbeat, so it's scheduled without a heartbeat timeout. Part of #491.
campoy
marked this pull request as ready for review
November 13, 2026 00:55
JasonSteving99
approved these changes
Nov 13, 2026
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 was changed
TemporalModel, and soTemporalAgent, now schedules the model activities with a 10-secondheartbeatTimeoutunlessactivityOptionssets one. SoinvokeModel,invokeModelStreaming,strandsInvokeStatefulModelandstrandsInvokeStatefulModelStreamingheartbeat by default.autoHeartbeat), so they don't change. A timeout you set wins, andheartbeatTimeout: 0(or'0s') turns heartbeats off.strandsGetModelConfigis now scheduled without a heartbeat timeout, even when you set one. It builds the model and reads its config synchronously, so a heartbeat timer can't fire until it returns, and a model factory slower than the timeout would fail it.TemporalAgent,TemporalModeland the model activity said cancellation needs aheartbeatTimeoutyou set. They now say what the default does and how to turn it off.activityAsToolandactivityAsHookrun your own activities, so they stay as they are.Why?
Without a heartbeat timeout, the model activities never heartbeat. So a cancel never reaches a running model call: since #297 the model gets the activity's cancellation signal, but the signal only aborts once the worker hears about the cancel, and it only hears through a heartbeat. With the default, the cancel stops models that pass
cancelSignalto their client, likeOpenAIModelandBedrockModel. A lost worker also goes unnoticed until the start-to-close timeout, 10 minutes by default. #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, and the replay tests pass, including the histories recorded with no heartbeat timeout. But a model call that didn't set
heartbeatTimeoutnow heartbeats, which in Temporal Cloud is at most one Action every 8 seconds of a running call. And a Worker whose event loop blocks for about 10 seconds now fails the call with a heartbeat timeout, and retries it.TemporalMCPClientisn't in this PR. Its activities never heartbeat, so a default there would fail every MCP call longer than 10 seconds. It needs a timer first, in a later PR.Checklist
Closes [Feature Request] Give Strands TypeScript model calls a 10-second default heartbeat timeout #507
How was this tested:
TemporalAgent dispatches model.stream() through invokeModel activitynow reads the heartbeat timeouts from History: none forstrandsGetModelConfig, 10 seconds forinvokeModel. Without the change it fails:cancelling a TemporalAgent workflow ... aborts the model calltests, whose agent setsheartbeatTimeout: '5 seconds', now check that the model call keeps those 5 seconds and the config read gets none. Without the change, the config read got 5 seconds too.Context.current().info:autoHeartbeatstarts its timer only whenheartbeatTimeoutMs > 0, so0means no heartbeats.make test(105 passed, including the replay tests),make lintand the conventions check pass, with Node 24.Any docs updates needed?
The README and docs are updated here. Release notes should mention the new default, and how to turn it off.