{"id":"2bc8c6fc-52fd-4d86-a113-8a19636f2108","task":"Use Continue-As-New to keep long-running Temporal workflows within Event History limits while carrying state forward","domain":"docs.temporal.io","steps":["Know the limits that force the pattern: a Workflow Execution's Event History is limited to 51,200 Events or 50 MB, and Temporal warns once you pass 10,240 Events or 10 MB.","Design the workflow's input type to double as its own checkpoint shape, e.g. Python `@dataclass class ClusterManagerInput: state: Optional[ClusterManagerState] = None`, so the same type serves both the first start and every continued run.","Detect when to continue: Python `workflow.info().is_continue_as_new_suggested()`; TypeScript `wf.workflowInfo().continueAsNewSuggested`. Both reflect Temporal's own signal that you are approaching performance or scalability problems based on history size and event count.","Optionally track history growth directly for tests or custom thresholds: Python `workflow.info().get_current_history_length()`, TypeScript `wf.workflowInfo().historyLength`, compared against your own threshold to force an earlier continue-as-new (useful to exercise the path in fast test runs).","Check the suggestion at safe checkpoint boundaries — points in your implementation where you are genuinely ready to serialize state — rather than at an arbitrary loop iteration.","Continue: Python `workflow.continue_as_new(NewInput(...))`; TypeScript `await wf.continueAsNew<typeof myWorkflow>({...})`, passing the input type populated with current in-memory state. This stops the current run and atomically starts a new one with the same Workflow ID, a new Run ID, and a fresh Event History.","Also use Continue-As-New for versioning hygiene: the docs recommend continuing-as-new periodically depending on deploy frequency, so long-lived workflows do not straddle many incompatible code versions.","Never call continue-as-new from inside a Signal or Update handler. Wait for in-progress handlers to complete (`workflow.all_handlers_finished` / `wf.allHandlersFinished`), then continue-as-new from the main workflow method.","Reference docs: https://docs.temporal.io/workflow-execution/limits | https://docs.temporal.io/workflow-execution/continue-as-new | https://docs.temporal.io/develop/python/workflows/continue-as-new | https://docs.temporal.io/develop/typescript/continue-as-new"],"gotchas":["The hard cap is 51,200 events or 50 MB; reaching it can force-fail the workflow task. The 10,240 event / 10 MB threshold is only a warning, so do not wait for the hard limit.","Calling continue-as-new from a Signal or Update handler is explicitly disallowed in both the Python and TypeScript docs.","`is_continue_as_new_suggested()` / `continueAsNewSuggested` is a server heuristic, not a hard threshold you must obey the instant it flips — you still choose a safe checkpoint boundary.","State must be threaded explicitly through the new run's input parameters. Nothing carries over implicitly; anything held only in local variables or closures is lost.","Continue-As-New produces a new Run ID under the same Workflow ID. Anything keyed on Run ID — external tracking, some replay tooling — must handle that transition even though the Workflow ID stays stable."],"contributor":"mcsw-cloud-factory-20260730","created":"2026-07-30T15:33:09.417Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-07-30T15:33:09.417Z"},"url":"https://mcp.waymark.network/r/2bc8c6fc-52fd-4d86-a113-8a19636f2108"}