Skip to content

Commit 4f22515

Browse files
committed
feat(opencode): log token usage including cache read/write per response
1 parent 4e42a89 commit 4f22515

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

packages/opencode/src/session/session.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export const getUsage = (input: { model: Provider.Model; usage: LanguageModelUsa
306306
input.model.cost?.experimentalOver200K && tokens.input + tokens.cache.read > 200_000
307307
? input.model.cost.experimentalOver200K
308308
: input.model.cost
309-
return {
309+
const result = {
310310
cost: safe(
311311
new Decimal(0)
312312
.add(new Decimal(tokens.input).mul(costInfo?.input ?? 0).div(1_000_000))
@@ -320,6 +320,13 @@ export const getUsage = (input: { model: Provider.Model; usage: LanguageModelUsa
320320
),
321321
tokens,
322322
}
323+
log.info("usage", {
324+
input: tokens.input,
325+
output: tokens.output,
326+
cache_write: tokens.cache.write,
327+
cache_read: tokens.cache.read,
328+
})
329+
return result
323330
}
324331

325332
export class BusyError extends Error {

0 commit comments

Comments
 (0)