Lesson 08.08 · Phase 08 · Multi-Agent Systems
Message passing & mailboxes
Give each agent a mailbox and let it handle one message at a time, sharing nothing. That's the actor model, and it makes concurrency easy to reason about. It also brings the network's problems with it: messages get lost, duplicated, piled up or stuck, and each one needs a deliberate answer.
Learning objectives
- Build actors: an agent with private state, a mailbox, and a loop that handles one message at a time.
- Implement request/reply with message ids and correlation ids, timeouts and resends (at-least-once delivery).
- Make handlers idempotent by deduplicating on message id, so resends and duplicates don't repeat side effects.
- Use bounded mailboxes for backpressure, and a dead-letter queue for messages that can't be delivered or handled.
Lesson 5's blackboard shared one store between agents, so it needed locks and versioned writes. The alternative is to share nothing: each agent owns its state, and the only way to affect it is to send it a message. No locks, no lost updates. Each agent handles its messages in order, so its own code never runs concurrently with itself.
Loading the full lesson…