Commit e468037
Quinn 🕊️
fix: prevent fallback truncation summaries in compaction
Replace the three-level summarization escalation (normal → aggressive →
deterministic truncation) with a two-level approach that returns null on
failure instead of creating garbage summaries.
When both normal and aggressive summarization fail to compress below the
input token count, the compaction engine now bails and retries on the
next turn. This prevents useless '[Truncated from N tokens]' summaries
from polluting the DAG — particularly for media-only messages where the
stored text content is just a file path (~28 tokens) that no LLM can
compress further.
Changes:
- Remove truncation fallback in summarizeWithEscalation() — return null
on compression failure (callers already handle null since upstream)
- Wrap summarizer calls in try/catch to handle LLM errors gracefully
- Add 'level' column to summaries table (normal/aggressive/fallback)
with migration and backfill from compaction event metadata
- Add SummaryRecord.level to store types
- Add lcm_repair tool to scan/re-summarize existing fallback summaries
- Register repair tool in plugin entry point1 parent 518a1b2 commit e468037
6 files changed
Lines changed: 728 additions & 24 deletions
File tree
- src
- db
- plugin
- store
- tools
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | 143 | | |
145 | 144 | | |
146 | 145 | | |
| |||
982 | 981 | | |
983 | 982 | | |
984 | 983 | | |
985 | | - | |
986 | | - | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
987 | 991 | | |
988 | 992 | | |
989 | 993 | | |
| |||
992 | 996 | | |
993 | 997 | | |
994 | 998 | | |
995 | | - | |
996 | | - | |
997 | | - | |
998 | | - | |
| 999 | + | |
999 | 1000 | | |
1000 | 1001 | | |
1001 | 1002 | | |
1002 | 1003 | | |
1003 | | - | |
1004 | | - | |
1005 | | - | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
1006 | 1011 | | |
1007 | 1012 | | |
1008 | 1013 | | |
| |||
1021 | 1026 | | |
1022 | 1027 | | |
1023 | 1028 | | |
1024 | | - | |
1025 | | - | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
1031 | 1036 | | |
1032 | 1037 | | |
1033 | 1038 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
37 | 47 | | |
38 | 48 | | |
39 | 49 | | |
| |||
183 | 193 | | |
184 | 194 | | |
185 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
186 | 240 | | |
187 | 241 | | |
188 | 242 | | |
| |||
386 | 440 | | |
387 | 441 | | |
388 | 442 | | |
| 443 | + | |
389 | 444 | | |
390 | 445 | | |
391 | 446 | | |
| |||
499 | 554 | | |
500 | 555 | | |
501 | 556 | | |
| 557 | + | |
502 | 558 | | |
503 | 559 | | |
| 560 | + | |
504 | 561 | | |
505 | 562 | | |
506 | 563 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
1354 | 1355 | | |
1355 | 1356 | | |
1356 | 1357 | | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
1357 | 1365 | | |
1358 | 1366 | | |
1359 | 1367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
| |||
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
| 181 | + | |
179 | 182 | | |
180 | 183 | | |
181 | 184 | | |
| |||
0 commit comments