Short answer: a Dapr workflow's history only grows, and continue-as-new is the operation that starts it again with an empty one.
The hard part is that the history is also how the workflow survives. Dapr Workflow keeps an append-only log of every step and replays it to rebuild state after a restart. For a ten-step workflow that costs nothing. For a monitoring workflow written as a while (true) loop that checks something every five minutes, every cycle adds entries, and every replay reads all of them.
Continue-as-new restarts the workflow with a new input and a fresh history. The Dapr docs recommend it for "eternal workflows" such as monitoring agents. The loop body becomes one cycle: run the check, wait on a durable timer, then continue-as-new with whatever the next cycle needs to know.
Two things catch people out.
Pass everything forward. The old history is discarded, so state you leave out of the new input is gone.
Await your work before you continue. Continue-as-new restarts immediately and drops any activities, timers or child workflows that were started but not awaited.
A long-lived agent that wakes, checks, acts and sleeps fits this shape well. It is a monitoring workflow with a model call in the middle.
Docs on continue-as-new and history size: https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-features-concepts/
How durable agents use workflow history: https://www.diagrid.io/learn/durable-agents
Top comments (0)