「この仕事のノリ、前に対処した件と同じだわ」
Déjà Vu Protocol gives LLM agents semantic memory of past successes. When a new task is similar but not identical to a stored success pattern, it fires a déjà vu event — boosting dopamine and loading the proven GDC reasoning template.
if not exact_match and cosine_similarity(current_task, past_success) > 0.85:
neurostate.dopamine += 30 # 「いける気がする」mode
gdc.apply_template(past_success.gdc_shape)python3 -m venv .venv
.venv/bin/python -m pip install -e ".[dev]"from dejavu import DejaVuEngine
engine = DejaVuEngine(threshold=0.85)
# Record a success
engine.record_success(
task="fix the XSS vulnerability in login form",
gdc_shape={"depth": 2, "nodes": 4, "branch": "feat/security"},
neurostate={"joy": 70, "stress": 20},
)
# Check a new task
event = engine.check("sanitize user input in signup page")
print(event)
# [DVP] 🌀 Déjà vu fired! similarity=0.8823 dopamine+30 | 「この仕事のノリ、前に対処した件と同じだわ」
if event.fired:
ns = engine.apply_neurostate_boost(event, {"dopamine": 50, "stress": 40})
print(ns) # {"dopamine": 80, "stress": 30}
gdc_template = event.gdc_template # load proven reasoning shapeNew task arrives
↓
Encode as vector (BoW / sentence-transformers)
↓
Compare against all stored success patterns
↓
exact_match? → NO déjà vu (just repetition)
similarity > threshold? → 🌀 DÉJÀ VU FIRES
↓
dopamine += 30 | load GDC template | reduce stress
Default: pure-Python bag-of-words (zero dependencies).
For production accuracy, swap to sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("all-MiniLM-L6-v2")
class STEmbedder:
def encode(self, text: str) -> list[float]:
return model.encode(text).tolist()
engine = DejaVuEngine(embedder=STEmbedder(), threshold=0.85)DVP integrates with the cognitive OS stack:
- NeuroState — receives the dopamine boost on déjà vu
- GDC — provides the reasoning template to load
- CPOS — kernel that can route tasks through DVP before dispatching
MIT