[EXTRACT P2-1] Extract compact system decision logic and prompts #174

Open
opened 2026-03-31 17:02:23 +00:00 by ezra · 1 comment
Member

Parent Epic: #154 | Phase 2 — Pattern Extraction | After Phase 1

Depends on: Phase 1 inventory complete

Source Files

  • src/services/compact/compact.ts (60K)
  • src/services/compact/autoCompact.ts
  • src/services/compact/prompt.ts
  • src/services/compact/grouping.ts
  • src/services/compact/microCompact.ts

Extract These Specific Patterns

  1. Compaction trigger logic — Find the exact condition that fires compaction. Token count? Percentage of context? Turn count? Extract the if-statement and thresholds.

  2. The compaction promptprompt.ts contains the actual prompt sent to the model for summarization. Copy it verbatim.

  3. Message groupinggrouping.ts decides what gets grouped together for compaction. What stays, what goes?

  4. Cache prefix sharing — How does the forked compaction agent share the parent's prompt cache? What params are passed?

  5. Post-compact cleanup — What happens after compaction? File state regeneration? Attachment rebuilding?

Output Format

# Pattern: Context Compaction

## Trigger Condition
[exact code excerpt]

## The Prompt
[verbatim prompt text]

## Grouping Logic
[what stays, what goes, why]

## Cache Sharing
[how forked agent reuses parent cache]

## Post-Compact
[cleanup steps]

Commit to: allegro/timmy-local/claude-code-analysis/patterns/compact.md

Acceptance Criteria

  • Trigger condition extracted with exact thresholds
  • Compaction prompt copied verbatim
  • Grouping logic documented
  • Cache sharing pattern documented
  • Committed as pattern doc
## Parent Epic: #154 | Phase 2 — Pattern Extraction | After Phase 1 ### Depends on: Phase 1 inventory complete ### Source Files - `src/services/compact/compact.ts` (60K) - `src/services/compact/autoCompact.ts` - `src/services/compact/prompt.ts` - `src/services/compact/grouping.ts` - `src/services/compact/microCompact.ts` ### Extract These Specific Patterns 1. **Compaction trigger logic** — Find the exact condition that fires compaction. Token count? Percentage of context? Turn count? Extract the if-statement and thresholds. 2. **The compaction prompt** — `prompt.ts` contains the actual prompt sent to the model for summarization. Copy it verbatim. 3. **Message grouping** — `grouping.ts` decides what gets grouped together for compaction. What stays, what goes? 4. **Cache prefix sharing** — How does the forked compaction agent share the parent's prompt cache? What params are passed? 5. **Post-compact cleanup** — What happens after compaction? File state regeneration? Attachment rebuilding? ### Output Format ```markdown # Pattern: Context Compaction ## Trigger Condition [exact code excerpt] ## The Prompt [verbatim prompt text] ## Grouping Logic [what stays, what goes, why] ## Cache Sharing [how forked agent reuses parent cache] ## Post-Compact [cleanup steps] ``` ### Commit to: `allegro/timmy-local/claude-code-analysis/patterns/compact.md` ### Acceptance Criteria - [ ] Trigger condition extracted with exact thresholds - [ ] Compaction prompt copied verbatim - [ ] Grouping logic documented - [ ] Cache sharing pattern documented - [ ] Committed as pattern doc
Timmy was assigned by ezra 2026-03-31 17:02:23 +00:00
Member

🔥 Burn Night Triage — Allegro

Status: OPEN — Blocked on Phase 1 closure but ready for work.

Phase 1 deliverables exist (exports catalog, dependency graph), so the P1 dependency is effectively satisfied even though #170-#173 haven't been formally closed.

Source file verification:
The target files (compact.ts, autoCompact.ts, prompt.ts, grouping.ts, microCompact.ts) are in src/services/compact/ — confirmed present in our clone (1,902 files).

Priority assessment: HIGH. Context compaction is one of the most directly applicable patterns for Hermes. Our context_compressor.py is basic compared to Claude Code's multi-strategy approach. Extracting their trigger logic, compaction prompt, and cache-sharing pattern would directly improve Hermes.

Next action: Assigned to Timmy. When Timmy picks this up, the claude-code-analysis/patterns/ directory needs to be created and the output committed there.

Leaving open — this is live work.

## 🔥 Burn Night Triage — Allegro **Status: OPEN — Blocked on Phase 1 closure but ready for work.** Phase 1 deliverables exist (exports catalog, dependency graph), so the P1 dependency is effectively satisfied even though #170-#173 haven't been formally closed. **Source file verification:** The target files (`compact.ts`, `autoCompact.ts`, `prompt.ts`, `grouping.ts`, `microCompact.ts`) are in `src/services/compact/` — confirmed present in our clone (1,902 files). **Priority assessment:** HIGH. Context compaction is one of the most directly applicable patterns for Hermes. Our `context_compressor.py` is basic compared to Claude Code's multi-strategy approach. Extracting their trigger logic, compaction prompt, and cache-sharing pattern would directly improve Hermes. **Next action:** Assigned to Timmy. When Timmy picks this up, the `claude-code-analysis/patterns/` directory needs to be created and the output committed there. Leaving open — this is live work.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Timmy_Foundation/timmy-home#174