Algolia-Central (Second-Brain)

v2/wiki/decisions/2026-06-28-stateless-replay-vs-redis.md

ADR: Conversation state — stateless messages[] replay + dossier, not Redis

Date: 2026-06-28 Status: Accepted Repo mirror: docs/design/adr-002-conversation-state-stateless-replay-vs-redis.md

Context

rc2 (reference) is stateful — it persists conversation + dossier in Redis. AC2 did not port Redis; it is stateless (client replays history as messages[]; transcripts/scores to disk). Question: isn't resending context wasteful, and was rc2's Redis better? Backlog B also tested whether Agent Studio's native memory could carry context (removing the need to replay).

Decision

AC2 stays stateless: messages[] replay + a compact dossier. No Redis. Native Agent Studio memory is NOT used as a context carrier (proven non-functional, Backlog B). Token efficiency is owned by the dossier, not the storage layer. Any future production persistence should prefer the dossier + Algolia's native transcript store (GET /conversations, 90-day) over standing up Redis.

Rationale

  • Redis vs replay is not a token tradeoff. The LLM is stateless — it must see prior turns in-context regardless of where they're stored. Either the client resends them or the provider injects them; the model processes the same input tokens either way. Redis = storage layer; replay = wire format — orthogonal. rc2's Redis was for persistence/scale, never token savings.
  • Token bloat is solved by the dossier — a compact structured summary ({industry, stack, scale, pain…}) that doesn't grow, instead of raw transcript. Both rc2 and AC2 have it.
  • For AC2 as an eval lab: short turns, independent reproducible questions — stateless is strictly better; Redis = pure overhead.

Alternatives Considered

Option Why rejected
Redis (rc2 parity) Stateful component + infra, no token benefit, worse reproducibility
Native Agent Studio memory Does not carry context via the completions API (Backlog B)
Raw full-transcript replay (no dossier) Unbounded token growth — the dossier exists to avoid this

Consequences

  • Cross-turn context depends on the caller threading history into messages[]. Discovery Onion state (dossier) stays custom — native memory is a transcript store, not a state engine.
  • No memory infra to operate. The "lean on native memory" option is closed.