fix: restore Anthropic token accounting

This commit is contained in:
Peter Steinberger
2026-01-06 18:51:45 +00:00
parent 672762bdd0
commit 2f24ea492b
8 changed files with 115 additions and 25 deletions

View File

@@ -6,6 +6,7 @@ import {
queueEmbeddedPiMessage,
runEmbeddedPiAgent,
} from "../../agents/pi-embedded.js";
import { hasNonzeroUsage } from "../../agents/usage.js";
import {
loadSessionStore,
type SessionEntry,
@@ -450,7 +451,7 @@ export async function runReplyAgent(params: {
sessionEntry?.contextTokens ??
DEFAULT_CONTEXT_TOKENS;
if (usage) {
if (hasNonzeroUsage(usage)) {
const entry = sessionEntry ?? sessionStore[sessionKey];
if (entry) {
const input = usage.input ?? 0;