Commit 70b029f
committed
🤖 fix: prevent compaction infinite loop and stale usage display
Two related bugs were causing compaction to loop forever:
1. **Message queue overwrote compaction metadata**: When follow-up
messages were queued after a compaction request, the queue's
latestOptions got overwritten, losing the muxMetadata that marks
the message as a compaction-request. The compaction would then be
sent as a normal message, never triggering history replacement.
Fix: Preserve the first muxMetadata and use it in produceMessage().
This ensures compaction metadata survives even when follow-ups are
queued afterward.
2. **Usage display showed pre-compaction context**: After compaction,
the summary message's usage field contained the pre-compaction
context size (since that's what was sent to generate the summary).
This inflated the context window display, making it appear usage
was still high and triggering auto-compaction again.
Fix: Skip compacted messages when computing lastContextUsage.
The summary's usage reflects historical cost, not current context.
_Generated with `mux`_1 parent ac30c74 commit 70b029f
File tree
3 files changed
+122
-20
lines changed- src
- browser/stores
- node/services
3 files changed
+122
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
| 479 | + | |
479 | 480 | | |
480 | 481 | | |
481 | 482 | | |
482 | 483 | | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
483 | 489 | | |
484 | 490 | | |
485 | 491 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
120 | 162 | | |
121 | 163 | | |
122 | 164 | | |
| |||
127 | 169 | | |
128 | 170 | | |
129 | 171 | | |
130 | | - | |
| 172 | + | |
131 | 173 | | |
132 | 174 | | |
133 | 175 | | |
| |||
140 | 182 | | |
141 | 183 | | |
142 | 184 | | |
143 | | - | |
144 | | - | |
| 185 | + | |
145 | 186 | | |
146 | | - | |
| 187 | + | |
| 188 | + | |
147 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
148 | 199 | | |
149 | 200 | | |
150 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
25 | | - | |
| 30 | + | |
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
32 | 47 | | |
33 | 48 | | |
34 | | - | |
35 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
36 | 53 | | |
37 | 54 | | |
38 | 55 | | |
| |||
43 | 60 | | |
44 | 61 | | |
45 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
46 | 75 | | |
47 | 76 | | |
48 | 77 | | |
49 | 78 | | |
50 | 79 | | |
51 | 80 | | |
52 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
53 | 90 | | |
54 | 91 | | |
55 | 92 | | |
| |||
68 | 105 | | |
69 | 106 | | |
70 | 107 | | |
71 | | - | |
| 108 | + | |
72 | 109 | | |
73 | 110 | | |
74 | 111 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 112 | + | |
| 113 | + | |
79 | 114 | | |
80 | 115 | | |
81 | 116 | | |
| |||
90 | 125 | | |
91 | 126 | | |
92 | 127 | | |
93 | | - | |
| 128 | + | |
94 | 129 | | |
95 | 130 | | |
96 | 131 | | |
97 | 132 | | |
98 | 133 | | |
99 | 134 | | |
100 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
101 | 144 | | |
102 | 145 | | |
103 | 146 | | |
| 147 | + | |
104 | 148 | | |
105 | 149 | | |
106 | 150 | | |
| |||
113 | 157 | | |
114 | 158 | | |
115 | 159 | | |
| 160 | + | |
116 | 161 | | |
117 | 162 | | |
118 | 163 | | |
| |||
0 commit comments