My agent kept retrying the same failing command across sessions. Rules files didn't stop it — agents forget between sessions, and markdown can't enforce anything. So I built dejavu: an OpenCode plugin that mechanically detects recurring tool-call failures and promotes them into enforced gates.
How it works
tool call fails → signature normalized (paths/numbers/hashes stripped)
→ pattern-key counted, sessions tracked
→ 3 failures across 2 sessions → gate promoted
next attempt → [dejavu] REMINDER (call aborted, agent sees the correction)
retry fails → hard BLOCK for the rest of the session
No LLM in the hot path — normalized signatures and counters only.
Design decisions that matter
-
Remind first, block on repeat. Pure blocking starts an arms race (block
npm→ agent switches topnpm). A reminder with a CORRECTION teaches; the block is reserved for ignored reminders. -
Diagnostics never block.
grep/tsc/pytestexiting 1 is their normal "found nothing" outcome. Only non-diagnostic bash can ever become a blocking gate. -
Two scopes. Repo quirks live in
<repo>/.opencode/dejavu/(committable); patterns seen in 2+ projects are agent habits and escalate to the global store. -
Gates rot. 60 days without recurrence → expired. And
recurredAfterGatetells you when a gate fires but doesn't teach. - Secrets never persist. Every signature and snippet is scrubbed (OpenAI/Anthropic/AWS/GitHub/Stripe/JWT/PEM/DB-conn patterns) before touching disk.
Install
// ~/.config/opencode/opencode.json
{ "plugin": ["opencode-dejavu"] }
TypeScript + Bun, zero runtime deps, MIT.
Repo: https://github.com/WhiteBite/opencode-dejavu · npm: opencode-dejavu
Feedback welcome from anyone running long-lived agent setups.

Top comments (0)