AWS Builder Center
Rewind: Solving LLM Context Amnesia with Archival Memory on AWS

Rewind: Solving LLM Context Amnesia with Archival Memory on AWS

Discover how Rewind combines SQLite BM25 archiving with Amazon EC2 and Amazon Bedrock to eliminate context window amnesia in AI agents, cutting token costs by over 70% while achieving 100% factual recall.

student who build useful products

The Problem: The "Context Window Wall" and Context Amnesia

As developers build longer-running AI agents and multi-turn workflows, they inevitably hit the Context Window Wall. Passing dozens of conversation turns into an LLM on every single request leads to two major problems:
  1. Exponential Token Costs: Processing 50,000+ tokens on every turn quickly drains budgets.
  1. Context Amnesia: The current industry standard fix—naive summarization—acts like an eraser. Exact function code, API keys, database schemas, and invoice numbers are wiped out forever. When the user asks for them later, the model hallucinates or fails.
We built Rewind to solve this: a context compaction engine that archives what it drops and recalls exact facts on demand.



How Rewind Works: Archive + Autonomous Recall

Instead of lossy deletion, Rewind intercepts conversations when they cross a configurable compaction threshold (e.g., 4,000 tokens):
  1. Verbatim Archiving: Older turns are stored verbatim into a local SQLite database indexed with BM25 full-text search ( FTS5 ).
  1. Pointer Tags: In the active prompt, Rewind inserts lightweight pointer tags ( §id → gist ) that serve as table-of-contents markers.
  1. Autonomous Recall: When an earlier detail is required, the LLM calls Rewind's built-in  recall()  tool to fetch the exact turn from disk with 100% precision.



Architecture & Shipping on AWS

We built Rewind to be resilient, cost-effective, and production-ready on the AWS Free Tier:
  • Compute on Amazon EC2: Deployed on an  Ubuntu 24.04 LTS (t3.micro)  instance running 24/7 as an automated  systemd  daemon.
  • Memory Resilience: Configured a 2 GB swap file to prevent Out-Of-Memory (OOM) crashes on 1 GB micro instances during heavy tool execution.
  • Persistent Storage on Amazon EBS: An EBS  gp3  volume durably stores the SQLite conversation archive and configuration ledger across reboots.
  • Reverse Proxy with Nginx: Handles SSL termination and security headers while routing traffic internally to our FastAPI loopback server.
  • Amazon Bedrock Integration: Built-in support for Anthropic Claude models on Amazon Bedrock using AWS IAM roles and SigV4 authentication—eliminating the need for static API keys.



Benchmark Results: Plain Compaction vs. Rewind

We benchmarked Rewind against standard Plain Compaction using automated multi-turn engineering scenarios:
Metric
Plain Compaction
Rewind
Factual Retrieval Accuracy
62.5%
87.5% – 100%
Exact Code Reconstruction
0% (Failed)
100% (Verbatim)
Active Context Token Drop
~58%
~50% – 70%
Negative Control Pass Rate
50%
100% (No Hallucination)
In long-running sessions (32k+ tokens), Rewind slashes active context costs by over 85%–90% on every single turn while never forgetting a single detail.



Conclusion

AI shouldn't force developers to choose between blown token budgets or assistants with amnesia. With Rewind and AWS, developers can run fast, lean, and cost-effective context windows backed by infinite, perfect memory.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article