chore: first commit

This commit is contained in:
Han Xiao 2025-02-04 22:24:32 +08:00
parent a032a71701
commit f8bb0b4c1a

View File

@ -15,7 +15,7 @@ export class TokenTracker extends EventEmitter {
const currentTotal = this.getTotalUsage();
if (this.budget && currentTotal + tokens > this.budget) {
// Instead of adding tokens and then throwing, we'll throw before adding
throw new Error(`Token budget exceeded: ${currentTotal + tokens} > ${this.budget}`);
console.error(`Token budget exceeded: ${currentTotal + tokens} > ${this.budget}`);
}
// Only track usage if we're within budget
if (!this.budget || currentTotal + tokens <= this.budget) {