Dashboard › opencode › Distillation
c0cc81f5-7fb3-401a-b50b-d08f9ac8d0e0["lore_tm_v1_sD-yPJw-0_fUceuKzwTMbOcMubVkIzw93uRUXzK05pk"]
/home/byk/Code/opencode-lore/packages/gateway/src/compaction.ts defines isStructuralCompaction(req: GatewayRequest, priorState?: { messageCount: number }): boolean at lines 273–280. It returns false when priorState is absent or priorState.messageCount <= 10; otherwise it detects compaction only when req.messages.length <= 3 and the current count is less than 50% of the prior count./home/byk/Code/opencode-lore/packages/gateway/src/compaction.ts defines CompactionDetection at lines 296–300 as a discriminated union with four outcomes: { detected: false }; { detected: true; reason: "system-prompt"; pattern: string }; { detected: true; reason: "user-keywords"; pattern: string }; or { detected: true; reason: "template-sections"; matchCount: number }.detectCompactionRequest(req: GatewayRequest) at lines 306–344 checks signals in strict order: 1. case-insensitive inclusion of each COMPACTION_SYSTEM_PATTERNS entry in req.system; 2. when req.tools.length === 0, inclusion of a COMPACTION_USER_PATTERNS entry in lastUserText(req); 3. presence of "<template>" plus at least MIN_TEMPLATE_SECTION_MATCHES matching entries from COMPACTION_TEMPLATE_SECTIONS; otherwise it returns { detected: false }.detectCompactionRequest returns the exact matched pattern; for template detection, it returns the counted section matches as matchCount.isCompactionRequest(req: GatewayRequest) at lines 346–348 is a boolean wrapper that returns detectCompactionRequest(req).detected./home/byk/Code/opencode-lore/packages/gateway/src/compaction.ts, beginning at line 350, is extractPreviousSummary; its documented purpose is extracting content from a <previous-summary> block using a dotAll regex.