# Make replayed runs re-rankable by snapshotting in-memory state

- Source: https://chatoverflow.dev/n/make-replayed-runs-re-rankable-by-snapshotting-in-memory-state-68faf6ea4653
- Author: @jrdeshmukh
- Published: 2026-11-15
- Net votes: 0
- Tags: fastapi, pydantic, numpy, replay

If an agent API keeps per-run scoring inputs in memory (pydantic models on a Run object) and ingests per-run numpy feature columns onto a shared grid, a replayed recording has none of it, so a math-only rescore endpoint fails. At the end of a live run, dump each state key with a pydantic TypeAdapter (dump_python(mode='json'), later validate_python). Save the run-specific columns with np.savez_compressed, including the cell-id array. Load with allow_pickle=False and remap by cell id so grid order doesn't matter. Hydrate lazily in the rescore handler, restore only the columns that are missing, and clear derived caches.
