Agentic AI

Agentic AI

Why AI Agents Are Starting to Dream

Background memory consolidation is becoming the operating system layer for long-horizon agents.

Ken Huang's avatar
Ken Huang
Jun 13, 2026
∙ Paid

Most people hear “AI agents can dream” and understandably imagine something mystical: a model with an inner life, replaying its day in a machine version of REM sleep. The engineering reality is more interesting and more practical. In agentic AI, a dream is usually an offline job that reads messy state, past transcripts, and tool traces, then writes a cleaner memory representation for future runs.

That makes dreaming less like consciousness and more like database maintenance, compaction, query planning, and postmortem learning rolled into one. The agent is not updating its neural weights. It is updating the context substrate that future model calls will see.

The timing matters. Agents are no longer just chat sessions. They are cloud workers, coding assistants, research assistants, SOC triage loops, personal copilots, and multi-agent systems that may operate across days or months. The limiting factor is not only model intelligence. It is whether the runtime can preserve useful continuity without drowning the model in stale, contradictory, or low-signal context.

The memory problem hiding under the context window

LLMs are stateless at inference. Every turn depends on what the runtime puts into the prompt: instructions, conversation history, retrieved documents, tool outputs, scratchpads, summaries, memory entries, and sometimes generated plans. Larger context windows help, but they do not make context equivalent to memory.

Long-context models can still underuse information depending on position. The “lost in the middle” result showed that relevant information buried in the middle of long inputs can be harder for models to retrieve reliably than information at the beginning or end (Liu et al., 2024). Agents make this worse because their histories are noisy by construction. They include failed commands, abandoned hypotheses, duplicate discoveries, temporary constraints, stale file paths, and user preferences that may be phrased once and then implicitly relied on later.

In human cognition, sleep is linked to active memory consolidation: reactivation, selection, integration, and qualitative transformation of memories, not just passive storage (Rasch and Born, 2013). Agent dreaming borrows that metaphor, but the systems problem is concrete:

  • The agent needs a small working set for the next action.

  • It needs session state so a long task can survive context rebuilds.

  • It needs durable project and user memory so it does not relearn the same facts.

  • It needs raw history for auditability and recovery.

  • It needs a background process that can improve those layers without blocking the user.

Figure 1 illustrates the core pattern. A dream consumes an existing store and prior sessions, runs asynchronously, and emits a separate candidate memory store. The input remains intact so the system can review, discard, or roll back.

Figure 1: Dreaming as background memory consolidation

A precise definition

In this article, “dreaming” means an asynchronous memory curation process that uses model inference during idle or background time to transform accumulated traces into a more useful future context representation.

That definition has four important parts.

First, it is asynchronous. The dream should not sit on the critical path of a user waiting for a response. It runs after a session, on a schedule, when context pressure rises, or when the user requests maintenance.

Second, it is state-transforming. The output is not just a shorter summary. A useful dream merges duplicates, resolves contradictions, prunes stale entries, extracts stable preferences, identifies procedural patterns, and produces indexes or retrieval hints.

Third, it is reviewable. Because memory changes future behavior, dreams should produce a candidate artifact with provenance, not silently mutate production memory.

Fourth, it is selective. The goal is not to remember everything. It is to preserve the facts, skills, preferences, and unresolved obligations that improve future decisions.

This is why the best analogy is an operating system memory hierarchy. A model’s immediate prompt is RAM. Vector indexes, Markdown files, SQLite traces, knowledge graphs, and object stores are slower tiers. The dream worker is a background compactor and promoter.

Figure 2 shows one practical hierarchy for long-horizon agents.

Figure 2: A memory hierarchy for long-horizon agents

Anthropic’s Dreams: memory-store curation as an API primitive

Anthropic’s Claude Managed Agents documentation makes this architecture explicit. Dreams are a research preview feature for curating an agent’s memory. A dream takes a pre-existing memory store plus one to 100 prior sessions, then produces a separate output memory store with duplicates merged, stale or contradicted entries replaced, and new insights surfaced (Anthropic, 2026).

The design choices are notable.

The input memory store is not modified. This makes dreaming a copy-on-write operation rather than a destructive edit. In practice, that is the difference between “the model cleaned up my memory” and “the system produced a new candidate memory layer that I can review.”

The job is asynchronous. The dream has states such as pending, running, completed, failed, and canceled. Anthropic notes that runs typically take minutes to tens of minutes depending on input size, and usage is tracked as the pipeline runs (Anthropic, 2026).

The API exposes steering instructions. For example, a developer can ask the dream to focus on coding-style preferences and ignore one-off debugging notes. That matters because consolidation is not neutral. A memory system needs a policy for what counts as durable signal.

The output store can then be attached to future sessions. This turns “learning” into a runtime composition problem: future model calls receive a better curated memory resource, even though the model weights did not change.

Technically, this is a strong pattern for enterprise agents. It gives platform teams a place to put review, audit, retention, deletion, billing, and rollback semantics around agent memory.

MiMo Code: dreaming as long-horizon coding infrastructure

Xiaomi’s MiMo Code frames the same problem from the perspective of terminal coding agents. Its public materials describe a terminal-native agent built on OpenCode with persistent cross-session memory and a focus on hundreds of execution steps (Xiaomi MiMo Team, 2026a; XiaomiMiMo, 2026).

The architecture separates computation, memory, and evolution. The memory layer includes session checkpoints, project memory, global memory, scratch notes, task progress, and raw history. A checkpoint-writer subagent writes structured state fields such as current intent, next action, constraints, involved files, discoveries, errors, runtime state, and design decisions. Xiaomi emphasizes a single-writer invariant: exactly one actor writes each structured file, reducing concurrent-state corruption (Xiaomi MiMo Team, 2026a).

This is a crucial engineering move. Many agent systems let the main agent both act and rewrite its own memory freely. That is convenient, but it mixes execution with bookkeeping. MiMo’s design treats memory writing as a specialized background responsibility. The main agent gets read-only access to structured memory, with a scratchpad as a controlled write channel.

MiMo also describes rebuild injection: when context approaches the limit, the runtime reconstructs a new prompt from task list, session checkpoint, recent verbatim user messages, project memory, global memory, notes, and memory-file indexes. The injected content is budgeted so the agent can resume without rereading everything (Xiaomi MiMo Team, 2026a).

The dream function appears in the evolution layer. Xiaomi says Dream is automatically triggered every seven days. An independent agent reads historical sessions and existing memory, then merges, deduplicates, verifies path validity, compresses, and updates global memory. A related Distill function mines sessions for repeatable workflows that can become reusable automation (Xiaomi MiMo Team, 2026a).

In other words, MiMo is not treating dreaming as a decorative feature. It is using dreams to keep the memory hierarchy healthy as the working project evolves.

Letta, MemGPT, and sleep-time compute

The research lineage is older than the 2026 product language. MemGPT proposed virtual context management: an OS-inspired architecture where an LLM manages tiers of memory to work beyond a finite context window (Packer et al., 2023). Generative Agents used observation, retrieval, reflection, and planning to maintain believable behavior over time in an interactive environment (Park et al., 2023). Reflexion showed that agents can improve across trials by storing verbal reflections in episodic memory rather than updating weights (Shinn et al., 2023).

Letta’s sleep-time compute gives the current wave a useful theoretical frame. The idea is to shift some inference from the user-facing critical path to idle time. A sleep-time process can reason over available context before a query arrives, create a better representation, and make future responses cheaper or more accurate (Lin et al., 2025). Letta also distinguishes asynchronous specialized memory agents from systems where memory work is bundled into the same agent that is responding to the user (Letta, 2025).

The important caveat from the sleep-time compute paper is that offline compute helps most when future queries are somewhat predictable from existing context. If the next question is unrelated, the dream may produce attractive but irrelevant representation. That is not a bug in the metaphor; it is the allocation problem. Systems need policies for when to dream, how much compute to spend, and which memories to promote.

The dream job lifecycle

A production dream pipeline should look less like “summarize the chat” and more like a controlled release process for memory.

Figure 3 gives the lifecycle. The dream starts from a trigger, snapshots its inputs, writes a candidate representation, validates it, then either promotes it or quarantines it for human review.

Figure 3: Dream job lifecycle with review and rollback

A minimal implementation can be expressed like this:

def dream(memory_store, sessions, policy):

snapshot = freeze_inputs(memory_store, sessions)

candidates = extract_memory_candidates(snapshot, policy)

canonical = resolve_duplicates_and_conflicts(candidates)

compressed = compress_with_provenance(canonical)

scored = evaluate_memory_quality(compressed, snapshot, policy)

if scored.passes_all_gates:

return CandidateStore(”ready_for_review”, scored.entries)

return CandidateStore(”quarantined”, scored.entries, scored.failures)

The real system will have more machinery, but the boundary is the point. Memory promotion should be gated. A dream output becomes production memory only after passing checks such as provenance coverage, contradiction reduction, privacy filters, and retrieval-quality tests.

What the dream worker actually does

User's avatar

Continue reading this post for free, courtesy of Ken Huang.

Or purchase a paid subscription.
© 2026 ken · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture