prxy.monster API-key BYOK is live. Start free

rehydrator

Category: context · Cloud + Local · Status: v1.0 — production

Detects “remember when…” / “earlier we…” / “go back to…” style triggers in the user message. Searches the archived (compressed-out) context for matches. Pulls the relevant archived turns back into the active prompt.

When to use it

Dependency on ipc

The rehydrator reads from blob storage at evictions/{user_id}/* — the same path ipc writes archived turns to in cloud mode. If ipc isn’t in your pipeline (or it hasn’t archived anything yet) the rehydrator is a clean no-op. It logs nothing and adds no latency. You don’t need a guard.

Configuration

rehydrator:
  triggerPhrases:
    - 'remember'
    - 'earlier'
    - 'previously'
    - 'before'
    - 'last time'
    - 'we discussed'
    - 'we were'
  maxRehydrated: 5         # cap on the number of archived turns re-injected
  searchDepthDays: 90      # ignore archives older than this
  similarityThreshold: 0.7 # cosine similarity floor for a candidate to qualify
  blobPrefix: 'evictions'  # change if you write archives to a different prefix
  maxBlobsScanned: 50      # safety cap per request

All fields are optional. Defaults shown.

Metrics emitted

How it works

  1. Pre hook scans the latest user message for any configured trigger phrase. If none match, it short-circuits (sets rehydrator.matched = 0, returns continue).
  2. Lists archive blobs at evictions/{userId}/. Sorts most-recent-first by key (timestamp leads the file name).
  3. For each archive newer than searchDepthDays, embeds each archived turn and computes cosine similarity vs. the current user message.
  4. Keeps the top maxRehydrated turns above similarityThreshold, re-orders them chronologically, and injects them into the system prompt inside a <rehydrated-context> block so the model knows it’s looking at recovered context, not fresh user input.

Pipeline placement

Run it before patterns so any retrieved patterns can build on the rehydrated context:

PRXY_PIPE=ipc,rehydrator,patterns,semantic-cache

Source

src/modules/rehydrator.ts