Skip to content

Commit e26ef3c

Browse files
committed
Fixing anthropic model caching in roo-code
1 parent 4026a87 commit e26ef3c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/api/providers/unbound.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,20 @@ export class UnboundHandler implements ApiHandler, SingleCompletionHandler {
106106
}
107107

108108
if (usage) {
109-
yield {
110-
type: "usage",
111-
inputTokens: usage?.prompt_tokens || 0,
112-
outputTokens: usage?.completion_tokens || 0,
109+
if (this.getModel().id.startsWith("anthropic/")) {
110+
yield {
111+
type: "usage",
112+
inputTokens: usage?.prompt_tokens || 0,
113+
outputTokens: usage?.completion_tokens || 0,
114+
cacheWriteTokens: (usage as any)?.cache_creation_input_tokens || 0,
115+
cacheReadTokens: (usage as any)?.cache_read_input_tokens || 0,
116+
}
117+
} else {
118+
yield {
119+
type: "usage",
120+
inputTokens: usage?.prompt_tokens || 0,
121+
outputTokens: usage?.completion_tokens || 0,
122+
}
113123
}
114124
}
115125
}

0 commit comments

Comments
 (0)