← cs
$ cat projects/LLM-Agent-Memory.md

LLM Agent Memory in Repeated Social Dilemmas

How much memory do LLM agents really need to sustain cooperation in a repeated public-goods game?

Final project for 6.7960 - Deep Learning

2025-12-09
Python

LLM Agent Memory in Repeated Social Dilemmas

MIT 6.7960 final project. The question was whether the amount of memory an LLM agent carries drives cooperation, or whether the shape of it matters more.

Three GPT-4o-mini agents play a repeated public goods game: 10 rounds, starting budget 20, contribution cap 10, multiplier α=1.8. Five memory representations share one interface, so the only thing that changes across conditions is the block of text spliced into the prompt. That is what makes it an ablation rather than five different agents.

  • None: no history at all
  • Full history (k=5): last k rounds verbatim
  • Summary: an LLM-generated rolling 50-word summary
  • Structured: a numerical trust table
  • Hybrid: trust table plus a free-text strategy note

Every module also reports its own token estimate, so what a memory costs is measured by the same object that produces it. Metrics use 95% bootstrap confidence intervals over 10,000 resamples.

| Memory | Welfare (95% CI) | Mean contribution | Tokens/episode | |---|---|---|---| | None | 120.3 [120.0, 120.7] | 5.01 | ~11,200 | | Full History (k=5) | 120.5 [120.0, 121.4] | 5.02 | ~16,900 | | Summary (50w) | 124.0 [122.1, 126.2] | 5.17 | ~13,600 | | Structured | 123.0 [120.7, 126.0] | 5.13 | ~14,700 | | Hybrid | 240.0 [240.0, 240.0] | 10.00 | ~15,500 |

The result that holds up

Full history buys nothing. It costs 50% more tokens than no memory at all and lands at 120.5 against 120.3, well inside the interval. If you believe more context produces more coordination, this is the cheapest available counterexample.

The result I had to argue myself out of

Hybrid memory looks like it doubles welfare. It does, arithmetically. But hybrid agents contribute 10 out of 10 every round and everyone else contributes almost exactly 5, so 240 against 120 is "played the maximum" against "played half", not a graded improvement. The alpha sweep makes that obvious: 75 against 150 at α=1.5, 120 against 236 at α=1.8, 165 against 330 at α=2.1. Exactly 2x every time is the signature of a ceiling, not of a mechanism that scales with the payoff.

Then there is where the effect comes from. The hybrid strategy note is seeded from round one with the literal string "Start by cooperating to establish trust." Rerunning it with a neutral note collapses welfare to 124.2, which is the baseline. The trust table on its own does essentially nothing: 120.8 against 120.0.

So the honest claim is not that a richer memory representation produces cooperation. It is that a cooperative instruction carried inside the memory string produces cooperation, and that this is easy to mistake for a finding about memory architecture because the instruction happens to live in the memory. I would rather report that than the headline.

Which points at the actual next experiment: adversarial and defecting agent populations, where a cooperative prior should get punished rather than rewarded, and where whatever the trust table is worth would finally have something to do.