Overview
State inconsistency occurs when multiple agents maintain different views of what should be shared truth. Without proper synchronization, agents operate on stale, partial, or conflicting information—leading to contradictory actions and system incoherence.
Consistency Problem
Reality: Order #1234 status = CANCELLED
Agent A's View: status = PROCESSING
Agent B's View: status = CANCELLED
Agent C's View: status = SHIPPED
Same order, three different "truths"
Inconsistency Sources
Eventual Consistency Delays
Time Event Agent A Agent B
──── ───── ─────── ───────
T1 Order created PENDING PENDING
T2 Payment received PAID PENDING (sync delay)
T3 Agent A ships item SHIPPED PAID (still behind)
T4 Agent B checks status SHIPPED PAID → Confusion
Cache Staleness
Central DB: inventory = 0
Agent A (cached): inventory = 5 → Promises delivery
Agent B (cached): inventory = 3 → Also promises delivery
Agent C (fresh): inventory = 0 → Correctly rejects
Customers A and B expecting items that don't exist
Partial Updates
Customer record update:
- name: "John Doe" → "John Smith"
- email: old@example.com → new@example.com
Agent A sees: name=Smith, email=old (partial)
Agent B sees: name=Doe, email=new (partial)
Agent C sees: name=Smith, email=new (complete)
Split-Brain Scenarios
Network partition:
[Partition A] [Partition B]
Agent 1, Agent 2 Agent 3, Agent 4
See: status=ACTIVE See: status=INACTIVE
Both partitions process differently
Reconciliation creates conflicts
Multi-Agent Scenarios
Customer Service Chaos
Customer calls about order
Agent A (Chat): "Your order is being processed"
Agent B (Phone): "Your order was cancelled yesterday"
Agent C (Email): "Your order shipped this morning"
Customer: "???"
Conflicting Recommendations
Financial agents with different portfolio views:
Agent A: "You have $10K available, recommend investing"
Agent B: "You have $2K available, recommend saving"
Agent C: "Account shows overdraft, recommend deposit"
Same account, three recommendations
Workflow Corruption
Approval workflow:
Step 1: Agent A approves (status: APPROVED)
Step 2: Agent B sees PENDING (stale), requests approval again
Step 3: Agent C sees APPROVED, proceeds
Step 4: Agent D processes duplicate from Step 2
Duplicate processing, audit trail corrupted
Consistency Models
Strong Consistency
All agents see the same state at any given time
Pros: Simple reasoning, no conflicts
Cons: High latency, availability trade-offs
Eventual Consistency
Agents may temporarily see different states
Eventually converge to same state
Pros: High availability, low latency
Cons: Requires conflict resolution, complex reasoning
Causal Consistency
If A causes B, all agents see A before B
Unrelated events may appear in different orders
Pros: Balance of consistency and performance
Cons: More complex to implement
Detection Approaches
Version Vectors
class VersionedState:
def __init__(self):
self.value = None
self.version = {} # {agent_id: counter}
def update(self, agent_id, new_value):
self.version[agent_id] = self.version.get(agent_id, 0) + 1
self.value = new_value
def detect_conflict(self, other):
# Neither version dominates the other
return not self.dominates(other) and not other.dominates(self)
Consistency Checks
async def verify_consistency(entity_id, agents):
views = await asyncio.gather(*[
agent.get_view(entity_id) for agent in agents
])
if len(set(views)) > 1:
log.warning(f"Inconsistent views for {entity_id}")
return reconcile(views)
return views[0]