TECHNOLOGY

Temporal agent workflows put model calls outside replay

In this article
THE QUICK TAKE

Place model calls in Activities and distinguish replaying recorded decisions from retrying an external operation whose completion was not recorded.

Separate durable control from model generation

A research agent retrieves material, asks a model to classify it and waits for a reviewer. Temporal can coordinate that long-running process, but the model call belongs at a particular boundary. The Workflow Definition guide requires deterministic workflow control and explicitly places LLM invocations and other external interactions in Activities. The workflow describes sequencing; the Activity performs the fallible outside operation.

Understand what replay reconstructs

The workflow overview explains reconstruction through Event History rather than restoration of an arbitrary process-memory snapshot. Workflow code can run again while recorded results guide it back to the previous state. A completed Activity’s recorded result is reused during replay. Consequently, replay should not make a fresh model request simply because the control-flow code is being reconstructed. A new model response could otherwise choose a different branch from the recorded history.

Keep completed replay distinct from an Activity retry

The Activity Definition guide describes a different case: an Activity performs its external operation but the worker fails before reporting completion. Temporal may retry because it has no recorded completion. That is not replay of a successfully recorded result. If the Activity writes an external artifact, its implementation and receiving service need an appropriate duplicate-handling contract. Durable orchestration does not by itself make arbitrary external effects happen exactly once.

Choose Activity boundaries around observable results

For the research example, return the classification result and source identity from the model Activity, then let workflow logic decide the next step. Keep an artifact-writing operation distinguishable from merely generating its proposed contents. This makes failures easier to interpret: generation succeeded, publication failed or completion reporting was lost. Avoid combining a long sequence of unrelated outside actions into a single retry unit when repeating the entire sequence would be undesirable.

Verify recovery with a bounded scenario

Use synthetic source material and a harmless output target to compare a recorded completion with a deliberately interrupted unreported attempt. The task-contract guide states the intended effect; a bounded synthetic probe keeps recovery testing reviewable. Inspect event history alongside the actual external artifact. The useful result establishes which work replay reused and which outside operation was attempted again, rather than treating every resumed workflow as a new agent task.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles