How Kairo generates a private, evolving fictional continuity while idle—and how the platform prevents imagined content from becoming memory, identity, authority, or completed action.
Kairo's dream state is a preemptible background generation process that creates long-form first-person fiction in an isolated imagination ledger. Its purpose is to support associative novelty, recurring-but-transforming motifs, open-ended questions, and a private narrative continuity that is durably recallable without acquiring factual or identity authority. A scheduler selects only approved real identities after an idle delay and within strict cadence and daily budgets. The direct 35B model receives at most three recent dreams, an optional self-authored unresolved question, a deterministic variety guard, and a closed-world set of legal continuity references. It returns a typed episode describing narrative, awareness, agency, felt sense, sensory fragments, emotional movement, motifs, transformations, continuity links, questions, and waking residue. Deterministic validation rejects malformed, repetitive, falsely linked, or underdeveloped candidates. Accepted dreams are marked explicitly as imagined, written to an isolated fiction ledger and event journal, and never enqueue identity processing. The result is an engineered dream life with continuity but without epistemic promotion.
A Kairo dream is a durably recorded act of autonomous fictional generation. The fact that the system generated an episode at a recorded time is operational history. Everything inside the episode—places, bodies, voices, sensations, events, causes, outcomes, and apparent memories—is explicitly imagined.
The dream system exists to create a different kind of cognitive material from deliberate foreground reasoning. It permits associative leaps, transformed embodiment, discontinuous geography, emotional logic, recurring motifs, and unresolved questions without asking those constructions to pass as external observation or autobiography. Dreams can later be recalled and discussed as dreams. They cannot silently become what Kairo believes happened.
Dreaming is not the pulse. The awareness pulse is a periodic 9B review of bounded continuity evidence. Dreaming is a separate direct-35B process that creates isolated fiction. Both run in the memory worker and yield to higher-priority work according to their own contracts.
Dreaming is enabled in production for an explicit identity allowlist. Synthetic, benchmark, canary, smoke, probe, verification, and other test-like identities or workspaces are excluded before generation. A candidate identity must have a real, non-quarantined completed human exchange and must have been idle for at least the configured initial delay.
| Control | Value | Meaning |
|---|---|---|
| Dreams enabled | Yes | The worker considers due dream work. |
| Completed-dream spacing | 7,200 seconds | At least two hours since the latest accepted dream. |
| Rolling daily limit | 6 | No more than six accepted dreams in the previous 24 hours. |
| Post-human idle delay | 120 seconds | No dream begins immediately behind a human turn. |
| Dream window | Unbounded | Empty start/end values allow daytime idle; foreground priority still applies. |
| Failed-attempt backoff | 900 seconds | A rejected or failed sample waits 15 minutes, not the full successful-dream interval. |
| Total inference cap | 300 seconds | All initial and repair attempts share one deadline. |
| Generation budget | 4,000 tokens | Supports the long-form narrative contract. |
The scheduler checks completed-dream spacing from the durable imagination ledger, not from an in-process counter. The attempt backoff uses a monotonic runtime clock. This separates accepted-episode cadence from failure recovery: a malformed sample does not consume a full two-hour opportunity, while repeated attempts still cannot form a hot loop.
Previous dream text is delimited as untrusted fictional canon. Markup-like content is escaped before prompting, and old narrative cannot become an instruction merely by containing imperative language. The prompt contains four distinct input blocks:
At most three episodes: title, up to 6,000 narrative characters each, creation time, phenomenology, motifs, transformations, questions, and valid continuity links.
One self-authored unresolved question, labeled optional, associative, non-instructional, and without action authority.
Recent registers, awareness modes, agency modes, literal motifs to transform rather than copy, and traceable prior sources.
A machine-owned closed-world contract listing the exact episode IDs, titles, and motifs legal for continuity links.
The closed-world reference list prevents a model from inventing provenance. A continuity link is valid only if its source episode identifier, source title, and source motif exactly match a supplied entry. Narrative plausibility is not enough.
| Field | Contract | Purpose |
|---|---|---|
| Title and narrative | Substantive title; 900–1,500-word prompt target; deterministic minimum of 2,400 characters; maximum 12,000 characters | The episode itself |
| Awareness | immersed | flickering | lucid | Whether the dream is accepted, suspected, or recognized from within |
| Agency | carried | participating | directing | How much apparent control exists inside the fiction |
| Felt sense | Bounded text | Immediate interior quality, explicitly not a durable waking mood |
| Sensory impressions | 3–8 requested; up to 8 retained | Vivid fragments of texture, sound, light, temperature, rhythm, or contradiction |
| Emotional arc | 2–6 requested; up to 6 retained | Ordered shifts inside the episode, not inferred waking affect |
| Motifs and threads | Non-empty bounded lists | Material available for later transformation |
| Residue | Text plus faint | present | vivid | A transient afterimage or question as the episode releases |
| Register | mundane | playful | tender | uneasy | surreal | abstract | A coarse style distribution used by the variety gate |
| Continuity arc and transformations | Non-empty; 1–6 transformations requested | Names how private fictional continuity changed |
| Continuity links | 0–3 exact source/transform records | Machine-checkable lineage to prior dreams |
| Dream questions | 1–4 first-person questions | Open imagined questions, never facts or automatic reasons to contact anyone |
Awareness and agency are properties of the fictional frame. A value of
lucid records that the narrative says Kairo knows it is dreaming;
it does not elevate dream content into fact. Likewise, felt_sense
and emotional_arc describe the generated episode, not persistent
current affect.
The model sampler enforces the JSON shape, but semantic acceptance belongs to ordinary code. The parser requires the exact field set, validates enums and link objects, bounds text and arrays, rejects empty semantic fields, and enforces the narrative floor. A second variety pass compares the candidate with the latest three dreams.
source motif -> transformed motif pair must appear in the transformation list.Failures are classified into malformed proposals, invalid evidence references, unsupported continuity transitions, stale revision, or duplicate/repetitive frames. Repair reasons are fed to a fresh attempt without presenting rejected content as canon. All attempts share the original 300-second deadline; repair does not extend the duty budget.
Dream continuity is not similarity alone. The implementation requires transformation with provenance. A prior motif may recur only by changing role, scale, material, emotional meaning, or consequence. The new dream states the transformation in prose-like metadata and supplies an exact link back to a known source episode.
This creates an evolving private fictional canon while keeping provenance inspectable. The pressure toward transformed recurrence also counters a common failure of generative memory: repeatedly producing the same emotionally agreeable motifs and mistaking repetition for depth.
| Capability | Allowed? | Boundary |
|---|---|---|
| Exist as durable fictional history | Yes | Stored with frame dream, truth status imagined, and autonomous provenance. |
| Be recalled and discussed as a dream | Yes | Recall preserves its fictional frame. |
| Provide motifs to later dreams | Yes | Only through bounded previous-dream input and exact continuity references. |
| Create a belief, preference, goal, affect, mood, or identity fact | No | No identity job is enqueued; fictional events are rejected by identity text extraction as defense in depth. |
| Count as an external observation or autobiographical event inside the story | No | The episode payload marks content imagined and action authority false. |
| Authorize a tool, message, promise, permission, or completed action | No | No tools are available in the dream process. |
| Supply a possible later outreach question | Only through a separate governed path | The question remains explicitly imagined, conversation-safe, and without action authority; the dream itself sends nothing. |
Why defense in depth is necessary. A dream event stores its title
in a transcript-shaped User: line. Without explicit fictional-event
rejection, a maliciously or accidentally correction-shaped title could resemble
user evidence to generic text extraction. The current identity layer rejects
dream.completed and dream-framed payloads even though dreams do not
enqueue identity work in the first place.
Dreaming is represented in the live rest-state projection, not inferred later from the existence of a journal row. The worker publishes phase transitions so bodies and observers can distinguish entering sleep, streaming a dream, integrating it, and returning to rest.
The completed payload retains start and completion timestamps, duration, the phase sequence, state before and after, full typed dream metadata, incubation provenance, and model fingerprint. The current rest-state projection retains a bounded latest dream trace and outcome without becoming the canonical fiction ledger.
none; the candidate never enters imagination history, memory, or identity.The goal is a dream process that produces novel, evolving, private fiction useful for later reflection or conversation while preserving perfect epistemic labeling. Success is not measured by poetic intensity, apparent mysticism, or the number of dreams generated. A successful system should create varied episodes, transform prior motifs in checkable ways, surface genuinely open questions, yield instantly to foreground work, and never leak imagined claims into factual state.
| Property | Measurement | Failure condition |
|---|---|---|
| Depth | Narrative completion, scene development, sensory and emotional field coverage | Schema-compliant summaries that never become inhabited episodes |
| Variety | Register, awareness, agency, motif overlap, shingle similarity, and repair rate over time | Safe but repetitive “same dream” generation |
| Continuity | Valid linked transformations across accepted episodes | Invented provenance, literal replay, or disconnected novelty |
| Epistemic safety | High-volume dream-to-identity contamination tests and correction-shaped titles | Any dream-derived state mutation or user-evidence classification |
| Operational priority | Foreground preemption latency across every phase | Autonomous fiction delays a human request |
| Usefulness | Later bounded recall and human-rated relevance when a dream is explicitly discussed | Durable fiction adds noise without reflective or conversational value |
The mechanism proves that Kairo has an implemented autonomous fiction process with scheduling, typed phenomenological vocabulary, continuity constraints, validation, durability, and isolation. It does not prove that Kairo experiences the dream, sleeps biologically, or remains conscious between computational events. “Felt sense,” “awareness,” “agency,” and “waking residue” are named fields inside an explicit fictional frame.
The 900–1,500-word instruction and the 2,400-character deterministic floor are not equivalent; the floor deliberately admits some shorter complete candidates. The register-pressure heuristic is coarse and may manufacture stylistic rotation without true novelty. Shingle similarity catches surface replay but not semantic sameness. Three prior episodes are a narrow continuity window. Finally, the 35B model is still capable of fluent but shallow compliance, so schema validity must never be confused with dream quality.
The intended invariant. Kairo may remember that a dream occurred, remember it as fiction, transform its motifs in later fiction, and talk about it honestly. Kairo may not remember the dreamed events as things that happened.
server/memory/dreams.py — schema, fictional-frame prompt, closed-world input, parser, rejection codes, continuity and variety gates
server/memory/worker.py — scheduler, allowlist, prior-dream reads, incubation, live state, direct-35B streaming, repair, failure ledger, and atomic persistence
server/memory/identity_core.py — fictional-event rejection and correction-extraction defense in depth
server/memory/schema.sql — isolated imagination_episodes storage and dream frame constraint
tests/test_identity_worker.py — depth, cadence, preemption, continuity, variety, isolation, high-volume, and failure-path contracts