Part 2 of 6 · 2 min read
Definitions and setup
Covers: Definitions; Why concurrent writers lose updates.
Definitions
Shared state, blackboard, message passing
- Shared state: data that several agents can read and write.
- Blackboard: shared state used as the main coordination surface, where agents post and read partial results.
- Message passing: agents communicate by sending messages; no agent mutates another's state directly.
Lost update, last-writer-wins, race condition
- Race condition: the outcome depends on the timing of concurrent operations.
- Lost update: two concurrent read-modify-write operations; one write overwrites the other.
- Last-writer-wins: the store keeps the most recent write and silently discards the rest.
Optimistic concurrency, compare-and-set, reducer
- Optimistic concurrency: proceed without locking, and at write time check that nothing changed (a version number); if it did, redo the work.
- Compare-and-set (CAS): write only if the current value or version matches what the writer read.
- Reducer (merge function): a rule that combines concurrent updates, such as append to a list, add to a counter, or union of sets; it is safe when the operation is commutative and associative.
Delivery semantics, idempotency key, ordering
- At-most-once: send once; a lost message is lost.
- At-least-once: retry until acknowledged; messages may arrive more than once.
- Idempotency key: a unique id the receiver remembers, so applying the same message twice has the effect of applying it once.
- Ordering: sequence numbers let the receiver apply messages in the order they were sent even if they arrive out of order.
Why concurrent writers lose updates
Three facts from the example:
- Overwrites lose data in proportion to concurrency. Lost items rose from 5 (two agents) to 14 (four), 24 (six) and 54 (twelve).
- The long "think" step is what makes it likely. The window between read and write is an LLM call, seconds long, not microseconds.
- Optimistic retries are expensive for agents. A conflict means redoing the model call that produced the update. Retries grew faster than the number of agents (6 at two agents, 83 at six, 327 at twelve).