Existing memory plugins (such as Mem0, Letta) tend to make agents remember everything. dsh-memory-forget does the opposite: it turns “forgetting” from a failure into a design. It provides AI agents with mechanisms to manage memory lifecycles, including TTL, decay, eviction, and auditing.

Positioning

This is a forgetting engine for AI agents. Its core value lies in answering “when to forget,” “which memories are still trustworthy,” “how much context to inject,” and “what the current context contains.” This plugin is maintained by XIAOke8698, is released under the MIT License, and has zero core dependencies.

Core Features

  • Pluggable Memory Bus: Memory plugs in; forgetting unplugs. Forgetting is a protocol operation, not a failure.
  • Shelf Life and Decay: Every memory has a TTL and decay logic based on the Ebbinghaus curve (active -> stale -> forgotten).
  • Importance Management: Supports explicit marking (pin: true), or earns importance through usage (sliding update mechanism, “use it or lose it”).
  • Restorability: Supports restoring forgotten memories; the restore operation generates a new ID and TTL, with audit records.
  • Auditing and Privacy: Physically deletes content by default; only retains a SHA-256 hash for audit trails.
  • Hard Injection Budget: Limits the number of Tokens per injection (default 2000); dead memories are never injected, and when over budget, reduces the selection rather than truncating.
  • Token Accounting: Provides status() queries and preview() non-intrusive previews for cost accounting.
  • Multi-Agent Scope: Supports workspace, session, and team-level scopes; automatically unplugs temporary memories when sub-agents die.
  • Lightweight and Privacy-First: No Embedding, no LLM rewriting, no server process. Physical deletion by default.

Installation and Enablement

Install via the DSH official plugin command. Ensure the runtime is Node.js >= 20.

dsh plugin --profile <name> add @xiaoke8698/dsh-memory-forget

Use the remove command when uninstalling; memory data is retained in .dsh-memory-forget/store.json under the workspace directory.

Typical Usage

When using it as a library, first create an AmnesiaEngine instance.

import { AmnesiaEngine } from '@xiaoke8698/dsh-memory-forget'

const memory = new AmnesiaEngine({ restorable: true })

// 插入带保质期的记忆
const v = memory.plug({
  content: 'validation drink is lapsang',
  ttlMs: 60_000,
  kind: 'preference',
  tags: ['validation'],
})
// 输出包含 ID 和过期时间

// 查看健康状态(活跃/陈旧/遗忘计数及 Token 占用)
console.log(memory.status())

// 查询记忆会触发滑动 TTL(use it or lose it)
memory.recall('lapsang')

// 物理删除记忆
memory.unplug({ id: v.id })

// 恢复已遗忘的记忆(restorable 模式)
const back = memory.restore(v.id)

// 预算化注入选择(死记忆不入选)
const sel = memory.selectForInjection(2000)
console.log(sel.tokens, sel.skippedDead)

// 预览(不触发任何操作)
console.log(memory.preview())

Persistence

The engine runs in memory by default. If persistence is required, provide a StoreAdapter.

import { readFile, writeFile } from 'node:fs/promises'
import { AmnesiaEngine } from '@xiaoke8698/dsh-memory-forget'

const memory = new AmnesiaEngine({ restorable: false }, {
  async load() {
    try { return JSON.parse(await readFile('memories.json', 'utf8')) }
    catch { return undefined }
  },
  async persist(items, audit) {
    await writeFile('memories.json', JSON.stringify({ items, audit }))
  },
})
await memory.ready

Use Cases and Notes

Suitable for scenarios that require strict control of context length, prevention of memory pollution (such as outdated facts or poisoned memories), and need audit trails. Note: the current version of the engine is in-memory based; you need to implement StoreAdapter yourself to ensure data persistence; it depends on Node.js >= 20.

Conclusion

Through active forgetting strategies, context pollution can be avoided and agent reasoning quality can be improved. For more details and source code: GitHub | Plugin Catalog