MODULO 7.4

⌛ Kairos Always-On

6
Topicos
~60
Minutos
Deep
Nivel
Source
Tipo
1

🔄 What Is KAIROS?

Claude Code transforms from request-response CLI into an autonomous always-on daemon. Boots once, holds persistent sessions across restarts, schedules check-ins, sends unsolicited messages, consolidates memory autonomously.

FlagUnlocksScope
KAIROSFull assistant mode, session continuity, daily-log memoryant-only
KAIROS_BRIEFBriefTool (SendUserMessage) independentlyexternal
KAIROS_PUSH_NOTIFICATIONPushNotificationTool independentlyexternal
AGENT_TRIGGERSCron scheduling systemgb-gated
PROACTIVELighter proactive mode, SleepToolant-only
2

🎯 The kairosActive Pivot

Single boolean in bootstrap/state.ts. Effects cascade: Memory switches to daily-log mode, BriefTool opt-in bypassed, Fast mode SDK restriction lifted, AutoDream gated off, Bridge registers as claude_code_assistant, Scheduler auto-enables.

3

⏱️ The Tick Loop

Heartbeat mechanism: model periodically receives <tengu_tick> XML messages. 'You're awake, what now?' If nothing useful, model MUST call SleepTool. Each wake-up costs an API call; prompt cache expires after 5 minutes.

SleepTool

Model chooses sleep duration. Cheaper than Bash(sleep). Interruptible by user messages.

Queue Priority

'now' interrupts immediately. 'next' wakes SleepTool. 'later' drains at end-of-turn.

Terminal Focus

Unfocused: lean into autonomous action. Focused: be more collaborative.

4

🛠️ KAIROS Tool Suite

Sleep

Yield execution without holding shell process. Feature: PROACTIVE || KAIROS.

SendUserMessage (Brief)

Primary output channel. Supports proactive (unsolicited) vs normal status.

PushNotification

System-level push notification when user walked away.

SubscribePR

GitHub PR webhook subscription for automatic wakeup.

CronCreate/Delete/List

Schedule prompts on cron expressions. One-shot or recurring.

5

🧠 AutoDream Memory Consolidation

Fires after 24 hours and 5 sessions. Forked sub-agent with hardened read-only tool constraints. Four phases: Orient (ls memory), Gather (daily logs, drifted memories), Consolidate (merge into topic files), Prune (update index under 25KB).

💡 Lock Mechanics

File-mtime lock. tryAcquireConsolidationLock() returns null if another process is mid-consolidation. Kill triggers rollbackConsolidationLock() to prevent permanent blockage.

6

📁 Daily Log Memory Model

Standard mode: single MEMORY.md file. KAIROS mode: append-only daily logs at logs/YYYY/MM/YYYY-MM-DD.md. Dream skill distills logs into topic files nightly. MEMORY.md becomes synthesized index.

💡 BriefTool Entitlement vs Activation

isBriefEntitled() checks if user is allowed. isBriefEnabled() checks if opted in. Without split, enrolling user in tengu_kairos_brief would silently activate Brief for all sessions.

📋 Resumo do Modulo

KAIROS is family of build-time flags - core is ant-only; sub-features ship independently.
kairosActive boolean pivots memory mode, BriefTool behavior, fast mode, and bridge worker type.
Tick loop uses tengu_tick heartbeats + SleepTool as cost-aware idle mechanism.
BriefTool separates entitlement (allowed?) from activation (opted in?) preventing silent defaults.
AutoDream fires as forked sub-agent with read-only tool constraints after 24h and 5 sessions.
Positive ternaries mandatory for dead-code elimination - Bun constant-folds feature() to false in external builds.
Voltar Proximo