Skip to content
sinc-LLMBook a 15-minute call

How to Roll a Long AI Workflow Into a New History

Use Temporal Continue-As-New to carry a versioned cursor into a fresh history and verify messages and unfinished work across the transition.

On this page

By Mario Alexandre · November 29, 2026 · 24 min read

Use Temporal Continue-As-New when a long-running workflow can describe its durable progress in a small, versioned checkpoint. Start the next execution with that checkpoint. Before switching, finish message handlers that can change it or account for their work through an explicit handoff. Verify the new execution recovered the right position and preserved any accepted work that was still pending.

TL;DR Roll at a known application boundary, such as the end of a batch. Pass the next position, input revision, unresolved work, and message disposition into the new run or through a durable reference. Test a message arriving before, during, and after the switch. Approve the rollout only when the new Run ID and fresh history agree with the destination records for the work.

Key decision facts

Decision Evidence to use
When to roll A safe application checkpoint, with the Temporal suggestion or a tested application threshold as a trigger
What identity to expect The same Workflow ID and a different Run ID with a fresh Event History
What starting state to carry Input revision, explicit cursor semantics, pending or deferred work, result references, and message policy
Where to call Continue-As-New The main workflow path after the relevant handlers settle, following the SDK’s rules
Whether a competing message applied Its application disposition and related durable result, which can be checked independently of a sender response
When to hold Unknown checkpoint format, lost or repeated work, unresolved accepted messages, or a mismatch between old and new run state

Choose a boundary where the work can be described

A Temporal workflow can continue through a chain of executions. Continue-As-New closes the current run and starts a new one with the same Workflow ID, a different Run ID, and its own Event History. The next execution receives the arguments the workflow provides. Application-specific state that should carry across the boundary therefore needs an explicit representation. Start by identifying the minimum state another execution needs to recover the logical workflow. Temporal Continue-As-New overview

A catalog review that processes part of a manifest each day has a natural application boundary after a batch. At that point it can state which entries finished, which are waiting for a decision, and which item is next. A workflow in the middle of submitting a batch has a messier boundary. A customer-facing update might already have committed even though the Workflow has neither read its result nor marked the batch complete. Try to close or reconcile such work before switching executions. If the product requires rollover while a dependency is unresolved, represent the obligation and give the next run the evidence to interpret it safely.

Write one sentence specifying the state at the boundary. For example, “The checkpoint binds revision Spring B, advances the regular cursor to row forty-one, and preserves three deferred items in the review ledger.” Each part is observable. If a person cannot tell whether the cursor includes row forty-one or starts there, neither can a successor implementation that follows a new convention. If a deferred item is omitted because it is below the new regular cursor, write a check that discovers the omission. Define the evidence that will make an item eligible to resume.

A service hint for growing history is a useful input for timing. The application still decides where a checkpoint can be taken. The Continue-As-New overview recommends checking the suggestion from the workflow at points where state can be safely handed off. For example, evaluate it after applying a bounded batch of changes and settling any handlers that mutate the pending list. A check only at the end of a many-hour phase may give the workflow too few meaningful opportunities. Break up a large phase or prove that its worst expected history growth fits your operational limits. Temporal Continue-As-New overview

Avoid copying an application-level threshold without checking how your workflows produce events. Two batches with the same item count can create different history growth if one has more Activity attempts, timers, or messages. Likewise, a workflow that repeatedly takes small batches may produce fewer events per run yet rotate so often that operators have trouble tracing results. Choose a threshold in staging by observing histories for a normal batch and a more demanding combination of waits and messages. The threshold should give the workflow time to reach a safe boundary, including while it handles admitted input.

Use a test-only rollover trigger to exercise the transition without generating production-scale history. The Python guide shows how to test Continue-As-New from an application-controlled threshold. Keep the production condition and the test trigger distinguishable. A test that forces a boundary can prove the state handoff and message handling at that boundary. It leaves service-trigger frequency and long-running resource behavior to their own tests. Add a representative load observation if those determine when your team can deploy the change. Temporal Python Continue-As-New guide

Design the checkpoint from the new run backward

List the first things a new run must do. It should identify the logical operation, open the exact prior input revision, validate the checkpoint format, recover unresolved work, and decide which new action can be scheduled. Start with those reads and derive the necessary fields. This prevents a checkpoint from becoming a dump of workflow memory. It also means the design has a reader contract that another operator and another worker revision can test.

A useful checkpoint distinguishes the work selection from the current progress. The selection could be an immutable manifest digest or a generated revision recorded in the application. The progress might be a cursor into ordered input plus a durable ledger reference covering past results and explicit exceptions. If input can change between runs, a cursor from the old population can point to a different item. Use a separate product decision to accept a new population. Validate the old revision before touching work selected under the old checkpoint.

A version field gives the new run a way to choose the right reader. Document what each field means in each supported version. Include what values are permitted, which can be absent, and how a reader handles unknown references. Starting at position one after an unfamiliar checkpoint is a plausible default for a brand-new Workflow start and a dangerous default for a rollover. Distinguish the initial start contract from a continuation explicitly. Reject or hold an incompatible continuation before it creates new effects.

A sample continuation contract

Field Illustrative value What the next run verifies
Checkpoint format Version two A tested reader exists for this format
Input selection Catalog manifest April North, revision B The immutable reference and selected revision agree
Regular cursor Next eligible record is R4 The index maps to that exact record
Deferred work R5 awaits a reviewer The disposition and dependency are carried forward
Completed results Reference to results ledger for this logical workflow Previously completed records and their result versions are readable
Already handled messages Recent operation IDs or a durable reference to applied dispositions A logical request cannot be applied a second time across runs
Unknown results Pending operation IDs with destination references No dependent work starts until its prerequisite can be confirmed

When building the checkpoint, avoid embedding sensitive evidence that the next run could retrieve with its authorized references. Inputs become part of the new run’s execution context and should be handled according to their retention and confidentiality obligations. A compact reference can limit repeated carriage of documents and reduce the burden of a growing list of results. The tradeoff is a new read dependency. Check the exact reference under the candidate worker’s permissions before approving a rollout that depends on it.

Use a cursor only when it represents a range with a known relationship to completion. If R3 and R5 finish but R4 is unresolved, a checkpoint that advances the regular cursor to R6 can be valid if it also preserves R4 as an open obligation. If the record has no such set and the application interprets the cursor as contiguous completion, keep it behind R4. The test should compare intended record IDs with actual completed and deferred IDs, rather than checking a single maximum position.

Consider reproducibility for any state derived at the boundary. A working checkpoint may classify eight records as complete using a query over a results table, but its eventual reader might see nine if another operation commits between reads. Define which observation the application wants to carry. If the checkpoint refers to a frozen result revision, reopen that revision. If it intentionally refers to the latest authoritative state, verify that the reader can distinguish previously committed work from changes that belong to a later approved revision.

Decide what to do with messages at the transition

Messages can reach a workflow around the time it is preparing a checkpoint. The problem has several boundaries. The sender can know whether its request was submitted or accepted. The workflow can know whether a message handler started and changed application state. A destination may record a downstream effect separately. Define which of those observations count as success for each message type.

For a message that changes the pending list, make sure no handler that can still change the list gets abandoned at the boundary. The Temporal Python guidance describes waiting for in-progress handlers and performing Continue-As-New from the main workflow method. Follow the corresponding behavior in your SDK. If a handler spawns a task or awaits an Activity, record exactly what falls under your code's definition of finished. Holding a wait on handlers that can never complete under the current policy is a separate operational failure that needs a visible path to resolve. Temporal Python workflow message passing · Temporal Python Continue-As-New guide

The window between deciding to roll and finishing the handoff deserves an explicit test. A check showing that all handlers were idle at an arbitrary earlier time does not establish how the application behaves when a new message arrives during the transition. Drive the actual sender, receiver, and SDK in staging. Record whether the message was delivered to the previous run, received by the next run, rejected under the addressing contract, or left unresolved. Some clients may target a specific Run ID while others address the logical Workflow ID. Test the way real callers address the workflow instead of assuming they all use the same route.

Give every logical change a stable application identity before using retransmission as a recovery path. In a catalog review, the operation might mean “defer R5 for review under manifest revision B.” Assign a unique operation ID when the caller requests that change. Keep application dispositions by operation ID and retain enough information to detect a changed payload for an old ID. If a sender retransmits after an ambiguous result, the receiving application can learn whether it already applied the logical request. The design needs an authoritative read or a verified retry contract before repeating any consequential effects. Sincllm on reconciling uncertain tool effects

Different message types may need different contracts. A read-only query might ask for the current status and can return useful partial information. A request to defer a catalog record changes scheduling and may block a corresponding write. A request to approve a billing change has its own authorization and destination checks. The rollover test should name what is allowed for each type, how the sender resolves uncertainty, and the evidence establishing that state crossed the boundary. Do not let a decision about one type imply delivery or ordering guarantees for another.

A durable application disposition can help people reason about repeated messages. Useful states include received by the application, applied, rejected under application policy, and unresolved pending confirmation of a destination effect. A caller that receives an early success response from a transport may still need to check the final disposition. If the receiver supports a stronger completion response, test what it covers. A separately durable effect can still require separate evidence. Define the point at which an operator can stop monitoring rather than interpreting every good response as a closed obligation.

A staged handoff for six records and one competing message

Suppose a workflow manages review over six catalog entries, R1 through R6, in a fixed order. It completed R1, R2, and R3 and is ready to start a new run at R4. Its checkpoint carries the manifest revision, the results ledger pointer, and the regular cursor. An operator submits message M17 to defer R5. The application's endpoint records the operation ID and relevant parameters. R5 cannot advance while this authorized deferral is active.

Use one synthetic source dataset for the experiment and create separate runs for each timing case. Give each case its own workflow identity so committed results from earlier tests cannot contaminate a later case. Between the previous run and the next run inside a case, keep the logical Workflow ID stable as the service specifies. Save the Run IDs and expected outcome by logical operation. Choose an observer that can read the application ledger independently of the workflow's response.

Case When M17 arrives Expected evidence
Before the boundary Handler applies it and completes before the old run prepares the checkpoint Checkpoint or durable reference carries the deferral. The next run leaves R5 deferred.
During handler work The old handler starts and is paused while it updates the deferral state The old run waits or explicitly hands off under its tested contract. Final R5 scheduling matches the disposition.
During the switch The sender submits using its real destination addressing Trace the observed recipient and reconcile the final state. An ambiguous caller response does not count as a deferral.
After the new run starts Next run receives and handles the request The operation is applied under the new run and the resulting ledger records it.
Redelivery The sender repeats the original authorized request under its normal contract One logical deferral remains, with no duplicate destination effect.
Conflicting reuse A message with ID M17 arrives with a different action or target The conflict follows the application’s refusal or review rule. The old disposition remains recoverable.

Place the timing controls at points the experiment can observe. For the in-progress handler case, hold the handler at an awaited test dependency after it begins, ask the main workflow to evaluate its rollover condition, and observe whether it waits. Release the test dependency and confirm the handler's final disposition before reading the next run. In the during-switch case, choose instrumentation that can identify when the old run began the transition and when the new run accepted work. Record the actual order if the attempt misses the planned timing window. A test that only succeeds when the operator happens to act at the right instant is difficult to reproduce.

For the case where M17 was applied by the old run, the new run should recover with R4 as the regular next item and R5 deferred. Read the old run's checkpoint and the new run's startup arguments. Follow the results ledger to verify R1 through R3 remain confirmed at the exact revisions intended. There is no need to reprocess those records simply to demonstrate the new run can see them. Then inspect the action chosen for R4 and the policy result for R5. The correct exclusion of R5 from the regular queue gives evidence about what the new run actually did with the checkpoint.

For the during-switch case, compare the sender's observation with the authoritative disposition. If the sender receives a transport acknowledgment and neither run's application log confirms M17, see whether the records are incomplete or whether the request is still unresolved. A retry may be permitted under the existing with-same-identity contract, but it should never manufacture proof that the original request applied. Preserve every timing outcome as part of the evidence. Distinguish a transport rejection with a clear recovery path from a successful-looking response that leaves the application state unknown.

Include a deliberate defective checkpoint that omits the deferred item while carrying the right input revision and cursor. The next run can start successfully and process R4 without surfacing the defect immediately. The staging readback should reject the handoff when R5 becomes incorrectly eligible. Verify that the defect control fails for the omitted deferral, rather than failing during test setup. Another useful control supplies an unsupported checkpoint version. The new run should stop before its first new business effect, with enough evidence for an operator to recover the intended work.

Run a second rollover in a fresh instance with a different pattern of deferred work. This can reveal bugs in state representations valid for a single transition. For example, a durable reference might remain correct only because the first generated pointer never changed. A second transition tests whether the next checkpoint carries both the current position and the older outstanding obligations. Count the logical effects across runs and compare them against the frozen input set. Two successful start events do not prove two correct state transfers.

Neither the exact timing cases nor their expected values are production measurements. They specify how to structure a staging check. Your toolchain should record separate outcomes for workflow start, handoff acceptance, handling of M17, and destination state of R5. With these separate observations, a failure in the sender path does not get mistaken for checkpoint corruption, and a clean new run start does not hide application state lost at the transition.

Read back state from history, workflow, and destination

Use Temporal's run and history data to confirm the structural transition. Within the same logical Workflow ID, the old and new runs should have different Run IDs and different histories. Record the checkpoint format and canary identifiers using approved evidence access. Match the new run's actual startup arguments to the expected checkpoint. A new Run ID may verify that Continue-As-New took place while leaving the checkpoint interpretation or destination result unproven. Temporal Continue-As-New overview

Use the workflow's application state to confirm that it interpreted the checkpoint. For example, distinguish “started with checkpoint version two” from “validated the checkpoint and selected R4 as next.” The first statement may come from a startup argument. The second should come from the application path that validated the input revision and interpreted the cursor meaning. If the system exposes a status query, define who can read it and whether its result adequately demonstrates the point of interest. You can use structured logs or a dedicated test observation if a query would not provide reliable state.

Use the destination to confirm that work was actually preserved. Verify that the completed outputs still point to the expected revisions. Verify that the deferred entry remains deferred and that the regular queue advances only over appropriate work. Check which recent application messages are terminal and which remain unresolved. Keep progress references at the right granularity. A report that verifies “same manifest” without comparing R5's durable disposition can miss the specific fault in this case.

Inspection result Likely next check Release effect
Run IDs change and the checkpoint version is unreadable Verify the new worker supports the format and inspect the validated input Hold new effects and recover a tested reader
Cursor and manifest disagree Match the ordered input and exact record ID at the cursor Hold dependent processing until the original selection is located
Message accepted with no terminal application disposition Inspect both runs and the destination under its stable ID Keep disposition unresolved and follow the existing reconciliation contract
Main path continues while a paused handler could still mutate application state Check observed handler policy and how the checkpoint is captured Stop expanding rollout until transition preserves the change
Correct destination state but unexpected worker revision Read current deployment routing and trace the eligible workers Keep the release decision open until exposure matches the tested plan

A partial status can be useful during this handoff. List the preserved done items, the items intentionally deferred, and the items blocked by a missing published result or unverified message. If an upstream reader requires the entire batch, avoid returning an overall success state when a prerequisite is missing. An operator may still use confirmed results in decisions that permit partial evidence. Make that boundary clear in the application rather than requiring the operator to infer it from a progress percentage. Sincllm on returning partial workflow results

Audit references should let someone reconstruct the event sequence without storing unnecessary payloads. Useful fields include logical Workflow ID, old and new Run IDs, checkpoint version, input revision, reason for transition, an identity for the checkpoint reference, and the old and new application positions. Add the timing fixture and observed effect when reviewing a release. Timestamps from different hosts can help with diagnosis, while explicit causal records such as handler completion before checkpoint creation yield stronger evidence of ordering when available.

Plan rollouts and checkpoint compatibility together

A new worker reusing the same logical workflow name can encounter several application state shapes. Previous runs may enter the transition using old Workflow code. New runs may open older checkpoint versions during a rollout. The underlying worker routing rules depend on the deployed SDK and Temporal worker configuration. Continue-As-New gives the logical workflow a new run. By itself it cannot tell you which worker will pick up that run or whether the receiver supports the checkpoint. Inspect that behavior under your actual deployment. Temporal Worker Versioning documentation

Test the handoff directions that your release expects. If a version-one producer can hand off to a version-two reader, prove that pair with a staging continuation. If rollback may send a version-two checkpoint to a version-one reader, test that pair separately. Where an old reader cannot understand a new representation, limit rollback eligibility or retain a reader that can handle the affected executions under your product's rules. Record how the operator can identify the affected runs and what they should preserve rather than attempting an unverified rollback across all workflows.

Treat a schema upgrade as a deliberate version change. A new reader can make an optional field safe by choosing a documented default that fits old records. A changed meaning for a cursor should have an explicit migration or distinct version. Take the example of a cursor historically representing the last completed item. If a new version interprets the same number as the next candidate, the first item after a continuation changes. Capture a fixture with a nonzero cursor and expected next ID so your test can detect this incompatibility. Testing only initial states might let both conventions pass.

Use both historical and prospective tests where appropriate. History replay can assess compatibility for code that will reconstruct existing run state. A staged continuation can answer what the next execution actually receives under the candidate configuration. A destination effect check can prove the application did not duplicate past work or drop a new obligation. The test sets will overlap in subject but verify distinct behaviors. Keep each claimed pass tied to its own observation, especially if a rollout changes workflow code and business operations at the same time. Sincllm on replay before a worker deployment

Decide when to keep the old run open and when to proceed

Continuing a run can be a clean option once the work reaches a safe place. Holding the current execution can be appropriate while an important handler is bounded and still finishing. Pausing the application path for an operator can be appropriate if the state or a required destination record is unknown. Each decision should have a reason and a next observation. Otherwise a move intended to manage history can turn into an opaque wait with no progress path.

Think about a handler that requires approval from a person before it can finish. Delaying rollover until the handler completes may be impractical if that wait lasts long or the run is already growing quickly. An alternative is to structure admission so a handler stores the approved request as a durable pending item and completes its internal state transition, while the main workflow can carry that pending item forward. The revised meaning of handler completion should be explicit. Test the old run's disposition, the next run's handling, and the exact destination state after the person decides.

Only let a different default apply if it treats work and authorization as the same entities the original contract defined. A new run crossing from one dataset revision to another cannot simply inherit cursor position. A handler that accepts a request from an authorized caller cannot decide to skip it because the rollover budget is tight. It may expose an explicit deferral if the application permits, but an operator needs a way to find it and decide what remains pending. The new history should inherit these rules, along with the work record.

Measure the operating burden of rollover after proving correctness. A short transition that requires almost no state can be suitable even at a relatively high frequency. An application with a long checkpoint validation read or a host performing large downloads at every run start may need a different boundary. Compare normal batch progress, elapsed time in transition, starting state load time, unresolved message count, and failure recovery time before changing thresholds. Use representative staging measurements and note the workload and software version.

Use the sender's application message ID to join the acceptance record to the checkpoint and the next run. For a staged message accepted during the switch, require either one destination readback under that ID or a durable pending item under the same ID that the next run can resolve. If the sender reports acceptance and neither record exists, keep the gate closed even when the new history starts cleanly.

Rollover release checklist

  • Identify a safe application boundary and validate the conditions under which the Temporal hint or application threshold can lead to it.
  • Version the checkpoint and bind the exact input selection, next work, unresolved obligations, and handled message state.
  • Verify that the next worker can read any durable references under its normal permissions.
  • Exercise a message handled before the boundary and a distinct message that competes with the switch.
  • Verify an in-progress handler completes or transfers its durable obligation under the application’s actual rules.
  • Compare old and new run identities, startup arguments, selected next item, and destination state.
  • Run a broken-checkpoint control that loses a deferred item and confirm the readback detects the exact defect.
  • Verify multi-run carryover and historically relevant checkpoint versions. Test the opposite direction wherever rollback depends on it.
  • Record the release hold reason and next observation for every required unresolved case.

For a first deployment, choose one small logical workflow and observe a complete staged handoff under the actual sender and worker configuration. Use a direct read of the durable workflow-owned and destination-owned evidence. A later deployment can extend the same method to independent handlers, larger batches and additional routing cases after verifying that the original contract still describes them. The aim is a transition you can explain record by record, including the first action that the next run will take.

Plan for the obligation that survives several runs

Consider a separate synthetic case where R5 remains deferred for three consecutive runs. The workflow should let the ordinary cursor advance beyond R5 while carrying the deferral as a reference to one durable pending item. Give the pending item an owner, the input revision it applies to, and the condition that can make it eligible again. When the next run reads the pending set, it should find an existing obligation under the same identity. It should neither create a new deferred obligation because the Run ID changed nor assume the old one has disappeared because the regular cursor advanced.

Start the check with a deferral that is still valid. In the next run, place one ordinary pending item behind the regular cursor and a second item in the unresolved set because an external result is still unknown. Compare those dispositions with the staged destination. If the application can advance safe independent work, test that it does so while preserving both open cases. If the unresolved item is a prerequisite to later work, the workflow should hold the dependent branch and continue only what the application permits. This check prevents a success criterion that merely counts how far the majority of records progressed.

Then let an authorized reviewer resolve the R5 deferral while an independent attempt is advancing the ordinary path. Ask the application to record the disposition and an updated revision or proof of the resulting state. On the next rollover, verify whether R5 appears as newly eligible, still awaiting a different dependency, or complete. Compare against the user's authorized decision and the destination's readback. Do not rely solely on the most recent Workflow event if the destination also determines whether the item can be acted on.

An operator can keep the work navigable with a stable application ledger reference and a short reason for each pending item. Define when that record can be pruned. If a caller can still redeliver an earlier decision, the data needed to recognize it may have to outlive the effect itself. If the team has a finite replay window or reference retention period, use a test after that window to check how an old obligation is rejected or handed off. This documents which parts of the broader rollover behavior remain meaningful even after the current run has left the original execution history behind.

FAQ

Does Continue-As-New change the Workflow ID?

The new execution in the chain keeps the same Workflow ID. It has a new Run ID and starts a new history. Use both identities when verifying the old and new runs, and include the intended startup input when checking application state. Temporal Continue-As-New overview

Should I include the whole object graph in the checkpoint?

Keep the information the new run needs to preserve the application's guarantees. An immutable reference can be enough for a large dataset or result set if the receiving version can read and verify it. If the reference is unavailable, the new run should preserve the obligation and stop dependent work rather than interpreting absence as empty state.

Can my message handler call Continue-As-New directly?

Follow the relevant SDK documentation. For Temporal Python, the guidance is to call Continue-As-New from the main Workflow and finish in-progress handlers first. Structure admission and handler completion so a pending decision can be transferred through an explicit application record if it must remain unresolved at the boundary. Temporal Python Continue-As-New guide

Can I claim a message survived just because the client received a successful response?

First determine what the response guarantees for that specific API and request type. Then check the application's disposition and any required durable effect. A success that proves request receipt can be valid evidence for that step while leaving application completion unknown. Reconcile ambiguous outcomes under the same logical operation identity.

What if the new run’s checkpoint cannot be parsed?

Hold dependent work. Record the checkpoint identity, format, producing Run ID, and receiving worker identity. Use a tested compatible reader or a reviewed migration that preserves the existing application state. The new run may need an operator action, depending on the workflow contract and which effects have already occurred. Do not restart from the beginning on the assumption the failed checkpoint contained nothing important.

How do I know that a history rollover method can be reused?

Verify the conditions the method assumed, including the SDK, worker routing, checkpoint format, sender addressing, and the meaning of a resolved item. Reuse the smallest relevant staged scenario and include a fresh timing or state case. When a changed input violates the prior assumptions, verify the change before claiming compatibility for the new rollout.

Sources