Skip to main content
Four rules govern how code runs on an instance. They are the stateful actor’s rules, and a class that respects them needs no locks and gets its retries from the scheduler; a task handler must therefore be safe to run twice, and an outward effect such as sending a text needs its own guard. One call at a time per instance. An instance runs each method to completion before the next starts. A second text while a reply is being produced waits; messages.add followed by queue can never race another call on the same conversation. Different instances run in parallel, on whatever containers the platform placed them. Two budgets. An inbound call, an RPC or a webhook, runs under a 30-second wall-clock budget by default: enough to record a message, not enough for a model round-trip with tools. Queued and scheduled tasks run in the instance’s alarm handler with a budget of 15 minutes, and retry on failure, up to 5 times by default. The turn therefore lives in a task:
Writes land before the caller hears back. When a method returns, the runtime holds the response until every write it issued, to the message log, the state, the schedule or the SQL database, has been flushed. A caller never observes a result built on an unflushed write. Only what was written survives. An instance can be evicted, restarted or relocated between any two calls; its fields vanish, its storage does not. Memory Model is that rule in full. Under dev, calls and tasks run in one process the moment they are due; the budgets, the retry backoff and the restart recovery are only approximated there. Execution Model on Stateful Actors states the four rules for any actor.