📦 Moved to new directory. Last updated 12.2.2026. New location: claude-config/library/03-memory-state/deep-dives/state-15-hot-cold-state-architecture.html

Deep dive 15 of 27: The Hot/Cold State Architecture

Nov 19, 2026 · Michael Chang · Status in NurseOps Now: ✅ built

Show definitions in ( ) · hover a highlighted word for its meaning, click it for details · open with ?defs=1 to show definitions

Part of: Remembering the right things: state management in NurseOps Now, section Implementing Long-Term Memory: External Persistence Architecture (7.3) · All 27 solutions · ← The Engineering Trade-off: Fidelity vs. Capacity · Structured Storage (SQL/Postgres) →

Read in this order

  1. In plain words: what it is, without jargon
  2. The problem it solves: the problem, and the standard approach in my words
  3. How to implement it (ServiceApps): scenario, steps, code and real output
  4. In NurseOps Now: built or not, and where
  5. Trade-offs and Interview answer

In plain words

Hot state (what is in the current AI call) is what the AI is working with right now, in memory for this call. Cold state (what is saved in a database for later) is what's saved in a database for later: preferences, history, finished tasks. Each call loads the bit of cold state (what is saved in a database for later) it needs into hot state (what is in the current AI call), and saves what matters back.

In plain terms: hot is what's on your desk today; cold is the filing cabinet.

The problem it solves

Summarization solves volume, not time (a summary shrinks memory but doesn't survive a crash or restart): if everything lives (using the real Claude API (costs money), not a fake stand-in) in the window, a crash, a closed tab or a new session loses it.

The standard approach (in my words): separate hot state (what is in the current AI call) (context window (everything sent to the AI in one call; it has a size limit) and RAM: fast, volatile, current reasoning) from cold state (what is saved in a database for later) (SQL, NoSQL or a vector (text turned into a list of numbers so similar meanings sit close together) database: durable, slower, long-term facts).

How to implement it (ServiceApps)

Illustrative example: no ServiceApps (a company platform for IT tickets, HR requests and help-center articles) instance is connected, so the scenario and data are made up. The code is a self-contained sketch; it was run on that made-up data on Nov 19, 2026, and the output below is from that run.

The setting. ServiceApps (a company platform for IT tickets, HR requests and help-center articles) Assist, an AI helper inside a company's ServiceApps (a company platform for IT tickets, HR requests and help-center articles) portal. Employees ask it IT and HR questions; it answers from knowledge-base (KB (knowledge base: a library of help articles)) articles, looks up the employee's own tickets (incidents (a ServiceApps ticket for something broken) like INC0012345) and requests, and keeps one conversation per employee and ticket.

The scenario. ServiceApps (a company platform for IT tickets, HR requests and help-center articles) Assist answers "Is my laptop under warranty?" using a saved profile, with scratch notes that are thrown away after the call.

Steps.

  1. Keep a cold store (a database) for facts that must survive.
  2. At the start of a call, load the needed cold facts into hot state (what is in the current AI call).
  3. Keep scratch reasoning hot only.
  4. At the end, write back what should be remembered and clear hot state (what is in the current AI call).

The code (Python):

import sqlite3, json
cold = sqlite3.connect(":memory:")               # stand-in for the database
cold.execute("create table facts(user text, key text, value text, primary key(user, key))")
hot = {}                                         # in RAM: this call only

def remember(user, key, value):
    cold.execute("insert or replace into facts values(?,?,?)", (user, key, json.dumps(value)))

def start_call(user, question):
    hot.clear()
    hot["question"] = question
    hot["profile"] = {k: json.loads(v) for k, v in cold.execute("select key, value from facts where user=?", (user,))}
    hot["scratch"] = []

def end_call():
    hot.clear()

remember("u42", "preferred_contact", "email"); remember("u42", "asset", "LT-4471")
start_call("u42", "Is my laptop under warranty?")
hot["scratch"].append("look up the warranty for LT-4471")
print("hot during the call:", hot)
end_call()
print("hot after the call :", hot)
print("cold (kept)        :", cold.execute("select key, value from facts").fetchall())

Output (from running the code above):

hot during the call: {'question': 'Is my laptop under warranty?', 'profile': {'asset': 'LT-4471', 'preferred_contact': 'email'}, 'scratch': ['look up the warranty for LT-4471']}
hot after the call : {}
cold (kept)        : [('preferred_contact', '"email"'), ('asset', '"LT-4471"')]

What to watch for.

In plain terms: take the one file you need out of the cabinet, work on it, file the result, clear the desk.

In NurseOps Now

Built. Hot = the window built per call; cold = SQLite (cases, reviews, decisions, audit (a permanent record of who did what and when)), LangGraph (a tool for building AI workflows step by step) checkpoints (saved copies of a conversation's state) for chat, and Chroma (the database that stores the policy vectors) for policies (the health plan's written rules for when tests are covered). See the Intro and Step 1.

Trade-offs

Interview answer

"I split memory into hot state (what is in the current AI call) for the current call and cold state (what is saved in a database for later) in a database. Each call loads only what it needs from cold storage, does its work in memory, and writes back what should be remembered, so restarts and new sessions lose nothing."

All data in this post is made up. No real people, tickets or patient data.

← Back to all 27 solutions in the state management blog

Key terms

Every highlighted word in this post links here. Click ↩ Back to return to the spot you came from.

audit
A permanent record of who did what and when.Used in: In NurseOps Now↩ Back to where you were
checkpoints
Saved copies of a conversation's state.Used in: In NurseOps Now↩ Back to where you were
Chroma
The database that stores the policy vectors.Used in: In NurseOps Now↩ Back to where you were
cold state
What is saved in a database for later.Used in: In plain words, The problem it solves, How to implement it (ServiceApps), Interview answer↩ Back to where you were
context window
Everything sent to the AI in one call; it has a size limit.Used in: The problem it solves↩ Back to where you were
hot state
What is in the current AI call.Used in: In plain words, The problem it solves, How to implement it (ServiceApps), Interview answer↩ Back to where you were
incident
A ServiceApps ticket for something broken.Used in: How to implement it (ServiceApps)↩ Back to where you were
KB
Knowledge base: a library of help articles.Used in: How to implement it (ServiceApps)↩ Back to where you were
LangGraph
A tool for building AI workflows step by step.Used in: In NurseOps Now↩ Back to where you were
latency
How long it takes to respond.Used in: Trade-offs↩ Back to where you were
live
Using the real Claude API (costs money), not a fake stand-in.Used in: The problem it solves↩ Back to where you were
policies
The health plan's written rules for when tests are covered.Used in: In NurseOps Now↩ Back to where you were
ServiceApps
A company platform for IT tickets, HR requests and help-center articles.Used in: How to implement it (ServiceApps)↩ Back to where you were
state
Everything the app must remember to continue correctly.Used in: Trade-offs↩ Back to where you were
summarization solves volume, not time
A summary shrinks memory but doesn't survive a crash or restart.Used in: The problem it solves↩ Back to where you were
vector
Text turned into a list of numbers so similar meanings sit close together.Used in: The problem it solves↩ Back to where you were