Skip to content
analysis12 min read

KAIROS and AutoDream: Claude Code Is an AI That Never Sleeps — And Dreams at Night

Claude Code contains KAIROS — a daemon mode that runs 24/7 with heartbeat ticks and proactive actions. At night, AutoDream consolidates memory like REM sleep. Both found in the leaked source code.

Author
Anthony M.
12 min readVerified April 1, 2026Tested hands-on
KAIROS and AutoDream — The AI That Never Sleeps and Dreams at Night
KAIROS and AutoDream — Claude Code's autonomous daemon and memory consolidation systems revealed in the source leak

What if your AI coding assistant never actually stopped working? KAIROS is an unreleased daemon mode hidden inside Claude Code — an always-on agent with heartbeat tick signals, a 15-second proactive action budget, exclusive tools like PushNotification and SubscribePR, and companion system AutoDream that consolidates memory overnight like REM sleep. Both discovered in the v2.1.88 source leak, both stripped from public builds via dead-code elimination.

What Are KAIROS and AutoDream?

On March 31, 2026, the source maps for Claude Code v2.1.88 were accidentally exposed via npm, revealing approximately 512,000 lines of TypeScript and 1,900+ files that Anthropic never intended to make public. Among the most significant discoveries were two unreleased systems: KAIROS — an autonomous daemon mode that keeps Claude Code running 24/7 without user input — and AutoDream — a periodic memory consolidation mechanism deliberately modeled after human REM sleep.

Together, these systems represent something far more ambitious than the coding assistant most users interact with today. They reveal Anthropic's internal roadmap toward a persistent, proactive, self-organizing AI agent — one that watches your codebase while you sleep and literally dreams about what it learned during the day.

We analyzed the full leaked source code — the TypeScript archives, the Rust port in rust/crates/, the reference data snapshots, and cross-referenced with community analyses from VentureBeat, Alex Kim, and the ccleaks.com repository. This article presents everything we found.

Key Numbers at a Glance

MetricKAIROSAutoDream
Feature flag references150+ mentions~30 mentions
Server-side flagtengu_kairostengu_onyx_plover
Present in public buildsNo (dead-code eliminated)No (default: disabled)
Blocking budget15 seconds max~8-10 min per run
Trigger mechanismHeartbeat <tick> signalsTriple gate (24h + 5 sessions + lock)
Exclusive toolsSleepTool, SendUserFile, PushNotification, SubscribePRBash (read-only), memory file writes only
Source locationrust/crates/tools/src/lib.rs, bootstrap.rsskills/bundled/remember.ts

Claude Code's internal codename is tengu — analytics events follow the pattern tengu_startup_telemetry, tengu_mcp_channel_flags, tengu_agent_flag. Both KAIROS and AutoDream are gated behind compile-time feature flags that are completely stripped from external builds by Bun's dead-code elimination.

KAIROS: The Daemon That Never Stops

KAIROS — named after the ancient Greek concept of "the opportune moment" — is the most referenced feature flag in the entire Claude Code codebase, with over 150 mentions across the leaked source. It is a fundamental architectural shift: instead of Claude Code being a tool you invoke and dismiss, KAIROS makes it a persistent background process that monitors, decides, and acts on its own.

How the Heartbeat Tick System Works

At the core of KAIROS is a tick heartbeat mechanism. The agent receives periodic <tick> messages — each one a signal that says "you are awake — what do you do now?" along with the current local time context. On every tick, KAIROS makes a binary decision: act proactively or sleep.

The critical design rule: if KAIROS has nothing useful to do on a tick, it must call the SleepTool rather than emitting status text. This anti-narration principle prevents the daemon from flooding the terminal with unnecessary updates — a lesson clearly learned from the verbose behavior of early autonomous agent experiments.

KAIROS daemon architecture — tick heartbeat, 15-second budget, exclusive tools
KAIROS architecture: heartbeat ticks drive autonomous decisions under a strict 15-second blocking budget

The 15-Second Blocking Budget

Every proactive action KAIROS takes operates under a strict 15-second blocking budget. If an action would block the user's workflow for more than 15 seconds, it gets deferred. This constraint is fundamental to the system's design philosophy: KAIROS should be useful without being intrusive. It is an assistant, not a hijacker.

This budget creates a natural hierarchy of what KAIROS can do proactively versus what it must wait for explicit permission to execute. Quick operations like file scanning, notification sending, or PR monitoring fit comfortably within 15 seconds. Complex operations like large refactors or multi-file edits would be queued for when the user is ready.

Exclusive KAIROS Tools

The leaked code reveals four tools that are exclusive to KAIROS mode and completely unavailable in standard Claude Code:

ToolFunctionWhy It Matters
SleepToolWait a specified duration without holding a shellAllows KAIROS to pause without consuming resources
SendUserFilePush files/notifications directly to the userProactive delivery of results without user polling
PushNotificationSend push notifications to the user's deviceAlert the user about important events (PR reviews, build failures)
SubscribePRSubscribe to pull request activity in real timeMonitor code reviews, comments, and pushes autonomously

The SubscribePR tool is particularly significant. Combined with the KAIROS_GITHUB_WEBHOOKS feature flag, it reveals an architecture where KAIROS can subscribe to a pull request, receive real-time webhook events, analyze changes autonomously, and send push notifications — all without the user having to check GitHub manually.

Terminal Focus Awareness

One of the more sophisticated aspects of KAIROS is its awareness of terminal focus state. The proactive prompt includes a terminalFocus parameter that calibrates how autonomous the agent should be:

  • Terminal unfocused (user away): Maximize independent decision-making. Only pause for irreversible actions like force-pushes or destructive operations.
  • Terminal focused (user present): Increase collaboration. Show choices, ask before major commits, present options rather than acting unilaterally.

This is not a binary switch — it creates a spectrum of autonomy that dynamically adjusts to the user's presence. When you step away from your desk, KAIROS becomes more autonomous. When you come back, it defers to your judgment. The system essentially reads the room.

Daemon Management Commands

KAIROS supports container-like management commands, confirming that Anthropic designed it as a proper background service:

  • daemon ps — list active sessions
  • daemon logs — view session logs
  • daemon attach — attach to a running session
  • daemon kill — terminate a session

The bootstrap system in rust/crates/runtime/src/bootstrap.rs defines 12 ordered phases, three of which are daemon-specific: DaemonFastPath (detects args[0] === 'daemon'), DaemonWorkerFastPath (detects --daemon-worker flag), and BackgroundSessionFastPath (detects ps or --bg arguments).

AutoDream: When AI Sleeps, It Dreams

If KAIROS is Claude Code's waking state — always alert, always monitoring — then AutoDream is its sleep cycle. The system prompt extracted from the leak says it directly:

"You are performing a dream — a reflective pass over your memory files. Synthesize what you've learned recently into durable, well-organized memories so that future sessions can orient quickly."

The analogy to human REM sleep is deliberate and architecturally accurate. During REM sleep, the brain replays the day's events, strengthens important connections, discards what doesn't matter, and organizes everything into long-term memory. AutoDream does exactly the same thing for Claude Code's memory files.

AutoDream 4-phase consolidation cycle — Orient, Gather, Consolidate, Prune
AutoDream's four-phase consolidation cycle mirrors human REM sleep memory processing

The Triple Gate Activation System

AutoDream does not run arbitrarily. It requires three simultaneous conditions — a triple gate — before activation:

GateConditionDefault Value
Time gateHours since last dreamminHours: 24
Session gateSessions accumulated since last consolidationminSessions: 5
Lock gateExclusive lock file acquisitionPID lock file

All three gates must be satisfied simultaneously. The lock file prevents concurrent runs — if two Claude Code instances are open on the same project, only one can execute AutoDream. This prevents merge conflicts in memory files. The server-side feature flag is tengu_onyx_plover with enabled: false by default, indicating a gradual rollout strategy.

The 4 Phases of Consolidation

When AutoDream activates, it follows a structured cycle of four phases:

Phase 1 — Orient

AutoDream runs ls on the memory directory to inventory what exists. It reads MEMORY.md (the index file) to understand the current state, then skims existing topic files to improve them rather than creating duplicates. If logs/ or sessions/ subdirectories exist, it reviews recent entries.

Phase 2 — Gather Signal

The system collects new information from three sources in priority order: (1) daily logs from the append-only logs/YYYY/MM/YYYY-MM-DD.md files, (2) existing memories that have drifted — facts contradicted by the current codebase, and (3) targeted transcript searches via grep on JSONL session files. A critical rule: it must never exhaustively read transcripts — only search for things it already suspects matter.

Phase 3 — Consolidate

For each piece of information worth retaining, AutoDream writes or updates a memory file. The emphasis is on merging new signals into existing topic files rather than creating near-duplicates, converting relative dates ("yesterday", "last week") to absolute dates so they remain interpretable after time passes, and deleting contradicted facts at the source.

Phase 4 — Prune and Index

The final phase updates MEMORY.md to stay under 200 lines and ~25KB. The index is not a dump — each entry must be a single line under ~150 characters pointing to a topic file. Verbose entries get demoted, stale pointers get removed, contradictions get resolved, and new important memories get added.

Operational Constraints

AutoDream operates under strict safety constraints:

  • The dream sub-agent receives bash read-only access — it can inspect but never modify code
  • Write access is limited exclusively to memory files
  • Source code, configuration, and tests remain untouched
  • Observed performance: approximately 8-10 minutes to consolidate 913 sessions

The /dream slash command serves as a manual trigger that invokes the same process without waiting for the automatic thresholds. It lives in skills/bundled/remember.ts within the skills subsystem (20 modules total).

The Four-Layer Memory Architecture

KAIROS and AutoDream are parts of a larger four-layer memory system that the leak reveals:

LayerWriterPurposePersistence
CLAUDE.mdUser (manual)Instructions, rules, architecture guidelinesManual control
Auto MemoryClaude (per session)Project patterns, debug insights, preferencesAutomatic capture
Session MemoryClaude (automatic)Conversation continuity~5K token window
AutoDreamClaude (periodic)Consolidation and cleanupBetween sessions

The memdir/ subsystem manages this architecture with 8 dedicated modules: memdir.ts (orchestration), findRelevantMemories.ts (relevance scoring), memoryScan.ts (directory inventory), memoryAge.ts (staleness detection), memoryTypes.ts (TypeScript interfaces), paths.ts (directory resolution), plus teamMemPaths.ts and teamMemPrompts.ts for collaborative team memory.

Only the first 200 lines of MEMORY.md (or the first 25KB, whichever comes first) are loaded at conversation startup. This hard constraint motivates AutoDream's entire design: keep the index lean so startup is fast and the context window is not wasted on stale information.

Session Memory and Compaction

The SessionMemory service (3 files within the 130-module services subsystem) handles conversation continuity with a ~5K token window. When context grows too large, the compaction system in rust/crates/runtime/src/compact.rs activates:

  • Preserves the 4 most recent messages verbatim
  • Summarizes older messages into a system message covering scope, tools used, recent requests, work in progress, key files, and timeline
  • Maximum estimated tokens for the summary: 10,000

Session transcripts are stored as JSONL files — one JSON object per line — making them efficiently searchable by grep without parsing the entire file. This format is specifically designed for AutoDream's Phase 2 transcript search.

The Cron System and Scheduled Agents

KAIROS does not operate in isolation. The leak reveals an entire scheduling infrastructure built around it:

The ScheduleCronTool subsystem contains five modules: CronCreateTool.ts, CronDeleteTool.ts, CronListTool.ts, a React UI.tsx component, and a prompt.ts file. These are gated behind the AGENT_TRIGGERS feature flag. The RemoteTriggerTool adds remote agent invocation capabilities.

The scheduling operates at three levels:

  1. In-session (/loop) — local, ephemeral, dies with the session
  2. Desktop scheduled tasks — local, persistent across restarts
  3. Cloud scheduled tasks — runs on Anthropic's infrastructure, survives machine shutdown

A 5-minute cron refresh is referenced as the base periodic mechanism, calibrated to the prompt cache expiration window. This means KAIROS can maintain a warm cache for efficient operation while still checking for new events regularly.

The BriefTool and Proactive Communication

When KAIROS needs to communicate with the user, it uses the BriefTool — a specialized output mechanism found in tools/BriefTool/ with 5 files (BriefTool.ts, UI.tsx, attachments.ts, prompt.ts, upload.ts). The Rust definition in tools/src/lib.rs reveals its schema:

  • message (required string) — the actual content
  • attachments (optional array of file paths) — files to include
  • status (required: "normal" or "proactive") — whether the user asked for it or KAIROS initiated it

The proactive status is key — it marks messages that KAIROS sends without any user request. The tool resolves attachment paths via canonicalize, checks file sizes, and detects image formats (png, jpg, jpeg, gif, webp, bmp, svg). In KAIROS mode, Brief is the default output style: extremely concise, designed for a persistent assistant that must not flood the terminal.

44 Feature Flags: What Else Is Hidden?

The full leak reveals 44 feature flags for unreleased capabilities. Beyond KAIROS and AutoDream, the most notable compile-time flags include:

FlagWhat It Reveals
PROACTIVEProactive mode — KAIROS's behavioral layer
KAIROS_GITHUB_WEBHOOKSReal-time GitHub event processing
AGENT_TRIGGERSCron scheduling and remote triggers
BG_SESSIONSBackground sessions as system services
BUDDYA companion Tamagotchi feature
COORDINATOR_MODEMulti-agent orchestration
CONTEXT_COLLAPSEContext inspection and management

The configurable runtime flags add more depth: autoMemoryEnabled, autoDreamEnabled, autoCompactEnabled, fileCheckpointingEnabled, todoFeatureEnabled, alwaysThinkingEnabled, terminalProgressBarEnabled, and showTurnDuration. Six or more killswitches were also identified, along with hourly settings polling and remote telemetry.

Source Files: Where We Found Everything

For researchers and developers who want to verify our findings, here are the key source locations within the leaked codebase:

FileWhat It Contains
rust/crates/tools/src/lib.rsTool definitions, BriefStatus enum, ConfigSettings (3,000+ lines)
rust/crates/runtime/src/bootstrap.rs12 BootstrapPhases including DaemonFastPath
rust/crates/runtime/src/compact.rsCompaction system (200+ lines)
rust/crates/runtime/src/prompt.rsSystemPromptBuilder, CLAUDE.md discovery (783 lines)
rust/crates/runtime/src/config.rsRuntimeConfig, MCP configs, sandbox, OAuth (997 lines)
skills/bundled/remember.ts/dream skill — manual AutoDream trigger
memdir/*.ts (8 files)Memory management subsystem
services/SessionMemory/ (3 files)Session continuity and transcript management

What This Means for the AI Industry

The KAIROS and AutoDream discoveries are significant beyond just Claude Code. They reveal where the entire AI coding assistant industry is heading:

From reactive to proactive. Today's coding assistants wait for you to type a prompt. KAIROS shows that the next generation will monitor your codebase, watch your PRs, and act when they detect something worth acting on — all while respecting a strict blocking budget so they never get in your way.

From stateless to memory-rich. Current tools forget everything between sessions. AutoDream's four-layer memory architecture — with automatic capture, periodic consolidation, and a 200-line index constraint — shows how AI agents will maintain persistent, organized knowledge about your project across months of development.

From tools to teammates. The combination of daemon mode, proactive communication, GitHub webhook integration, scheduled tasks, and team memory sharing (via teamMemPaths.ts and teamMemPrompts.ts) paints a picture of AI agents that function as actual team members — with their own notification preferences, work schedules, and institutional knowledge.

The BUDDY feature flag — described as a "companion Tamagotchi" — suggests Anthropic is even experimenting with emotional attachment mechanics. Whether this ships or not, it signals that the company is thinking about long-term user-agent relationships, not just transaction-by-transaction interactions.

FAQ

Is KAIROS available in the current version of Claude Code?

No. KAIROS is completely stripped from public builds via Bun's dead-code elimination. It was discovered only because the source maps (.map files) for Claude Code v2.1.88 were accidentally exposed through npm on March 31, 2026. The feature is gated behind the feature('KAIROS') compile-time flag and the tengu_kairos server-side flag.

Can I enable AutoDream manually today?

The autoDreamEnabled setting exists in the configuration system (settable in ~/.claude/settings.json), but the server-side flag tengu_onyx_plover defaults to false. The /dream slash command exists as a manual trigger in skills/bundled/remember.ts. Whether it functions in current builds depends on Anthropic's server-side rollout status.

How does KAIROS avoid being intrusive?

Three mechanisms: (1) a strict 15-second blocking budget that defers any action exceeding that duration, (2) terminal focus awareness that adjusts autonomy based on whether the user is present, and (3) the anti-narration principle requiring KAIROS to call SleepTool rather than emit unnecessary status messages when it has nothing useful to do.

What data does AutoDream access during consolidation?

AutoDream's sub-agent receives bash read-only access — it can inspect the codebase but cannot modify any source code, configuration, or tests. Write access is limited exclusively to memory files in the ~/.claude/projects/<project>/memory/ directory. It reads daily logs, existing memory files, and performs targeted grep searches on JSONL session transcripts.

How many unreleased features were found in the Claude Code leak?

The leak revealed 44 feature flags for unreleased capabilities across 512,000 lines of TypeScript and 1,900+ files. Beyond KAIROS and AutoDream, these include COORDINATOR_MODE (multi-agent orchestration), BG_SESSIONS (background sessions), AGENT_TRIGGERS (cron scheduling), BUDDY (Tamagotchi companion), 6+ killswitches, and hourly remote settings polling.

Related Articles

Was this review helpful?
Anthony M. — Founder & Lead Reviewer
Anthony M.Verified Builder

We're developers and SaaS builders who use these tools daily in production. Every review comes from hands-on experience building real products — DealPropFirm, ThePlanetIndicator, PropFirmsCodes, and many more. We don't just review tools — we build and ship with them every day.

Written and tested by developers who build with these tools daily.