mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-22 01:02:16 +00:00
Use clearer abbreviations in compaction diagrams
This commit is contained in:
parent
3c5f4920c0
commit
a2664ba38a
1 changed files with 32 additions and 32 deletions
|
|
@ -188,31 +188,31 @@ When context exceeds the threshold, pi finds a "cut point" that keeps recent tur
|
||||||
|
|
||||||
```
|
```
|
||||||
Legend:
|
Legend:
|
||||||
H = header U = user message A = assistant message
|
hdr = header usr = user message ass = assistant message
|
||||||
T = tool result C = compaction entry B = bashExecution
|
tool = tool result cmp = compaction entry bash = bashExecution
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
Session entries (before compaction):
|
Session entries (before compaction):
|
||||||
|
|
||||||
index: 0 1 2 3 4 5 6 7 8 9 10 11
|
index: 0 1 2 3 4 5 6 7 8 9 10 11
|
||||||
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
┌─────┬─────┬─────┬─────┬──────┬─────┬─────┬─────┬──────┬──────┬─────┬──────┐
|
||||||
│ H │ C │ U │ A │ T │ A │ U │ A │ T │ T │ A │ T │
|
│ hdr │ cmp │ usr │ ass │ tool │ ass │ usr │ ass │ tool │ tool │ ass │ tool │
|
||||||
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
└─────┴─────┴─────┴─────┴──────┴─────┴─────┴─────┴──────┴──────┴─────┴──────┘
|
||||||
↑ └───────┬───────┘ └─────────┬─────────┘
|
↑ └────────┬────────┘ └────────────┬────────────┘
|
||||||
previousSummary messagesToSummarize messagesToKeep
|
previousSummary messagesToSummarize messagesToKeep
|
||||||
↑
|
↑
|
||||||
cutPoint.firstKeptEntryIndex = 6
|
cutPoint.firstKeptEntryIndex = 6
|
||||||
|
|
||||||
After compaction (new entry appended):
|
After compaction (new entry appended):
|
||||||
|
|
||||||
index: 0 1 2 3 4 5 6 7 8 9 10 11 12
|
index: 0 1 2 3 4 5 6 7 8 9 10 11 12
|
||||||
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
┌─────┬─────┬─────┬─────┬──────┬─────┬─────┬─────┬──────┬──────┬─────┬──────┬─────┐
|
||||||
│ H │ C │ U │ A │ T │ A │ U │ A │ T │ T │ A │ T │ C │
|
│ hdr │ cmp │ usr │ ass │ tool │ ass │ usr │ ass │ tool │ tool │ ass │ tool │ cmp │
|
||||||
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
└─────┴─────┴─────┴─────┴──────┴─────┴─────┴─────┴──────┴──────┴─────┴──────┴─────┘
|
||||||
└───────┬───────┘ └─────────┬─────────┘ ↑
|
└────────┬────────┘ └────────────┬────────────┘ ↑
|
||||||
ignored loaded firstKeptEntryIndex = 6
|
ignored loaded firstKeptEntryIndex = 6
|
||||||
on reload on reload (stored in new C)
|
on reload on reload (stored in new cmp)
|
||||||
```
|
```
|
||||||
|
|
||||||
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`. The cut point is always a user, assistant, or bashExecution message (never a tool result, which must stay with its tool call).
|
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`. The cut point is always a user, assistant, or bashExecution message (never a tool result, which must stay with its tool call).
|
||||||
|
|
@ -220,11 +220,11 @@ The session file is append-only. When loading, the session loader finds the late
|
||||||
```
|
```
|
||||||
What gets sent to the LLM as context:
|
What gets sent to the LLM as context:
|
||||||
|
|
||||||
┌────────────────────────────────────────────────────────────┐
|
┌──────────────────────────────────────────────────────────────────────────────────────┐
|
||||||
│ [system] [summary] [U idx 6] [A idx 7] [T idx 8] [T idx 9] [A idx 10] [T idx 11] │
|
│ [system] [summary] [usr idx 6] [ass idx 7] [tool idx 8] [tool idx 9] [ass idx 10] [tool idx 11] │
|
||||||
└────────────────────────────────────────────────────────────┘
|
└──────────────────────────────────────────────────────────────────────────────────────┘
|
||||||
↑ └──────────────────┬──────────────────┘
|
↑ └──────────────────────┬──────────────────────┘
|
||||||
from new C's summary messages from firstKeptEntryIndex onwards
|
from new cmp's summary messages from firstKeptEntryIndex onwards
|
||||||
```
|
```
|
||||||
|
|
||||||
**Split turns:** When a single turn is too large, the cut point may land mid-turn at an assistant message. In this case `cutPoint.isSplitTurn = true`:
|
**Split turns:** When a single turn is too large, the cut point may land mid-turn at an assistant message. In this case `cutPoint.isSplitTurn = true`:
|
||||||
|
|
@ -232,18 +232,18 @@ What gets sent to the LLM as context:
|
||||||
```
|
```
|
||||||
Split turn example (one huge turn that exceeds keepRecentTokens):
|
Split turn example (one huge turn that exceeds keepRecentTokens):
|
||||||
|
|
||||||
index: 0 1 2 3 4 5 6 7 8 9
|
index: 0 1 2 3 4 5 6 7 8 9
|
||||||
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
┌─────┬─────┬─────┬──────┬─────┬──────┬──────┬─────┬──────┬─────┐
|
||||||
│ H │ U │ A │ T │ A │ T │ T │ A │ T │ A │
|
│ hdr │ usr │ ass │ tool │ ass │ tool │ tool │ ass │ tool │ ass │
|
||||||
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
└─────┴─────┴─────┴──────┴─────┴──────┴──────┴─────┴──────┴─────┘
|
||||||
↑ ↑
|
↑ ↑
|
||||||
turnStartIndex = 1 firstKeptEntryIndex = 7
|
turnStartIndex = 1 firstKeptEntryIndex = 7
|
||||||
│ │ (must be U/A/B, not T)
|
│ │ (must be usr/ass/bash, not tool)
|
||||||
└───── turn prefix ─────┘ (idx 1-6, summarized separately)
|
└─────────── turn prefix ───────────────┘ (idx 1-6, summarized separately)
|
||||||
└── kept messages (idx 7-9)
|
└── kept messages (idx 7-9)
|
||||||
|
|
||||||
messagesToSummarize = [] (no complete turns before this one)
|
messagesToSummarize = [] (no complete turns before this one)
|
||||||
messagesToKeep = [A idx 7, T idx 8, A idx 9]
|
messagesToKeep = [ass idx 7, tool idx 8, ass idx 9]
|
||||||
|
|
||||||
The default compaction generates TWO summaries that get merged:
|
The default compaction generates TWO summaries that get merged:
|
||||||
1. History summary (previousSummary + messagesToSummarize)
|
1. History summary (previousSummary + messagesToSummarize)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue