Skip to Main Content

Stock Fighter: Governed Memory for AI Agents Inspiration Persistent memory lets AI agents learn from experience, but a lesson that worked yesterday can be exactly wrong today, and an agent that keeps trusting it gets worse over time. We wanted to test whether agents can use memory without clinging to outdated lessons. What it does Stock Fighter is a stress lab for agent memory. Seven trading agents (momentum, contrarian, conservative, aggressive, adaptive, breakout, dip-buyer) fight it out in a simulated stock market that shifts from bull to bear to volatile and can be hit by shocks like a chip export ban. Every run is played three ways: no memory, raw memory (remember everything, trust it blindly), and governed memory (check whether each lesson still applies and retire the ones that stop working). The Memory Arena viewer replays all three side by side: equity race, leaderboard, regime timeline, the memories behind each decision, and what each agent would have done without them. How we built it Simulation: a deterministic, seeded TypeScript engine. Same seed, same market, every time. The engine alone decides prices, fills and P&L; agents can only propose orders. Market data: agents get features (returns, volatility, momentum) and an inferred regime. They are never told the true regime. Agents: LLM-driven (OpenAI structured outputs), with every decision validated by Zod before it touches the market. Memory citations must match what was actually retrieved. Memory: lessons are embedded and stored in MongoDB Atlas. Each agent's memories are isolated in the database query itself. Governed lessons carry a regime scope, reliability, and lifecycle states (active, invalidated, superseded), and every change records a reason. Evaluation: a reproducible harness runs every scenario × memory mode across 20 seeds, using deterministic versions of the seven strategies, and measures adaptation, stale-lesson influence, repeated mistakes, and counterfactual decision flips. Results Across 20 seeds in the regime-reversal scenario, governed memory cut reliance on stale lessons from 94% to 48% of memory-driven decisions. It also lost the least money of the three modes (−$144 vs −$248 raw and −$456 no memory). In stable and shock markets it stays close to raw memory, so the gains are concentrated where they matter: when the world changes. Challenges Keeping the experiment honest. We caught and removed several paths where ground truth leaked into the agents (for example, the true market regime), unified two competing regime estimators, and made every run reproducible so the comparisons are fair. What we learned More memory is not more intelligence. The value is in governance: knowing what to retrieve, when a lesson no longer applies, and when to forget. What's next Evidence-based invalidation in the live LLM run, longer live scenarios driven by our Chaos Director, and testing governed memory beyond markets.

Team

nanarimpongsahilg123Yenooh+1

More from Agents in Context Toronto: a MongoDB Hackathon

We simulate real world agent to agent systems built on MongoDB, Langchain (harnesses) ready for use in production to defend all systems. A swarm of real AI…

Legacy Siege project preview

suture is an incident-recovery agent that finishes the job even when its worker crashes mid-run. Cleaning up a leaked key takes a chain of writes across…

suture project preview

Venues play one playlist for everyone, and the apps that let guests shape the music keep their likes on view with no easy way to take them back. Musory: your…

Musory project preview

Robots are starting to learn from people, and fleets can share what one robot learns with every other robot. Nobody can yet answer three questions: who taught…

One Lesson project preview

Phylax Tower is a safety net for airport control towers. In March 2026 at LaGuardia, a jet was cleared to land, and two minutes later a fire truck was cleared…

Phylax Tower project preview

New hires hit the ground at light speed. New devs lose their first days juggling broken setup guides, each solving the same problems alone. Day One finishes…

Day One project preview