Shared memory: one governed store for agents and people

Shared memory is a store that several agents and people read and write, with owners, scopes, and conflict rules. Use it when agents hand over context or a team builds knowledge together.

Shared memory in 60 seconds

  • What: a memory store that several agents, and often people, read and write together, with rules for ownership, scope, and conflicts.
  • Why: without it, each agent works alone, repeats work, and contradicts the others.
  • How: every item records an owner, a scope, and a version. A conflict rule decides what happens when two writers disagree.
  • Best for: multi-agent systems and teams where handing over context is a regular need.
  • Watch for: data leaking across users, one agent's mistake spreading to all, and write conflicts that silently overwrite good data.

Where this type fits

Shared memory is an organisation type, like tiered memory. It does not say what kind of thing is stored. It says who can use it. A shared store can hold facts, past events, or skills. The Types of memory hub groups it with tiered memory, and the CoALA framework (Sumers et al., 2023) gives the underlying split into working, episodic, semantic, and procedural memory that a shared store may hold.

The problem it solves

Consider three agents on a project. A research agent finds that a supplier raised its prices. A writing agent drafts a proposal using the old price. An editor, who is a person, corrects the number in the draft, but the research agent never hears about the correction. Each part of the system holds a different version of the truth. The user sees contradictions, and the team spends effort reconciling them.

Passing messages between agents helps, but messages are short-lived. They cover what to do next, not what is now known. When a new agent joins, or an old one restarts, the context is gone. A shared store gives the whole system a common, lasting record that anyone may consult.

Sharing also creates new risks. A private note in one user's memory must not appear in another user's answer. An agent that writes a wrong fact can poison every other agent that reads it. And two writers who update the same item at once can undo each other. Shared memory is the design of the store and its rules so that the benefits arrive without these failures.

How it works

  • Common store: one place, usually a database with a search index, that every participant reads and writes through a single interface.
  • Item metadata: each item records its owner (which agent or person wrote it), its scope (private, team, or organisation), a version, a timestamp, and its source.
  • Write rules: a writer may add or update items within its permissions. Updates create a new version rather than overwriting the old one.
  • Conflict rule: when two writers disagree, a stated rule decides. Common rules are latest write wins, human wins over agent, or flag for review.
  • Read rules: a reader sees only items whose scope allows it. The store enforces this on every query.
  • Separation from private memory: per-user memory is kept apart. Team knowledge goes in the shared store, and personal details stay in the private one.
Many writers share one governed store, while private memory stays separate.

The left side shows who writes. Agents and people use the same interface, which is useful because their changes then appear in one history. The centre is the shared store, which carries the owner, scope, and conflict rule on every item. The right side is private memory, kept apart on purpose.

The warning box matters most. If access rules exist only as instructions in a prompt, a model can be talked out of them. The store must refuse the read, not the model. That is the same lesson as in any system with users and data, covered on the security page.

A worked example

Acme Procurement runs three participants on a supplier review. Agent A (research) finds that Northgate Supplies raised its unit price from 4.20 to 4.80 on 14 November. It writes an item: owner "agent-research", scope "team:procurement", version 1, source "supplier price list, 14 Nov", text "Northgate unit price is 4.80".

Agent B (writing) starts the proposal. It queries the store for "Northgate price" under scope team:procurement and gets version 1. It drafts the proposal with 4.80. Meanwhile, person C, the editor, sees that a volume discount applies and the price is really 4.56. C updates the item. The store creates version 2 with owner "c.okafor", marks it as human-written, and keeps version 1 in history.

Agent A, running an hour later, tries to refresh the item with a new scrape that says 4.80. The conflict rule is "human edits win over agent edits until reviewed". The store rejects the write, and records a flag for review. Agent B reads again before sending the proposal, finds version 2, and updates the draft to 4.56. In the same run, a private note from another user's session, "negotiating position: walk away at 4.40", is not returned, because its scope is private to that user.

A shared item with owner, scope, and version (illustrative) (json)
{
  "id": "item-3319",
  "text": "Northgate unit price is 4.56 after volume discount",
  "owner": "c.okafor",
  "owner_type": "human",
  "scope": "team:procurement",
  "version": 2,
  "supersedes": "item-3319@1",
  "source": "editor review, 14 Nov",
  "expires_at": "2027-02-14T00:00:00Z"
}

Building it

The sketch below shows the core of a governed store: scope checks on every read and write, versioned updates, and a conflict rule that protects human edits. Everything outside the sketch is a placeholder. Note the limits on result size and on how long items live.

A governed shared store (illustrative) (python)
import time

# Placeholders: db (a database with versioned rows), embed(), index (vector search).
MAX_RESULTS = 8                 # bound what any one agent can pull into a prompt
DEFAULT_TTL = 90 * 24 * 3600    # shared facts expire unless renewed

class Denied(Exception):
    pass

def can_read(principal, item):
    # Enforced here, in the store, never by asking the model to behave.
    if item["scope"].startswith("user:"):
        return item["scope"] == "user:" + principal["user_id"]
    return item["scope"] in principal["scopes"]

def can_write(principal, scope):
    return scope in principal["write_scopes"]

def write_item(principal, scope, text, source):
    if not can_write(principal, scope):
        raise Denied("no write access to " + scope)
    key = text_key(text)                      # placeholder: stable key per subject
    current = db.latest(key, scope)
    if current and current["owner_type"] == "human" and principal["type"] == "agent":
        # Conflict rule: a human edit beats an agent edit until reviewed.
        db.flag_for_review(current["id"], proposed=text, by=principal["id"])
        return {"status": "flagged", "id": current["id"]}
    version = (current["version"] + 1) if current else 1
    row = {"key": key, "scope": scope, "text": text, "source": source,
           "owner": principal["id"], "owner_type": principal["type"],
           "version": version, "created_at": time.time(),
           "expires_at": time.time() + DEFAULT_TTL}
    db.insert(row)                            # never overwrite; keep history
    index.upsert(row["id"], embed(text), {"scope": scope})
    return {"status": "written", "version": version}

def read(principal, query):
    hits = index.search(vector=embed(query), top_k=MAX_RESULTS * 3,
                        filter={"scope": {"in": principal["scopes"]}})
    visible = [h for h in hits if can_read(principal, h)]  # check again after search
    return visible[:MAX_RESULTS]

Design decisions

  • Scope model: private, team, and organisation levels, at minimum. Default: scope every item at write time, and make the narrowest scope the default.
  • Enforcement point: in the store and the query layer. Default: filter in the search query and check again on the results, and never rely on prompt instructions.
  • Conflict rule: choose one and document it. Default: versioned writes, human edits beat agent edits, and agent disagreements go to review.
  • Provenance: record who wrote each item, from what source, and when. Default: reject writes with no source, since unsourced facts are hard to trust or correct.
  • Trust and quarantine: an agent that reads untrusted content can write bad items. Default: mark items from external content as unverified, and show that mark when they are read.
  • Latency and scaling: reads are frequent and writes are rare. Default: cache reads with short TTLs, and invalidate on a new version. For high write rates, use a queue so writers do not block each other.
  • Retention and deletion: shared items outlive their authors. Default: use TTLs, support deletion by person, and keep an audit log of changes.

Measuring it

  • Cross-scope leak rate: run a test suite that tries to read items from the wrong scope. The target is zero, and any leak is a defect.
  • Conflict rate: the share of writes that hit a conflict rule. A rising rate means agents are fighting over the same facts.
  • Stale read rate: the share of reads that return a superseded version, measured by comparing the version used with the latest at answer time.
  • Reuse rate: the share of tasks that read at least one item written by a different participant. This shows whether sharing is paying off.
  • Error propagation: when a bad item is found, count how many later outputs used it. This sizes the blast radius.
A leak test across scopes (illustrative) (python)
def leak_test(store, principals, items):
    # items: list of (item_id, owner_scope). Every principal without access
    # must get zero results for each item's text.
    leaks = 0
    for p in principals:
        for item_id, scope in items:
            if scope in p["scopes"]:
                continue
            hits = store.read(p, store.text_of(item_id))
            leaks += sum(1 for h in hits if h["id"] == item_id)
    return leaks   # must be 0

When to use it, and when not to

SituationUse this type?Why
Several agents work on one project and need the same factsYesA common record prevents contradictions and repeated work.
People and agents collaborate, and human corrections must stickYesVersioned items and a human-wins rule keep corrections.
A support team wants shared knowledge from solved casesYesTeam-scoped items help the next agent and the next person.
One agent serves one user with personal detailsNoPrivate memory is simpler and safer.
Data from different customers must never mixOnly with strict scopesTenant isolation must be enforced in the store, and tested.
Agents read untrusted web content and write what they findOnly with quarantineUnverified writes can spread errors or injected instructions to every reader.

Trade-offs

DimensionEffectWhat to do about it
QualityConsistent answers across agents, but one bad item affects allRecord sources, mark unverified items, and review flagged writes.
LatencyA shared read on each task, and write coordinationCache reads briefly and keep writes asynchronous.
CostStorage, an index, and governance workShare only what is reusable, and expire the rest.
ComplexityScopes, versions, conflict rules, and auditStart with two scopes and one conflict rule.
Failure modesData leakage, silent overwrites, and spread of poisoned itemsEnforce scopes in the store, version every write, and keep an audit log.

Tiered memory is about how items move between layers to save space. Shared memory is about who may use them. The two combine well, for example a team archive with a private core per user. Semantic memory stores facts for one user or one agent, and becomes shared memory once several participants write to it.

If your agents are coordinated by a supervisor, a shared store may replace some message passing, but not all of it. See supervisor with workers for the orchestration side.

What this means for your role

Common mistakes

Further reading

Shared memory lets a team of agents and people work from one record. Make access, ownership, and conflicts explicit in the store, and test them as carefully as the model.

Search topics

↑↓ to move · Enter to open · Esc to close