teapot-coding-agent 0.37.201 → 0.37.203
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.
- package/dist/agent/agent.js +22 -20
- package/package.json +1 -1
- package/public/assets/{index-DlXjDc6K.js → index-CeTEMDJa.js} +4 -4
- package/public/assets/index-CeTEMDJa.js.map +1 -0
- package/public/assets/{index-lrkXbZYj.css → index-DQ00J4Kn.css} +1 -1
- package/public/index.html +2 -2
- package/public/assets/index-DlXjDc6K.js.map +0 -1
package/dist/agent/agent.js
CHANGED
|
@@ -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.",
|
|
@@ -291,8 +296,6 @@ export class Agent {
|
|
|
291
296
|
workspaceMissing = false;
|
|
292
297
|
lastProgressAt = Date.now();
|
|
293
298
|
lastUsage;
|
|
294
|
-
/** until the provider reports again, the usage figure is OUR estimate, and the line says so (#249) */
|
|
295
|
-
usageIsEstimated = false;
|
|
296
299
|
modelPricing;
|
|
297
300
|
compactedAtLen = 0;
|
|
298
301
|
pendingSubReport = "";
|
|
@@ -383,12 +386,7 @@ export class Agent {
|
|
|
383
386
|
* time and task size. Telling it the real percentage each turn costs nothing (this line is already
|
|
384
387
|
* per-message) and removes the inference.
|
|
385
388
|
*/
|
|
386
|
-
return
|
|
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" : ""));
|
|
389
|
+
return `${clock} · ${usageLine(this.contextSizeForBudgeting(), this.opts.contextTokenBudget, this.opts.contextWindowTokens)}`;
|
|
392
390
|
}
|
|
393
391
|
activityChars = 0;
|
|
394
392
|
turnsSinceProgress = 0;
|
|
@@ -1022,7 +1020,6 @@ export class Agent {
|
|
|
1022
1020
|
if (own[i].type === "usage") {
|
|
1023
1021
|
const u = own[i].data;
|
|
1024
1022
|
if (typeof u.inputTokens === "number") {
|
|
1025
|
-
this.usageIsEstimated = false;
|
|
1026
1023
|
this.lastUsage = {
|
|
1027
1024
|
input: u.inputTokens,
|
|
1028
1025
|
output: u.outputTokens ?? 0,
|
|
@@ -3379,17 +3376,7 @@ export class Agent {
|
|
|
3379
3376
|
});
|
|
3380
3377
|
return;
|
|
3381
3378
|
}
|
|
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
|
-
*/
|
|
3391
3379
|
this.lastUsage = undefined;
|
|
3392
|
-
this.usageIsEstimated = true;
|
|
3393
3380
|
const keepTokens = keepFraction !== undefined
|
|
3394
3381
|
? Math.max(1, Math.floor(this.opts.contextTokenBudget * keepFraction))
|
|
3395
3382
|
: Math.min(KEEP_RECENT_TOKENS, Math.max(1, Math.floor(this.opts.contextTokenBudget / 4)));
|
|
@@ -3551,12 +3538,27 @@ export class Agent {
|
|
|
3551
3538
|
* or the front of every request changes after a restart and the provider's prefix cache misses for the whole
|
|
3552
3539
|
* session. The line is therefore a recorded fact, and `compactionNotice()` is the single builder both paths use.
|
|
3553
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);
|
|
3554
3556
|
this.messages = [
|
|
3555
3557
|
{
|
|
3556
3558
|
role: "user",
|
|
3557
3559
|
content: compactionNotice({ summarized: oldCount, summary, contextLine: noticeLine }),
|
|
3558
3560
|
},
|
|
3559
|
-
...
|
|
3561
|
+
...kept,
|
|
3560
3562
|
];
|
|
3561
3563
|
}
|
|
3562
3564
|
const after = this.estimateTokens();
|