teapot-coding-agent 0.37.200 → 0.37.202

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.
@@ -53,6 +53,11 @@ const SUMMARIZE_MIN_TOKENS = 2_000;
53
53
  const SUMMARIZE_OVERFLOW_RETRIES = 3;
54
54
  const SUMMARIZE_SHRINK = 0.6;
55
55
  const MAX_AUTO_COMPACT_FAILURES = 3;
56
+ /**
57
+ * The usage segment a harness message carries (`context 75% used (787k/1049k tokens) · auto-compacts at 786k · 0 until
58
+ * auto-compaction`), matched so it can be neutralised when a compaction keeps the message alive with a newer truth.
59
+ */
60
+ const STALE_USAGE_LINE = /context \d+% used \([^)]*\)(?: · auto-compacts at [^·]*)?(?: · \d+ until auto-compaction)?|context \d+ tokens used/;
56
61
  const OVERFLOW_SHRINK_STEPS = [0.5, 0.35, 0.2];
57
62
  const COMPACT_INSTRUCTION = [
58
63
  "You compress a coding agent's conversation into dense notes for it to continue working.",
@@ -3533,12 +3538,27 @@ export class Agent {
3533
3538
  * or the front of every request changes after a restart and the provider's prefix cache misses for the whole
3534
3539
  * session. The line is therefore a recorded fact, and `compactionNotice()` is the single builder both paths use.
3535
3540
  */
3541
+ /**
3542
+ * A usage line that survives INTO the compacted context is a stale fact, so it is rewritten.
3543
+ *
3544
+ * MEASURED in prismrv-2-9bb8660a: a harness progress request logged at 09:37:19 read "context 75% used
3545
+ * (787k/1049k tokens) · auto-compacts at 786k · 0 until auto-compaction" — true at that moment — and the compaction
3546
+ * ran 40s later. The kept TAIL still held that message, so the model's next reasoning said "The context is at 75%,
3547
+ * near auto-compaction" while the notice at the front of the same conversation said 1%. The model read the number
3548
+ * nearest the end of its history, which was the one from before the pass.
3549
+ *
3550
+ * The notice is the single owner of "how much is used NOW", so every usage line in the retained messages is replaced
3551
+ * with a pointer to it rather than left to contradict it.
3552
+ */
3553
+ const kept = this.messages.slice(cut).map((m) => typeof m.content === "string" && m.content.includes("until auto-compaction")
3554
+ ? { ...m, content: m.content.replace(STALE_USAGE_LINE, "(context usage: see the compaction notice at the top)") }
3555
+ : m);
3536
3556
  this.messages = [
3537
3557
  {
3538
3558
  role: "user",
3539
3559
  content: compactionNotice({ summarized: oldCount, summary, contextLine: noticeLine }),
3540
3560
  },
3541
- ...this.messages.slice(cut),
3561
+ ...kept,
3542
3562
  ];
3543
3563
  }
3544
3564
  const after = this.estimateTokens();
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.202",
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",