Commit 416ccef
authored
fix: Fix stale context usage after compaction + usage calculation (#1548)
## Problem
1. Context usage calculation omitted output_tokens, under-reporting total token occupancy.
2. Context usage bar shows stale pre-compaction values until the next agent turn, making it look like context is still full after compaction.
## Changes
1. Include output_tokens in context usage calculation (they become input on the next turn)
2. Emit a usage_update with used:0 immediately on compact_boundary
3. Reset local usage counter on compaction so subsequent turns start fresh
## How did you test this?
Manually1 parent e63f693 commit 416ccef
1 file changed
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
| 374 | + | |
| 375 | + | |
374 | 376 | | |
375 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
376 | 386 | | |
377 | 387 | | |
378 | 388 | | |
| |||
530 | 540 | | |
531 | 541 | | |
532 | 542 | | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
533 | 548 | | |
534 | 549 | | |
535 | 550 | | |
| |||
544 | 559 | | |
545 | 560 | | |
546 | 561 | | |
| 562 | + | |
547 | 563 | | |
548 | 564 | | |
549 | 565 | | |
| |||
0 commit comments