Agent Foundry
All Problems

#43. Multi-Agent Shared Memory

HardMemoryMulti-Agent

The Problem

You have three agents — a Researcher, an Analyst, and a Writer — collaborating on a report. Currently each agent operates in complete isolation: the Researcher finds data but the Analyst can't see it, and the Writer only sees the last agent's output, missing the Researcher's raw findings. There is no shared scratchpad or collaboration layer. Your job is to add a shared memory that all agents can read from and write to, with attribution and no silent overwrites.

Examples

Example 1

Scenario: Researcher finds 5 renewable energy trends. Analyst needs to analyze them.

Current (bad) behavior: Analyst receives only the final result string from the state, losing the structured data the Researcher found. The Analyst has to re-research or work with incomplete information.

Expected (good) behavior: Researcher writes findings to the shared scratchpad: [Researcher] Top 5 trends: 1. Solar... 2. Wind... The Analyst reads this scratchpad and performs analysis on the actual data.

Example 2

Scenario: Writer needs both raw research data and the Analyst's insights.

Current (bad) behavior: Writer only sees the Analyst's output. The original research data from the Researcher is lost.

Expected (good) behavior: Writer reads the shared scratchpad and sees entries from both the Researcher and the Analyst, producing a report that integrates raw data with analysis.

Example 3

Scenario: Both Researcher and Analyst write to shared memory.

Current (bad) behavior: If they wrote to the same variable, one would overwrite the other.

Expected (good) behavior: Each entry is appended with attribution: [Researcher] ..., [Analyst] .... Nothing is overwritten.

Your Task

Add a shared scratchpad for multi-agent collaboration:

  • Create a shared data structure (e.g., a list) accessible to all agents.
  • Each agent can append entries with its name as attribution.
  • Each agent reads the full scratchpad before running so it has context from previous agents.
  • Entries are append-only — no agent can overwrite another's entries.

Evaluation

Submissions are checked for the following:

  • All agents can read shared memory: Every agent in the workflow can access the shared scratchpad.
  • Writes are attributed: Each entry tracks which agent wrote it.
  • No silent overwrites: Agents append to shared memory rather than overwriting.
  • Downstream agents see upstream data: Later agents can access findings from earlier agents.

Constraints

  • All agents must be able to read from the shared scratchpad
  • Writes to the shared scratchpad must not overwrite each other silently
  • Each entry must track which agent wrote it
  • The shared memory must be readable by all agents at any point in the workflow
Starter Code
from crewai import Agent, Task, Crew

# BUG: Each agent has isolated memory — they can't share findings
researcher = Agent(
    role="Researcher",
    goal="Find key data points about renewable energy trends.",
    backstory="You are an expert researcher who finds relevant data.",
    verbose=True,
)

analyst = Agent(
    role="Analyst",
    goal="Analyze data and extract insights.",
    backstory="You are a data analyst who turns raw data into insights.",
    verbose=True,
)

writer = Agent(
    role="Writer",
    goal="Write a compelling report from the analysis.",
    backstory="You are a technical writer who creates clear reports.",
    verbose=True,
)

# Each task runs in isolation — no shared scratchpad
research_task = Task(
    description="Research the top 5 renewable energy trends for 2025.",
    expected_output="A list of 5 trends with supporting data.",
    agent=researcher,
)

analysis_task = Task(
    description="Analyze the research findings and identify the most impactful trend.",
    expected_output="An analysis with the top trend identified.",
    agent=analyst,
)

writing_task = Task(
    description="Write a 3-paragraph summary report combining research and analysis.",
    expected_output="A polished 3-paragraph report.",
    agent=writer,
)

crew = Crew(
    agents=[researcher, analyst, writer],
    tasks=[research_task, analysis_task, writing_task],
    verbose=True,
)

result = crew.kickoff()
print(result)
Open in Google Colab
Evaluation Criteria0/4