Lakuna · docs

Strategy memory (Inter-Cascade)

Every cloud escalation produces a short, reusable strategy for that kind of input, embedded and stored via a swappable index (app/lib/strategy-store.ts, app/lib/embedding.ts). The next similar request retrieves the closest matches and injects them into the local model's prompt, in-context transfer only, never fine-tuning, never a weight update.

By default that index is a Redis linear scan, fine at low volume but O(n) per request. Set UPSTASH_VECTOR_REST_URL and UPSTASH_VECTOR_REST_TOKEN to switch to an Upstash Vector index instead - same three functions (addStrategy, retrieveStrategies, strategyCount), server-side ANN search underneath.

strategy-store.ts
on cloud escalation:
  vector = embed(prompt)
  index.add({ vector, strategy: cloud.reasoning })

on next local attempt:
  matches = index.query(embed(prompt), topK: 2, minSimilarity: 0.6)
  prompt = system + matches.map(strategy)

  try(local, prompt) -> confidence.evaluate -> pass | escalate