mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 15:02:32 +00:00
Fix compaction ASCII diagram to show append-only behavior
This commit is contained in:
parent
ea16af8b72
commit
ea3ab718ea
1 changed files with 19 additions and 17 deletions
|
|
@ -188,26 +188,28 @@ When context exceeds the threshold, pi finds a "cut point" that keeps ~20k token
|
||||||
|
|
||||||
```
|
```
|
||||||
Session entries (before compaction):
|
Session entries (before compaction):
|
||||||
┌─────────────────────────────────────────────────────────────────┐
|
|
||||||
│ [header] [prev compaction] [msg] [msg] [msg] [msg] [msg] [msg] │
|
|
||||||
│ ↑ └─────┬─────┘ └───────┬───────┘ │
|
|
||||||
│ previousSummary messagesToSummarize messagesToKeep│
|
|
||||||
│ (will be discarded) (kept as-is) │
|
|
||||||
│ ↑ │
|
|
||||||
│ cutPoint.firstKeptEntryIndex │
|
|
||||||
└─────────────────────────────────────────────────────────────────┘
|
|
||||||
|
|
||||||
After compaction:
|
index: 0 1 2 3 4 5 6 7
|
||||||
┌─────────────────────────────────────────────────────────────────┐
|
┌────────┬───────────────┬─────┬─────┬─────┬─────┬─────┬─────┐
|
||||||
│ [header] [prev compaction] [NEW compaction] [msg] [msg] [msg] │
|
│ header │ prev compact │ msg │ msg │ msg │ msg │ msg │ msg │
|
||||||
│ └──────┬──────┘ └───────┬───────┘ │
|
└────────┴───────────────┴─────┴─────┴─────┴─────┴─────┴─────┘
|
||||||
│ summary of messagesToKeep │
|
↑ └─────┬─────┘ └───────┬───────┘
|
||||||
│ messagesToSummarize (unchanged) │
|
previousSummary messagesToSummarize messagesToKeep
|
||||||
│ + previousSummary │
|
↑
|
||||||
└─────────────────────────────────────────────────────────────────┘
|
cutPoint.firstKeptEntryIndex = 5
|
||||||
|
|
||||||
|
After compaction (new entry appended):
|
||||||
|
|
||||||
|
index: 0 1 2 3 4 5 6 7 8
|
||||||
|
┌────────┬───────────────┬─────┬─────┬─────┬─────┬─────┬─────┬─────────────┐
|
||||||
|
│ header │ prev compact │ msg │ msg │ msg │ msg │ msg │ msg │ NEW compact │
|
||||||
|
└────────┴───────────────┴─────┴─────┴─────┴─────┴─────┴─────┴─────────────┘
|
||||||
|
└─────┬─────┘ └───────┬───────┘ ↑
|
||||||
|
ignored loaded firstKeptEntryIndex = 5
|
||||||
|
on reload on reload (stored in this entry)
|
||||||
```
|
```
|
||||||
|
|
||||||
The new compaction entry's `firstKeptEntryIndex` tells the session loader where to start reading messages after the summary.
|
The session file is append-only. When loading, the session loader finds the latest compaction entry, uses its summary, then loads messages starting from `firstKeptEntryIndex`.
|
||||||
|
|
||||||
**Event fields:**
|
**Event fields:**
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue