0
Phase 10

Shared Memory

~3 min read

Concept & How It Works

    Why Does It Exist?

    Agents without shared memory re-derive context every turn and contradict earlier conclusions. A shared store is the team's single source of truth.

    Real-World Analogy

    Shared memory is the shared Google Doc everyone edits — not separate notebooks that get out of sync.
    Loading diagram...

    Visual Workflows

    What is Shared Memory?

    Loading diagram...

    Example

    Scenario

    Research agent writes `findings.acme_revenue` to shared memory; Writer agent reads it without re-searching; Supervisor reads both to check consistency.

    Solution

    In Multi-Agent Systems, apply Shared Memory to this scenario: Research agent writes `findings. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.

    Practice Task

    Do this before moving to the next module — reading alone is not enough.

    Open the Code Walkthrough below and run it locally. Change one parameter related to Shared Memory (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.

    Code Walkthrough

    Highlighted lines show where Shared Memory happens in the code.

    Shared Memory
    1class SharedMemory:  # define a data structure or component2    def __init__(self, redis):  # define a reusable function3        self.redis = redis4
    5    def set(self, session_id, key, value):  # define a reusable function6        self.redis.hset(f"session:{session_id}", key, json.dumps(value))7
    8    def get(self, session_id, key):  # define a reusable function9        return json.loads(self.redis.hget(f"session:{session_id}", key))  # return the result

    Commands to Remember

    Commands to Remember

    • pip install langgraph langchain-openai # multi-agent orchestration
    • pip install crewai # role-based multi-agent crews

    Common Mistakes

    • Treating Shared Memory as a black box without evaluation
    • Ignoring cost and latency in production
    • Skipping error handling for shared memory

    Cheat Sheet

    Quick recap — the most important points from this module.

    Cheat Sheet

    quick ref
    • Shared Memory
    • Session State
    • Episodic Memory
    • MemGPT