A Cloudflare agent's identity and stored data survive sleep; its in-memory object does not. Wake-up reruns initialization. Think provides bounded chat recovery after interruption. Custom work on the base Agent needs explicit recovery logic.
Keep the logical agent separate from the temporary object running in memory.
A new invocation can activate the same named agent after sleep or eviction. Initialization runs again. initialState applies only when stored state is absent; existing data loads from SQLite.
After work finishes, the runtime can hibernate the instance when it meets the conditions for hibernation. Pending work and outbound connections can prevent immediate sleep. Hibernated WebSocket connections can remain open.
Save progress during execution. Cloudflare does not provide a guaranteed shutdown callback for a final save. Ordinary fields and a JavaScript call stack are not durable storage.
Recovery from interrupted work is separate. Think wraps chat turns in recoverable fibers and schedules a bounded continuation or retry. This is built in. Our earlier recovery explanation describes responsibilities for custom work on the base Agent, where snapshots and recovery behavior must be supplied.
These are documented behaviors; we have not tested interruption or recovery here.
Sources: Durable Object lifecycle, persistent state, Think recovery, custom fibers.