OmniMem 為 AI Agent 記憶加入人工把關,並以 Daydreaming 從工作階段紀錄學習
Don't let your agents' dreams turn into nightmares. Let them daydream.
OmniMem 正在開發的 7.2 版本加入 Daydreaming,讓 AI Agent 從工作階段紀錄中學習,並由用戶逐項審批所有提案。功能只會在用戶匯入紀錄、工作階段結束 hook 觸發或按下 Daydream now 時執行,沒有排程器。OmniMem 是以 Rust 編寫、透過 MCP 提供服務的開源 AI Agent 記憶伺服器。
Agent memory had a busy year. The newest trick is dreaming: a background job that, between sessions, reads back through an agent's logs and rewrites its memory. It merges duplicates, corrects notes it thinks are wrong, and promotes the important ones into the context the next session starts with. Anthropic described it this month as offline reflection on logs, named after the way the hippocampus replays the day while you sleep (https://anthropic.com/research/components-of-agent-memory).
I build OmniMem (https://github.com/richarvey/OmniMem), an open source memory server for AI agents, written in Rust and served over MCP. Dreaming tackles the problem I care about most: agents that never learn from their own sessions. But the way it's usually built, unattended and in the background, runs straight into something we learned the hard way with production systems. State that changes without a gate eventually changes in a way you didn't want.
This post is the argument for manual gates on agent memory, what OmniMem already gates, and how 7.2 adds learning from session transcripts, which I'm calling daydreaming, without giving up any of them.
The criticism, and the gate that answers it
In August The New Stack collected practitioners' reactions to dreaming (https://thenewstack.io/anthropic-agent-memory-dreaming/). In fairness, Anthropic's own talk sent proposed updates to a human for review. The critics' point was that this isn't enough on its own. Here's what they raised, paraphrased, with what OmniMem does about each.
- Repeated mistakes get promoted to permanent policy, and review becomes a rubber stamp at fleet scale (Jayakumar Ramalingam). In OmniMem nothing becomes a skill or a believed memory without a person accepting it, one item at a time, and proposals carry the memories they came from.- "The right instinct aimed at the wrong evidence", and a store that drifts towards whatever happened lately (Vladimir Beskorovainyi). Daydream's reinforcement gate counts sessions across the whole history, not the latest batch.- Transcripts hold content the agent never wrote, so an automated writer reading them is an attack surface (Viktor Bulanek). The detectors are deterministic pattern matchers, not a model. Transcripts pass the scrub gate first, and every finding waits for a person.- A persisted hallucination becomes infrastructure; provenance matters, and sometimes forgetting is the safe move (Berk Yilmaz). Every memory carries provenance and validity dates, there are tools to end a fact's validity or forget it, and contradiction resolution keeps the losing side for audit.- Dreaming isn't cheap or deterministic like garbage collection; it's repeated paid model runs (Kerstin Frailey). Detection and the skill compiler are deterministic and local. An LLM is optional and only rewords a proposal.The common thread: memory is state that agents act on, so every change to it needs evidence, an owner and a way back. ## What OmniMem already gates (7.0.x, today) None of this is new for 7.2. It's the foundation daydreaming sits on, and it's why I didn't want to bolt on an unattended loop.
- Skills: propose, then a person accepts. compile_skill in propose mode turns accumulated experience into a SKILL.md draft and returns a diff. Write mode is only a request: by default (HUMAN_APPROVAL=human) OmniMem asks the person through MCP elicitation, or parks the proposal in the settings panel's Pending list when the client can't ask. The compiler is deterministic, so the same sources render a byte-identical skill and a diff only ever shows a real change.- Trust: only a person moves it. Every memory has a trust state: candidate, accepted, disputed, superseded or rejected. Facts the enrichment worker extracts start as candidates. Confirming or rejecting goes through the panel or the CLI, and there is deliberately no MCP tool that can do it. Restoring a backup never raises trust either, so a doctored backup can't promote anything.- Contradictions: resolved, never deleted. check_contradictions links memories that disagree. Its resolve mode records the outcome on both sides and goes through the same human approval as skills. The loser is kept with the reason, and the decision can be reopened.- Provenance and licence on every memory. Retrieved (an outside source), concluded (the system's own reasoning) or asserted (you said it), decided at write time and never scored on.- Time. Memories carry valid_from and valid_to, end_validity closes a fact that stopped being true, and recall accepts valid_at and known_at, so you can ask what was true in March and what OmniMem believed at the time.- Audit. The store writes the audit log in the same transaction as the change. Below the full level no row holds memory text, and a forget scrubs earlier rows for that memory too.- The graveyard. record_experience and log_abandoned record approaches that failed and why. A PreToolUse hook (Claude Code, OpenCode, the Mistral Vibe CLI and Kiro) refuses a tool call that repeats a known dead end. On my dead-end benchmark that hook was the difference: agents with the answer already in the store made no memory calls on their own.## Daydream: learning from transcripts, with you in the room The gap all those gates left: OmniMem only learned from what an agent chose to remember, and agents mostly don't choose. The session transcript is the best record of what really happened, and OmniMem never read it. 7.2 changes that, and it's in development now on the v7.2.x branch. When it runs. Only when a person is there: importing a log, a session-end hook firing, or pressing Daydream now. There is no scheduler. Where the logs come from. Five routes feed one pipeline: the desktop app (local discovery and a local scan), the settings panel's new Logs page (browser upload), omnimem logs import on the CLI, session-end hooks, and a new MCP tool, submit_session_log, for clients that keep no transcripts locally. That's the 50th tool. Day one covers every client OmniMem has a guide for:
- Read from disk: Claude Code, Codex CLI, Cursor, GitHub Copilot (VS Code), Kiro, Mistral Vibe CLI, OpenCode- Account export upload: claude.ai, Claude Desktop, Mistral Vibe on the web (formerly Le Chat)- Agent submits its own session: GitLab Duo, Lumo, Open Design*What it looks for.* Seven deterministic detectors: tool_error, retry_loop, user_correction, revert, abandoned, recovery and guard_hit. A failure followed by a recovery becomes a proposed piece of experience: the approach that failed, and the fix that worked. Repeated failure with no recovery becomes a proposed dead end. Repeated corrections on one topic become a candidate preference, in your own words. When it proposes. A signal has to recur in at least two distinct sessions, counted across the whole history, before anything is proposed. A pattern seen in one client only stays scoped to that client, which is also the evidence the model-routing work planned for 7.3 will need. Where it lands. As a candidate, with the client, the model and references back to the sessions and turns it came from. It goes into the Pending list. Nothing daydreamed is ever accepted without a person. The defaults change nothing until you import a log: DAYDREAM=manual, DAYDREAM_MIN_SESSIONS=2, DAYDREAM_LLM=off and TRANSCRIPT_RETENTION=none. ## The scrub gate: no secrets reach an LLM Transcripts are where credentials leak: the .env an agent prints, the token in a curl command, the connection string in a stack trace. A memory store is the worst place for one, because recall will put it straight back into a later session's context, and from there into a model provider's request log. ### Where 7.0 was 7.0's Claude Code session-end hook already redacted its session record with a redact() function: seven regexes, compiled on every call. It caught OpenAI-style sk- keys, GitHub tokens, AWS access key IDs, bearer tokens, password= style assignments, PEM private keys and JWTs. It missed GitLab and Slack tokens, Google keys, Tailscale keys and passwords inside database URLs. And nothing stopped a future code path skipping it. ### What 7.2 does instead A new crate, omnimem-scrub, sits in front of everything, and the core idea is to make skipping it impossible to compile. Text straight from a transcript is a RawText: no Display, no Serialize, and a Debug that prints a placeholder. The only way to get a CleanText is Scrubber::scan(), which fails closed. The store, the embedder, the LLM client and the queue take CleanText only. Forgetting to scan stops being a bug you find in production and becomes a build that won't compile. The rules run in layers:
- Known formats: provider and platform tokens (Anthropic, OpenAI, AWS, GitHub, GitLab, Slack, Stripe, Google, Tailscale, Cloudflare, Hugging Face, npm, PyPI), PEM keys, JWTs, and OmniMem's own bearer and OAuth secrets- Credentials in structure: passwords in URLs, Authorization and Cookie headers, .env blocks, password flags- Keyword plus entropy: a high-entropy value next to secret, token or api_key, the way gitleaks does it, which catches formats nobody listed- Your own secrets by fingerprint: register a token or a config file and OmniMem keeps a salted SHA-256 and a length, never the value- Personal data, opt-in: emails, phone numbers, private IPs, tailnet hostnamesThe built-in pack is written in gitleaks' TOML rule format, so you can drop in an existing gitleaks.toml. A hit becomes a typed placeholder carrying a short keyed hash, so the same secret gets the same placeholder throughout a session and "the key that failed" still makes sense to a detector, but the value is never recoverable. Rules marked as blocking, like private keys, drop the whole turn, and too many in one session quarantine it for review. The crate also builds for WebAssembly, so the settings panel scans a log in your browser before upload, and the server scans it again on arrival. The findings report holds counts and offsets, never values. With the default retention, no transcript text is stored at all. The tests are the part I'll hold the release on. A canary test plants fake secrets of every rule type in every adapter's fixtures, runs a full import and daydream, then byte-searches the database, the WAL, the audit log, captured tracing output, the embedder's inputs and a mocked LLM's request log. One hit fails the build. ## Follow along, or pick something up Dreaming will mature, and plenty of the people building it care about these problems. My position is simple: memory that agents act on should only change when a person says so, with the evidence attached and a way back. Let your agents daydream. Keep the nightmares out. All of 7.2 is public:
- Milestone 7.2.0, 18 issues starting with the scrub gate: https://github.com/richarvey/OmniMem/milestone/6- Milestone 7.2.1, the follow-ups: https://github.com/richarvey/OmniMem/milestone/7- The scrub gate issue, with the type design: https://github.com/richarvey/OmniMem/issues/44- The spec: https://github.com/richarvey/OmniMem/blob/v7.2.x/docs/daydream-spec.mdIf you know one of these clients' log formats better than its docs do, the adapter issues are a good place to start. And if you think a gate is still too thin, I'd rather hear it now than after release. Reply here, open an issue, or find me on Mastodon at https://mastodon.squarecows.com/@ric
來源:DEV Community · dev.to