Compare commits

...
Author SHA1 Message Date
Saoud Rizwan 0edcc02e9f v3.40.1 Release Notes
Hotfix release including:
- 4df486fa5: fix cost calculation for Anthropic API requests (#7943)
2025-12-05 15:52:02 -08:00
Saoud Rizwan 5479fe53a6 fix: restore cost calculation for Anthropic API requests (#7943)
The taskMetrics.totalCost was incorrectly initialized to 0 instead of
undefined in commit 09692d7d3. This broke cost display for providers
like Anthropic that don't return totalCost in their usage chunks.

When totalCost is 0, the fallback to calculateApiCostAnthropic() in
updateApiReqMsg doesn't trigger because the nullish coalescing operator
(??) only falls back for null/undefined, not 0.

By initializing totalCost to undefined:
- Providers that return totalCost (like OpenRouter) use that value
- Providers that don't (like Anthropic) fall back to calculating cost
  from token counts and model pricing info
2025-12-05 15:51:44 -08:00
3 changed files with 12 additions and 2 deletions
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [3.40.1]
- Fix cost calculation display for Anthropic API requests
## [3.40.0]
- Fix highlighted text flashing when task header is collapsed
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "claude-dev",
"displayName": "Cline",
"description": "Autonomous coding agent right in your IDE, capable of creating/editing files, running commands, using the browser, and more with your permission every step of the way.",
"version": "3.40.0",
"version": "3.40.1",
"icon": "assets/icons/icon.png",
"engines": {
"vscode": "^1.84.0"
+7 -1
View File
@@ -2716,7 +2716,13 @@ export class Task {
await this.postStateToWebview()
try {
const taskMetrics = { cacheWriteTokens: 0, cacheReadTokens: 0, inputTokens: 0, outputTokens: 0, totalCost: 0 }
const taskMetrics: {
cacheWriteTokens: number
cacheReadTokens: number
inputTokens: number
outputTokens: number
totalCost: number | undefined
} = { cacheWriteTokens: 0, cacheReadTokens: 0, inputTokens: 0, outputTokens: 0, totalCost: undefined }
const abortStream = async (cancelReason: ClineApiReqCancelReason, streamingFailedMessage?: string) => {
if (this.diffViewProvider.isEditing) {