클로드 코드에는 다마고치와 꿈의 엔진이 있습니다

hackernews | | 🔬 연구
#ai개발도구 #autodream #claude #claude code #github #review #tamagotchi
원문 출처: hackernews · Genesis Park에서 요약 및 분석

요약

앤스로픽의 코딩 도구 '클로드 코드' 내부 소스 코드가 유출되어 자율 메모리 통합 시스템인 'AutoDream'과 동반자 캐릭터인 'Buddy'의 존재가 확인되었습니다. AutoDream은 마지막 통합 후 최소 24시간이 경과하고 5개 이상의 세션이 누적되는 등 엄격한 시간 및 세션 게이트 통과 조건을 충족할 때만 포크된 하위 에이전트로서 실행됩니다. 또한 KAIROS 모드나 원격 모드에서는 자동 꿈 기능이 비활성화되며, 동시 실행을 방지하기 위한 잠금 장치와 10분 간격의 세션 스캔 스로틀링 등 안정적인 작동을 위한 다층적 제어 로직이 포함되어 있습니다.

본문

- - Save Houstoten/144e4ae9c520a281551d0cb92c488e04 to your computer and use it in GitHub Desktop. Claude Code internals: AutoDream, Buddy companion, prompt cache economics, microcompact This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters | // biome-ignore-all assist/source/organizeImports: ANT-ONLY import markers must not be reordered | | | // Background memory consolidation. Fires the /dream prompt as a forked | | | // subagent when time-gate passes AND enough sessions have accumulated. | | | // | | | // Gate order (cheapest first): | | | // 1. Time: hours since lastConsolidatedAt >= minHours (one stat) | | | // 2. Sessions: transcript count with mtime > lastConsolidatedAt >= minSessions | | | // 3. Lock: no other process mid-consolidation | | | // | | | // State is closure-scoped inside initAutoDream() rather than module-level | | | // (tests call initAutoDream() in beforeEach for a fresh closure). | | | import type { REPLHookContext } from '../../utils/hooks/postSamplingHooks.js' | | | import { | | | createCacheSafeParams, | | | runForkedAgent, | | | } from '../../utils/forkedAgent.js' | | | import { | | | createUserMessage, | | | createMemorySavedMessage, | | | } from '../../utils/messages.js' | | | import type { Message } from '../../types/message.js' | | | import { logForDebugging } from '../../utils/debug.js' | | | import type { ToolUseContext } from '../../Tool.js' | | | import { logEvent } from '../analytics/index.js' | | | import { getFeatureValue_CACHED_MAY_BE_STALE } from '../analytics/growthbook.js' | | | import { isAutoMemoryEnabled, getAutoMemPath } from '../../memdir/paths.js' | | | import { isAutoDreamEnabled } from './config.js' | | | import { getProjectDir } from '../../utils/sessionStorage.js' | | | import { | | | getOriginalCwd, | | | getKairosActive, | | | getIsRemoteMode, | | | getSessionId, | | | } from '../../bootstrap/state.js' | | | import { createAutoMemCanUseTool } from '../extractMemories/extractMemories.js' | | | import { buildConsolidationPrompt } from './consolidationPrompt.js' | | | import { | | | readLastConsolidatedAt, | | | listSessionsTouchedSince, | | | tryAcquireConsolidationLock, | | | rollbackConsolidationLock, | | | } from './consolidationLock.js' | | | import { | | | registerDreamTask, | | | addDreamTurn, | | | completeDreamTask, | | | failDreamTask, | | | isDreamTask, | | | } from '../../tasks/DreamTask/DreamTask.js' | | | import { FILE_EDIT_TOOL_NAME } from '../../tools/FileEditTool/constants.js' | | | import { FILE_WRITE_TOOL_NAME } from '../../tools/FileWriteTool/prompt.js' | | | // Scan throttle: when time-gate passes but session-gate doesn't, the lock | | | // mtime doesn't advance, so the time-gate keeps passing every turn. | | | const SESSION_SCAN_INTERVAL_MS = 10 * 60 * 1000 | | | type AutoDreamConfig = { | | | minHours: number | | | minSessions: number | | | } | | | const DEFAULTS: AutoDreamConfig = { | | | minHours: 24, | | | minSessions: 5, | | | } | | | /** | | | * Thresholds from tengu_onyx_plover. The enabled gate lives in config.ts | | | * (isAutoDreamEnabled); this returns only the scheduling knobs. Defensive | | | * per-field validation since GB cache can return stale wrong-type values. | | | */ | | | function getConfig(): AutoDreamConfig { | | | const raw = | | | getFeatureValue_CACHED_MAY_BE_STALE | null>( | | | 'tengu_onyx_plover', | | | null, | | | ) | | | return { | | | minHours: | | | typeof raw?.minHours === 'number' && | | | Number.isFinite(raw.minHours) && | | | raw.minHours > 0 | | | ? raw.minHours | | | : DEFAULTS.minHours, | | | minSessions: | | | typeof raw?.minSessions === 'number' && | | | Number.isFinite(raw.minSessions) && | | | raw.minSessions > 0 | | | ? raw.minSessions | | | : DEFAULTS.minSessions, | | | } | | | } | | | function isGateOpen(): boolean { | | | if (getKairosActive()) return false // KAIROS mode uses disk-skill dream | | | if (getIsRemoteMode()) return false | | | if (!isAutoMemoryEnabled()) return false | | | return isAutoDreamEnabled() | | | } | | | // Ant-build-only test override. Bypasses enabled/time/session gates but NOT | | | // the lock (so repeated turns don't pile up dreams) or the memory-dir | | | // precondition. Still scans sessions so the prompt's session-hint is populated. | | | function isForced(): boolean { | | | return false | | | } | | | type AppendSystemMessageFn = NonNullable | | | let runner: | | | | (( | | | context: REPLHookContext, | | | appendSystemMessage?: AppendSystemMessageFn, | | | ) => Promise) | | | | null = null | | | /** | | | * Call once at startup (from backgroundHousekeeping alongside | | | * initExtractMemories), or per-test in beforeEach for a fresh closure. | | | */ | | | export function initAutoDream(): void { | | | let lastSessionScanAt = 0 | | | runner = async function

Genesis Park 편집팀이 AI를 활용하여 작성한 분석입니다. 원문은 출처 링크를 통해 확인할 수 있습니다.

공유

관련 저널 읽기

전체 보기 →