Actor Model

Each agent is its own mailbox, its own state, its own supervisor.

Agents or components run as independent actors: each owns its private state, processes one message at a time from its mailbox, and can spawn further actors — so there is no shared-memory contention and a crash is contained to a single actor.

In practiceA high-throughput document-processing system assigns each uploaded file to an independent actor, so a crash in one file's processing actor never affects the others running in parallel.

Level
04 · Production
Subdomain
Runtime Architecture
Also known as
Actor-based Runtime, Agent Actors, Message Actors
Trade-off
Strong isolation and scalability are gained against more complex messaging and error semantics.
Native in
Microsoft Agent Framework, AutoGen / AG2, AWS Strands
The mechanism

How it works.

Each actor has its own state and a mailbox. It takes one message at a time, and the only way to affect another actor is to send it a message.

1 · One actor

  1. A message arrivesIt waits in the mailbox
  2. The actor takes one messageNever two at once
  3. It actsChanges its own state, sends messages, creates actors

2 · Many actors

  1. A supervisor creates actorsOne per unit of work
  2. They run independentlyNo shared memory, no locks
  3. One actor crashesIts own state is lost, nothing else
  4. The supervisor reactsRestarts it, or reports the failure
Mailbox
The queue in front of an actor. Messages wait there until the actor is free.
Private state
Only the actor itself reads or writes it. That is why no locks are needed.
Supervision
An actor that watches others and decides what happens when one of them fails.
Walk it through

A real run, step by step.

TaskFour files are uploaded at the same time. Each gets its own actor, and the second file is a corrupt PDF:
Illustrative run.
ActorMailboxWhat happensOutcome
File 1parse, summariseHandles both messages in orderSummary delivered
File 2parse, summariseCrashes while parsingReported as unreadable
File 3parse, summariseHandles both messages in orderSummary delivered
File 4parse, summariseHandles both messages in orderSummary delivered
What this shows: the crash of the second actor touched nothing else, because there was no shared state it could have damaged. Three summaries arrived as if nothing had happened. The price is that everything becomes an asynchronous message. Even the question “is file 2 finished?” is a message, and a message can arrive late or not at all.
In code

The pattern in code.

Plain Pythonpython
import asyncio

class FileActor:
    def __init__(self, name):
        # private state
        self.name, self.mailbox, self.pages = name, asyncio.Queue(), None

    async def run(self, supervisor):
        try:
            while True:
                message = await self.mailbox.get()  # one message at a time
                if message == "parse":
                    self.pages = parse(self.name)
                elif message == "summarise":
                    await supervisor.put((self.name, summarise(self.pages)))
        except Exception as error:  # the crash stays inside this actor
            await supervisor.put((self.name, f"failed: {error}"))
Fit

Use it, or not.

When to reach for it

  • Concurrency and isolation are critical.
  • Agents possess their own internal state.
  • Scaling should occur via independent units.

When it backfires

  • A simple synchronous workflow suffices.
  • The message model creates unnecessary complexity.
  • Global transactions are central.
Pitfalls

Two ways this pattern will hurt you.

Lost messages disappear without a trace

An actor crashes between receive and ack. The message vanishes; the sender thinks it was processed; the system silently loses work.

Countermeasure

Use at-least-once delivery with idempotent handlers, or persist the inbox before processing. Make message loss a visible failure, not a silent one.

A slow actor's mailbox grows without bound

One actor consumes messages slower than they arrive. Its mailbox swells until memory is exhausted, and the backlog latency cascades to everyone waiting on its replies.

Countermeasure

Bound mailboxes and apply backpressure or load-shedding when full; monitor queue depth per actor and scale or shed before it becomes an outage.

Framework support

Where Actor Model is native.

Microsoft Agent Frameworkactor runtimeNative
AutoGen / AG2actor agentsNative
AWS Strandsagent actorsNative

Search

Search patterns, frameworks, and pages.