In this article
Treat Continue-As-New as an explicit state handoff from the main workflow, including in-flight message work that must finish before its old run closes.
Identify why the process needs a new run
A research coordinator processes repeated requests for the same project and accumulates a long history. The Python Continue-As-New guide provides a transition that closes the current execution successfully and starts a new run with fresh history. This can keep a long-lived logical process manageable. It does not mean the application should forget every decision or restart the user’s completed work.
Carry the required state through parameters
The guide asks the workflow author to design input parameters that can receive current state from the preceding run. Decide which project configuration, pending work and deduplication information the next run needs. Ordinary local variables do not become a new input contract merely because the code calls Continue-As-New. Keep the carried structure explicit and reviewable so a later schema change does not silently lose the facts needed to resume the logical task correctly.
Drain message handlers before leaving
The message-passing guide notes that an asynchronous Signal or Update handler may still be awaiting an Activity when the main workflow returns or continues. Closing then can interrupt important work and prevent clients receiving Update results. The documented pattern waits for workflow.all_handlers_finished. Perform the transition from the main workflow after handlers finish, rather than calling it from inside a handler and assuming its remaining work will migrate automatically.
Keep workflow and run identities distinct
The identity guide describes a chain retaining its Workflow ID while run identity changes. An interface following the project should distinguish that logical identity from a specific run’s evidence. Record which run handled an Update and which run now owns the ongoing process. A fresh event history is an operational boundary, not evidence that earlier artifacts or external operations disappeared.
Test the handoff before production-length history
The Python guide recommends a small test threshold so the transition can be exercised without waiting for a naturally long execution. Use a harmless pending request and verify carried state, completed handler results and the new run’s next action. Task contracts identify the continuity required; tool observations establish what crossed the boundary. A successful test demonstrates deliberate continuation rather than simply observing that another run exists.
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.