-
Notifications
You must be signed in to change notification settings - Fork 22
Closed
Description
When accepting a compaction early, the stream's usage is not returned:
mux/src/node/services/streamManager.ts
Lines 427 to 428 in e4646a2
| // Get usage and duration metadata (usage may be undefined if aborted early) | |
| const { usage, duration } = await this.getStreamMetadata(streamInfo); |
This means all we're able to display to the user is the historical context usage & cost. We aren't able to increment it.
Before interrupted compaction:
After interrupted compaction:
The model becomes unknown too, as we don't create a usageHistory item with the model of the last message unless we know the usage of it:
mux/src/common/utils/tokens/displayUsage.ts
Lines 112 to 119 in e4646a2
| if (msg.metadata?.usage) { | |
| // Use the model from this specific message (not global) | |
| const model = msg.metadata.model ?? fallbackModel ?? "unknown"; | |
| const usage = createDisplayUsage(msg.metadata.usage, model, msg.metadata.providerMetadata); | |
| if (usage) { | |
| usageHistory.push(usage); | |
| } |
mux/src/common/utils/tokens/displayUsage.ts
Lines 19 to 24 in e4646a2
| export function createDisplayUsage( | |
| usage: LanguageModelV2Usage | undefined, | |
| model: string, | |
| providerMetadata?: Record<string, unknown> | |
| ): ChatUsageDisplay | undefined { | |
| if (!usage) return undefined; |
Metadata
Metadata
Assignees
Labels
No labels