teapot-coding-agent 0.37.199 → 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,
@@ -2963,7 +2971,16 @@ export class Agent {
2963
2971
  }
2964
2972
  async handleFinish(argsJson) {
2965
2973
  const args = safeParse(argsJson);
2966
- if (args.goalComplete === true && this.goal.status !== "done") {
2974
+ /**
2975
+ * A finish that omits `goalComplete` claims completion, so it is audited.
2976
+ *
2977
+ * `=== true` treated an omitted argument as "not completing" — so the monitor saw a `finish` with no false claim (and
2978
+ * nothing to warn about) while the audit never ran, and the goal could be done on the agent's own say-so. Reported as
2979
+ * "goalComplete が渡されなかった場合にgoal doneになるのにauditされないっぽい / goalComplete が undefined だった場合にこの経路に
2980
+ * 落ちてそう". Only an EXPLICIT `false` means "I am stopping without completing".
2981
+ */
2982
+ const completesGoal = args.goalComplete !== false;
2983
+ if (completesGoal && this.goal.status !== "done") {
2967
2984
  /**
2968
2985
  * A PAUSED goal is not the agent's to complete.
2969
2986
  *
@@ -3362,7 +3379,17 @@ export class Agent {
3362
3379
  });
3363
3380
  return;
3364
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
+ */
3365
3391
  this.lastUsage = undefined;
3392
+ this.usageIsEstimated = true;
3366
3393
  const keepTokens = keepFraction !== undefined
3367
3394
  ? Math.max(1, Math.floor(this.opts.contextTokenBudget * keepFraction))
3368
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.199",
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",