Home » AI Agent Memory » Two Agents Same Memory

What Happens When Two Agents Write Same Memory

In a last-write-wins system, one agent's update silently overwrites the other's, and data is lost. In a system with optimistic concurrency control, the second write is rejected with a version conflict error, and the agent must re-read, merge, and retry. In an append-only system (like Adaptive Recall), both agents create separate memory entries rather than updating the same one, so no write is lost. The consolidation process later merges related entries into a coherent summary. The append-only model is the safest for multi-agent systems because it eliminates write conflicts entirely at the cost of temporary duplication that the lifecycle system handles.

The Three Possible Outcomes

Last-Write-Wins: Silent Data Loss

In the simplest memory architectures, concurrent writes are handled by letting the last write overwrite whatever was there before. Agent A reads a memory about Service X ("connection pool: 50"), adds its finding ("timeout: 30s"), and writes the updated memory. Meanwhile, Agent B reads the same original memory, adds its finding ("retries: 3"), and writes its update. If Agent B's write lands after Agent A's, the stored memory contains Agent B's addition but loses Agent A's. Neither agent is notified of the conflict.

This is the worst outcome because it is silent. No error is raised, no agent is alerted, and the lost information may not be noticed until much later when an agent retrieves the memory and the missing information causes a bad decision. Last-write-wins is common in simple key-value stores and in-memory dictionaries, which is why these are poor choices for multi-agent memory.

Optimistic Concurrency Control: Detected Conflict

With version-tracked memory, each memory carries a version number that increments on each update. When Agent A tries to update the memory, it includes the version it read. If Agent B updated the memory in the meantime, the version has changed and Agent A's update is rejected. Agent A then re-reads the memory (now including Agent B's changes), merges its own changes with Agent B's, and retries. No data is lost, but the agent must handle the conflict.

This is better than last-write-wins because conflicts are detected rather than silently ignored. The trade-off is that agents must include conflict-handling logic: re-read the current version, decide how to merge, and retry. For LLM-based agents, the merge can be handled by the LLM itself ("Here are two versions of a memory. Merge them into a single coherent entry."), but this adds an LLM call to the update path.

Append-Only: No Conflict Possible

In an append-only architecture, agents never update existing memories. Instead, they create new memory entries for each observation. Agent A creates a memory "Service X timeout is 30s." Agent B creates a separate memory "Service X has 3 retries." Both memories are stored independently, each with its own ID, timestamp, and agent attribution. No write conflict occurs because neither agent is modifying the same record.

The result is temporary duplication: the memory store contains multiple entries about the same topic. The consolidation process handles this by periodically reviewing related memories, merging them into a single coherent entry, and removing the originals. The consolidated memory combines both agents' observations: "Service X: connection pool 50, timeout 30s, retries 3."

Why Append-Only Is Best for Agents

LLM-based agents are poorly suited for handling write conflicts. The conflict-handling logic (detect version mismatch, re-read, merge, retry) adds complexity to the agent loop and edge cases that are hard to test. An agent in the middle of a reasoning chain that encounters a version conflict must interrupt its flow, handle the conflict, and then resume reasoning, which can derail the LLM's chain of thought.

Append-only storage eliminates this entirely. The agent's store operation always succeeds (no conflict possible). The consolidation process handles merging asynchronously, outside the agent's execution loop. The agent never needs to know that another agent wrote about the same topic because both entries coexist peacefully until consolidation merges them.

The cost is temporary duplication, but this is a minor concern. Duplicate memories about the same topic consume slightly more storage and may both appear in retrieval results. The retrieval model handles this gracefully: if both entries are relevant to the query, both appear in the results, giving the consuming agent two perspectives. If one is more relevant than the other (more recent, higher confidence, better match), it ranks higher. The duplication resolves automatically when the next consolidation cycle runs.

How Adaptive Recall Handles It

Adaptive Recall uses the append-only model. Every store operation creates a new memory entry, regardless of whether similar memories already exist. The knowledge graph connects related entities across memories automatically, so the two entries about Service X are linked through the "Service X" entity even though they are separate memories. When an agent recalls information about Service X, both observations surface, ranked by cognitive scoring (recency, confidence, access frequency, entity connections). The consolidation process periodically reviews the memory store, identifies related entries that can be merged, and creates consolidated memories that combine the best information from each original entry.

For teams running multiple agents against the same memory store, this means zero write conflicts, no lost updates, and automatic consolidation that keeps the memory store clean over time. Agents never need to handle concurrent write logic, which keeps the agent code simple and the reasoning flow uninterrupted.

Run multiple agents against shared memory without worrying about write conflicts. Adaptive Recall's append-only storage and automatic consolidation handle concurrency safely.

Get Started Free