teapot-coding-agent 0.37.200 → 0.37.201

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -291,6 +291,8 @@ export class Agent {
291
291
  workspaceMissing = false;
292
292
  lastProgressAt = Date.now();
293
293
  lastUsage;
294
+ /** until the provider reports again, the usage figure is OUR estimate, and the line says so (#249) */
295
+ usageIsEstimated = false;
294
296
  modelPricing;
295
297
  compactedAtLen = 0;
296
298
  pendingSubReport = "";
@@ -381,7 +383,12 @@ export class Agent {
381
383
  * time and task size. Telling it the real percentage each turn costs nothing (this line is already
382
384
  * per-message) and removes the inference.
383
385
  */
384
- return `${clock} · ${usageLine(this.contextSizeForBudgeting(), this.opts.contextTokenBudget, this.opts.contextWindowTokens)}`;
386
+ return (`${clock} · ${usageLine(this.contextSizeForBudgeting(), this.opts.contextTokenBudget, this.opts.contextWindowTokens)}` +
387
+ /**
388
+ * An estimate is labelled, because a model that is told "3% used" right after a compaction it cannot see the numbers for
389
+ * will fill the gap with the impression it had BEFORE the pass — that is the reported behaviour, not a shortage of tokens.
390
+ */
391
+ (this.usageIsEstimated ? " · estimated, not the provider's count" : ""));
385
392
  }
386
393
  activityChars = 0;
387
394
  turnsSinceProgress = 0;
@@ -1015,6 +1022,7 @@ export class Agent {
1015
1022
  if (own[i].type === "usage") {
1016
1023
  const u = own[i].data;
1017
1024
  if (typeof u.inputTokens === "number") {
1025
+ this.usageIsEstimated = false;
1018
1026
  this.lastUsage = {
1019
1027
  input: u.inputTokens,
1020
1028
  output: u.outputTokens ?? 0,
@@ -3371,7 +3379,17 @@ export class Agent {
3371
3379
  });
3372
3380
  return;
3373
3381
  }
3382
+ /**
3383
+ * The provider's own count is dropped here because it described the OLD history — but a dropped count is replaced by an
3384
+ * ESTIMATE, and the estimate is what the model then reads in its usage line. MEASURED (#249): after a compaction the line
3385
+ * reported a far smaller figure than the provider would have charged, and the model reasoned "context is near compaction"
3386
+ * from the stale impression it had before the pass — "compact後にサボる原因これじゃね? / まだ勘違いされてそう".
3387
+ *
3388
+ * So the estimate is marked as one. `contextSizeForBudgeting` keeps reporting the estimate for the compaction DECISION (it
3389
+ * must, the old count is gone), and the USAGE LINE says which of the two it is showing.
3390
+ */
3374
3391
  this.lastUsage = undefined;
3392
+ this.usageIsEstimated = true;
3375
3393
  const keepTokens = keepFraction !== undefined
3376
3394
  ? Math.max(1, Math.floor(this.opts.contextTokenBudget * keepFraction))
3377
3395
  : Math.min(KEEP_RECENT_TOKENS, Math.max(1, Math.floor(this.opts.contextTokenBudget / 4)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.37.200",
3
+ "version": "0.37.201",
4
4
  "description": "A lightweight, always-on multi-agent harness for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",