This repository was archived by the owner on May 15, 2026. It is now read-only.
Commit d56b3da
committed
fix: calculate header percentage based on available input space
The percentage in the collapsed task header was showing 45% when it
should show ~19%. This was because the formula incorrectly calculated:
(tokensUsed + reservedForOutput) / contextWindow * 100
Instead of the correct formula:
tokensUsed / (contextWindow - reservedForOutput) * 100
The correct formula shows the percentage of available input space
that is currently used. The reserved output tokens should not be
counted towards the used percentage since they are reserved for the
model response.
Example with 50.4k tokens, 128k reserved, 400k context window:
- Old (incorrect): (50.4k + 128k) / 400k = 44.6%
- New (correct): 50.4k / (400k - 128k) = 18.5%
Fixes EXT-6751 parent fe722da commit d56b3da
2 files changed
Lines changed: 30 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | | - | |
286 | | - | |
287 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
288 | 292 | | |
289 | 293 | | |
290 | 294 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
405 | 428 | | |
0 commit comments