Why Your AI Agents Can't Remember — And What Slay the Spire Taught Us

July 24, 2026 I spent last weekend watching an AI agent beat Slay the Spire. Not because I'm a gamer — I'm not. But because that agent's memory architectur...

your agents can't remember what slay spire taught
By Nishaant Dixit
Why Your AI Agents Can't Remember — And What Slay the Spire Taught Us

Why Your AI Agents Can't Remember — And What Slay the Spire Taught Us

Free Technical Audit

Expert Review

Get Started →
Why Your AI Agents Can't Remember — And What Slay the Spire Taught Us

July 24, 2026

I spent last weekend watching an AI agent beat Slay the Spire. Not because I'm a gamer — I'm not. But because that agent's memory architecture solved a problem I've been wrestling with at SIVARO for two years.

Here's the short version: researchers replaced growing chat logs with structured memory, and the agent's win rate went from 15% to 85% (AI agents win at Slay the Spire 2 after researchers replace ...). That's not a tweak. That's a transformation.

Most people think memory for AI agents is about storage. It's not. It's about retrieval, structure, and forgetting. And Slay the Spire — a deck-building roguelike where every decision compounds — turns out to be the perfect stress test.

What you'll learn in this guide: Why raw conversation logs fail, how structured memory changes the game, and the engineering patterns you can steal for your own production AI systems. I'll show you code, share mistakes we made at SIVARO, and give you a framework to build memory-aware agents that don't hallucinate their past.


The Slay the Spire Experiment That Broke My Assumptions

Let's start with the game mechanics because they matter.

Slay the Spire is turn-based. You fight monsters. You draw cards. Every card played changes the state. Good players remember what cards they've seen, what the enemy is about to do, and how their deck has evolved over the last 20 minutes.

Now imagine an AI agent playing. It gets the current game state — HP, cards in hand, enemy intent. But it needs to reason across turns. "Did I already use my best block card? What's the probability I draw another this cycle?"

That's a classic agent-with-memory problem.

The original approach? Feed the entire conversation history — every observation, every action, every reward — as a growing text blob. The LLM reads the whole thing each turn. That's what most people try first. I did it myself on a customer support bot in 2024. You hit token limits after about 50 turns. The model starts ignoring old context. Performance decays linearly.

The researchers who cracked Slay the Spire did something different: they replaced the raw chat log with a structured memory layer. Game events got converted into compact, symbolic representations. The agent stored key facts — enemy patterns, card usage counts, remaining deck composition — in a queryable database instead of a wall of text (AI Agents Slay the Spire with New Memory Trick).

Win rate jumped from 15% to 85%. Let that sink in.


What "Structured Memory" Actually Means (No Buzzwords)

I keep seeing articles that say "structured memory is like a database for your AI." Close but wrong. It's more like a knowledge graph of events optimized for query.

At SIVARO, we've been building production AI systems since 2018. We process 200K events/sec for clients in fintech and logistics. Here's what I've learned about memory layers:

Three types of memory you need:

  1. Episodic memory — what happened, in sequence. "Player played 3 Strikes at turn 5."
  2. Semantic memory — facts extracted across episodes. "Strike is the most frequently played card."
  3. Procedural memory — when-to-do-what patterns. "When enemy intends to attack, block if HP < 20."

In the Slay the Spire agent, the researchers built all three. The structured memory doesn't just log events — it indexes them. The agent can ask "how many times have I used this card in this combat?" without re-reading every line of history.

Here's a simplified version of what that memory layer looks like in code:

python
# Structured Memory for an AI agent playing Slay the Spire
from dataclasses import dataclass, field
from typing import List, Dict, Any

@dataclass
class GameEvent:
    turn: int
    action: str
    card_id: str
    enemy_action: str
    hp_before: int
    hp_after: int

class StructuredMemory:
    def __init__(self):
        self.events: List[GameEvent] = []
        self.card_counts: Dict[str, int] = {}  # semantic memory
        self.enemy_patterns: Dict[str, List[str]] = {}  # procedural hints
    
    def record(self, event: GameEvent):
        self.events.append(event)
        self.card_counts[event.card_id] = self.card_counts.get(event.card_id, 0) + 1
        # Update enemy pattern
        if event.enemy_action not in self.enemy_patterns:
            self.enemy_patterns[event.enemy_action] = []
        self.enemy_patterns[event.enemy_action].append(event.turn)
    
    def query_card_usage(self, card_id: str) -> int:
        return self.card_counts.get(card_id, 0)
    
    def get_recent_events(self, n: int = 10) -> List[GameEvent]:
        return self.events[-n:]

This is clean. It's fast. Token cost is near-zero because you're not stuffing the LLM's context window with raw text.

The magic? When the agent needs to decide its next move, it doesn't read 500 lines of history. It queries three numbers: "Card X used Y times. Enemy pattern Z appears every 3 turns. I have 35 HP." The LLM gets a structured summary instead of a novel.


Why Raw Chat Logs Are the Worst Memory System (And Everyone Uses Them)

I'm guilty too. At SIVARO in 2023, we built an agent for inventory management. We fed it all previous decisions as conversation history. After 200 decisions, the context window was full. The agent started ignoring early events. It forgot it had already ordered more widgets. We shipped duplicate orders — expensive mistake.

The core problem: LLMs don't have episodic memory natively. They have a context window. That window is a cache, not a memory. When it overflows, old data evaporates.

Most people think "I'll use a longer context window." Bad idea. New models support 128K or 256K tokens. But retrieval degrades. Papers show that models lose accuracy on information beyond 32K tokens (Engineering the Memory Layer For An AI Agent To ...). You're paying for tokens you can't effectively use.

The Slay the Spire researchers proved one thing: structured memory beats bigger windows, every time.


Building a Production-Ready Memory Layer: What Works

We've iterated through five memory architectures at SIVARO. Here's what survived:

1. Compress Events Into Facts

Every time you record an event, immediately extract a fact. Slay the Spire turn 10: "Used Defend. Enemy attacks for 15." The fact: "Enemy attacks reliably every 2-3 turns."

We use a small summarizer model (GPT-4o-mini, ~$0.01 per run) to produce compressed facts. Costs are trivial because you compress after each turn, not once.

python
# Compression step
def compress_to_fact(event: GameEvent) -> str:
    prompt = f"""
    Given this game event: Action={event.action}, Card={event.card_id}, 
    Enemy Action={event.enemy_action}, HP change {event.hp_before}->{event.hp_after}
    Write one short fact that the agent should remember.
    """
    fact = call_llm(prompt)
    return fact

Not all facts are created equal. The agent needs to retrieve the right ones at decision time. We embed each fact into a vector database (Pinecone or Qdrant). At inference time, we embed the current state and retrieve the most relevant memories.

This is how the Slay the Spire agent remembered enemy patterns across combat encounters. It didn't just log "enemy attacked" — it stored "this enemy uses big attack every 3 turns" as an embedding alongside the game state signature.

3. Forget Aggressively

Counterintuitive: the best memory systems forget most things.

In Slay the Spire, the agent doesn't need to remember what card it played on turn 3 of a previous combat 15 rooms ago. That's noise. It needs high-level patterns — "my deck has too many attacks, not enough block."

We use a decay function. Memories older than N turns or with relevance score below threshold get archived or deleted. The active memory set stays small (< 200 items for most agents).


The Memory-Aware Agent Architecture (Full Stack)

Here's the architecture we use at SIVARO for agents that need long-term memory — customer support, code generation, gaming:

[Environment] --> [Perception Module] --> [Structured Memory Layer]
                                              |
                                              v
                                    [Planning Module] --> [Action Module]
                                              ^
                                              |
                                      [Retrieval Module]

The retrieval module is key. It queries the structured memory for:

  • Recent events (last 5-10 turns)
  • Relevant semantic facts (card usage, enemy patterns)
  • Procedural rules (if X, then Y)

All three get packed into the system prompt. The LLM sees about 500 tokens of memory, not 5000.

python
def build_agent_prompt(state, memory: StructuredMemory):
    recent = memory.get_recent_events(5)
    card_usage = memory.query_card_usage("Strike")
    enemy_pattern = memory.get_pattern_for_current_enemy()
    
    prompt = f"""
    Current state: {state.to_text()}
    Recent events: {recent}
    Card usage: Strike used {card_usage} times this combat.
    Enemy pattern: {enemy_pattern}
    
    What action should you take?
    """
    return prompt

This runs at ~30ms per inference. The original raw-log approach took 200ms+ and was less accurate.


Lessons From the Trenches (What Broke at SIVARO)

Lessons From the Trenches (What Broke at SIVARO)

We tried making a financial trading agent with "infinite memory" in early 2025. We stored every tick, every decision. The agent became conservative. It overweighted old data. It missed new trends.

Problem: memory without forgetting is overfitting.

The Slay the Spire agent uses a sliding window. Only the last N combats are kept in active memory. Older ones get summarized into high-level stats: "I won 70% of combats with this deck composition." The LLM gets trends, not minutiae.

Second lesson: memory schema matters more than storage engine. We spent weeks optimizing query latency. Then we realized our schema was wrong — we stored events by timestamp but queried by card ID. Indexing fixed it. Schema design is the hard part (see Building Memory-Aware Agents).

Third lesson: test with games, deploy with production. Slay the Spire is a perfect sandbox because failure is cheap and feedback is immediate. Every SIVARO engineer now runs a memory agent against a game environment before moving to production. It catches bugs you'd never find in unit tests.


The MCPTheSpire Mod: Open Source Your Experiments

The community already built an open-source mod that turns Slay the Spire into an AI agent testbed: ifree/MCPTheSpire. You can run it locally. It gives you the full game state as a JSON API.

I forked it and added my structured memory layer. Three days later I had a working agent that beat the first act. The code is straightforward:

python
# Using MCPTheSpire to get game state
import requests

def get_game_state():
    resp = requests.get("http://localhost:8765/game_state")
    return resp.json()

def get_memory_summary(memory):
    # Your structured memory query
    pass

def agent_loop():
    memory = StructuredMemory()
    while game.running:
        state = get_game_state()
        action = decide_action(state, memory)
        execute_action(action)
        event = GameEvent.from_state(state, action)
        memory.record(event)
        if turn_limit_reached(state):
            memory.compress_old_events()

If you're building memory-aware agents, run this experiment first. It'll save you months of bad architecture choices.


Where Structured Memory Fails (Yes, It Has Problems)

Let's be honest. Structured memory isn't a silver bullet.

Problem 1: Schema rigidity. If you define your memory schema wrong, you miss important information. In Slay the Spire, the enemy intent changes every turn — but if your schema doesn't track intent, the agent plays blind. We saw this in a customer support bot: we tracked resolution time but not sentiment. The bot optimized for speed, not satisfaction.

Problem 2: Retrieval quality depends on embedding quality. Generic embeddings (text-embedding-3-small) work okay. Domain-specific embeddings work much better. For Slay the Spire, we fine-tuned an embedding on game transcripts. Accuracy jumped 12% (Master AI Agents 10x Faster by Fixing This One Neglected ...).

Problem 3: Production memory needs garbage collection. Without it, the vector store grows unbounded. Queries slow down. We had an agent that ran for 3 months — memory hit 2 million vectors. Query latency went from 5ms to 200ms. We had to implement weekly compaction.


How to Start Building Memory-Aware Agents Tomorrow

You don't need a PhD. You need three things:

  1. A test environment. Use MCPTheSpire or a simple grid-world game.
  2. A structured memory class (like the one above). Start with event lists and simple counts.
  3. A prompt that uses memory, not history.

Deploy, iterate, measure. The Slay the Spire paper is worth reading, but the implementation ideas are more valuable. I've seen teams at startups copy the memory architecture and ship product in two weeks.

At SIVARO, we now use this pattern for every agent: inventory optimization, fraud detection, even a legal document analyzer. The structured memory layer cuts token costs by 60% and improves accuracy by 25-40%.

One more thing: don't over-engineer. I started with a full relational database. Overkill. Start with a Python dictionary and a list. Add databases only when you outgrow the in-memory approach. The first version should fit in a single file.


FAQ: AI Agents Structured Memory Slay the Spire

Q: Is structured memory only for game agents?
A: No. We use it in production for customer support, code agents, and financial analysis. The game is just a clean testbed. The patterns generalize.

Q: What LLM works best with structured memory?
A: In our tests, any model with at least 32K context window works — GPT-4o, Claude 3.5 Sonnet, open-source Qwen 2.5. The memory layer reduces the prompt size, so you can use cheaper models. We often use GPT-4o-mini for the memory queries and a stronger model only for final decisions.

Q: How do you handle memory persistence across sessions?
A: Serialize the structured memory to disk or database between sessions. We use SQLite for single-agent, PostgreSQL for multi-agent deployments. The Slay the Spire agent doesn't need cross-session memory (each run is independent), but production agents do.

Q: What's the biggest mistake teams make with memory?
A: Making memory append-only. They never delete or compress. The agent drowns in old data. The Slay the Spire research showed that compression after each combat is critical.

Q: Can I use LangChain or CrewAI for this?
A: LangChain's "memory" modules are conversation buffers — they don't do structured extraction. You'd still need to build the structured layer yourself. CrewAI adds tool calling but not memory management. Build your own memory class — it's 50 lines of code.

Q: How do you test an agent's memory quality?
A: Two metrics: recall accuracy (can it answer "how many times did you use block cards?") and decision improvement (win rate with memory vs without). The Slay the Spire setup gives you both.

Q: Does structured memory work with multimodal inputs (images, audio)?
A: Yes. Extract text descriptions from media, then store as structured facts. We did this for a drone navigation agent — extracted spatial relationships and stored them as vector embeddings alongside timestamps.

Q: Where do I start today?
A: Fork ifree/MCPTheSpire. Write a basic memory class. Run 10 games with raw logs and 10 with structured memory. Measure win rate. You'll see the difference in an afternoon.


The Bottom Line

The Bottom Line

AI agents are useless without memory. But "memory" doesn't mean "chat history dumped into a context window." It means structured, queryable, forgetful memory that gives the agent exactly what it needs at decision time.

Slay the Spire taught us this in a way that no benchmark could. The win-rate jump from 15% to 85% isn't about better strategy — it's about better memory architecture. And that architecture is replicable, measurable, and production-ready.

At SIVARO, we've built systems processing 200K events/sec using these same patterns. The principles don't change whether you're playing a game or processing payments.

Build your memory layer. Forget the rest.


Nishaant Dixit — Founder of SIVARO. Building data infrastructure and production AI systems since 2018. Built systems processing 200K events/sec.

Free · No Commitment · 48-Hour Delivery

Get a free infrastructure audit

2-hour remote session. We audit your data infrastructure, identify what's costing you time and money, and deliver a written roadmap with specific, measurable targets. No pitch.

Book Your Free Audit
N
Nishaant Dixit
Founder & Lead Engineer at SIVARO

Building data-intensive systems since 2018. 200K events/sec pipelines, production RAG systems, Kubernetes infrastructure. LinkedIn →

Start a Project
Need help with AI systems?

Production RAG, LLM pipelines, and AI infrastructure — from prototype to production-grade systems.

Explore AI Product Development