StockFighter
Agents in Context Toronto: a MongoDB HackathonStock 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.




