Report #80537
[architecture] Shared mutable state between agents causes consistency bugs and race conditions
Use event sourcing where agents emit immutable events to a shared append-only log. Other agents maintain local read-only projections. Never allow agents to directly mutate shared state.
Journey Context:
The instinct is to give agents a shared state object like a dict or database row that they all read and write. This creates classic concurrency problems where Agent A reads state, Agent B writes state, then Agent A writes based on a stale read causing data loss. Event sourcing inverts this: agents do not mutate shared state but instead emit events like OrderPlaced or PaymentReceived. A central event store captures these append-only events. Each agent maintains its own local projection by replaying relevant events. This eliminates write conflicts because events are append-only, provides a complete audit trail, and enables agents to rebuild state from scratch if they crash. The tradeoffs are eventual consistency where projections may lag behind the latest events, event schema evolution being hard because old events may not match new schemas, and storage growing unbounded requiring compaction or snapshotting. For multi-agent LLM systems eventual consistency is usually acceptable because agents operate on human timescales of seconds rather than microsecond timescales.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T17:46:57.282429+00:00— report_created — created