2.1 KiB
006: Reverse RAG: cross-page context via encrypted localStorage
Reporter: fxhp Date: 2026-03-03 Priority: medium Status: fixed Affects: Browser extension, embedded widget
Description
When a user browses multiple pages on the same site, the machine learning model should be able to reference content from previously visited pages. Currently each page is isolated: the model only knows the current page's content.
Goal
Build a reverse RAG system where page summaries are stored in encrypted localStorage (per-domain), and automatically included in the system prompt for new pages. This gives the model a growing knowledge base about the site as the user browses.
Architecture
- After generating the intro message for a page, extract a brief summary (title, key topics, 2-3 sentences)
- Store summaries per-domain in vault-encrypted localStorage:
uncloseai-pageknowledge-{domain} - On new pages, include the last N page summaries in the system prompt as context
- Summaries should be compact (under 200 tokens each) to avoid context overflow
- Use the existing
fitPageContent()budget system to allocate space for cross-page context
Privacy
All cross-page data must be encrypted via the vault, same as chat history. The user controls their data. No data leaves the device except through explicit LLM requests.
Dependencies
- Site journey tracking (implemented in storage.js)
- Vault encryption (already working)
fitPageContent()context budgeting (already working)
Notes
This is the foundation for making uncloseai "unstoppable" on any site. The model gets smarter the more pages you visit, building a personal knowledge graph of the site, all stored locally and encrypted.
Resolution
Page-summary storage (per-domain, vault-encrypted via savePageSummary /
loadPageSummaries in storage.js) and prompt backfill landed per the
architecture above. Step 3's "include the last N page summaries" was
later sharpened from recency selection to BM25 relevance ranking against
the current page: see #009 Resolution (commit 2834e99). Summaries now
included are the ones similar to the page in view, not just the most
recent.