Commit 7afe084
committed
🤖 fix: preserve usage data when queued message interrupts stream
Two bugs caused usage/cost data to reset when a queued message was sent:
1. AI SDK's totalUsage returns zeros on abort - now use tracked cumulativeUsage
2. usageStore cache not invalidated on stream-start - now bump on new stream
Usage from the interrupted step is abandoned since finish-step fires before
tool execution, but cumulative usage from completed steps is preserved.1 parent 372f0d9 commit 7afe084
File tree
4 files changed
+25
-3
lines changed- src
- browser/stores
- common/types
- node/services
4 files changed
+25
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
147 | 149 | | |
148 | 150 | | |
149 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
63 | 70 | | |
64 | 71 | | |
65 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
503 | | - | |
504 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
505 | 517 | | |
506 | 518 | | |
507 | 519 | | |
508 | 520 | | |
509 | 521 | | |
510 | 522 | | |
511 | | - | |
| 523 | + | |
512 | 524 | | |
513 | 525 | | |
514 | 526 | | |
| |||
0 commit comments