teapot-coding-agent 0.37.173 → 0.37.174

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.
@@ -22,11 +22,22 @@ export const AUTO_CONTINUE_NUDGE = "Continue working toward the current goal. If
22
22
  "When the goal is genuinely met — or truly blocked — call finish() " +
23
23
  "(finish(goalComplete=true) when met, finish(goalComplete=false) when blocked) " +
24
24
  "instead of replying in prose; prose here does not stop the loop.";
25
+ /**
26
+ * How much of the goal the nudge repeats.
27
+ *
28
+ * The nudge is injected on EVERY auto-continue round, so an unbounded goal would re-enter the context over and over
29
+ * (#136). It is clipped — but the clip is ANNOUNCED, because a silently shortened goal is a requirement the model cannot
30
+ * see and cannot ask about: the same failure as the AGENTS.md slice. The full text stays one `get_goal()` away.
31
+ */
32
+ const NUDGE_GOAL_CHARS = 8_000;
25
33
  export function autoContinueNudge(goalText) {
26
34
  const goal = goalText.trim();
27
35
  if (!goal)
28
36
  return AUTO_CONTINUE_NUDGE;
29
- return `${AUTO_CONTINUE_NUDGE}\nCurrent goal:\n=====\n${goal.slice(0, 1500)}\n=====`;
37
+ const shown = goal.length > NUDGE_GOAL_CHARS
38
+ ? `${goal.slice(0, NUDGE_GOAL_CHARS)}\n… (clipped: ${goal.length - NUDGE_GOAL_CHARS} more characters — call get_goal() for the whole goal)`
39
+ : goal;
40
+ return `${AUTO_CONTINUE_NUDGE}\nCurrent goal:\n=====\n${shown}\n=====`;
30
41
  }
31
42
  export const PROGRESS_REQUEST = "Please give a brief progress report now: what you are doing, goal progress, " +
32
43
  "what you recently tried, any problems, and your next step. Keep it under 10 lines. " +
@@ -116,9 +127,9 @@ Most session state is not injected into prompts — fetch it with tools instead:
116
127
  - list_skills() / load_skill(name) / save_skill(...) → reusable playbooks.
117
128
 
118
129
  ## Rules
119
- - Project instructions from AGENTS.md (workspace root) are EMBEDDED in this
120
- prompt below when present — read them here, don't re-read_file it. Keep the
121
- file current by editing it when it goes stale.
130
+ - Project instructions from AGENTS.md (workspace root) are EMBEDDED **in full**
131
+ in this prompt below when present — read them here, don't re-read_file it.
132
+ Keep the file current by editing it when it goes stale.
122
133
  - Work step by step with tools. Verify results (run tests/builds) before claiming progress.
123
134
  - File changes — pick by scope: write_file (one new file / full rewrite) ·
124
135
  edit_file (exactly one small unique replacement) · apply_patch (several
@@ -476,7 +487,16 @@ export class Agent {
476
487
  if (!this.skillsCache.length)
477
488
  return "";
478
489
  const lines = this.skillsCache.map((s) => {
479
- const desc = (s.description || "(no description)").replace(/\s+/g, " ").slice(0, 200);
490
+ /**
491
+ * The description is passed WHOLE.
492
+ *
493
+ * It was cut at 200 characters, and a skill's description is the only thing the model sees when deciding whether to
494
+ * load it — "when a loaded skill matches your task, follow its playbook" is decidable only from that sentence. A
495
+ * truncated one ("…use when verifying work, writing test cases, or rev…") hides exactly the conditions that make
496
+ * the skill relevant, which is the same class of bug as the AGENTS.md truncation: the harness hiding its own
497
+ * instructions and then behaving as if it had given them.
498
+ */
499
+ const desc = (s.description || "(no description)").replace(/\s+/g, " ");
480
500
  return `- ${s.name}: ${desc}`;
481
501
  });
482
502
  return lines.join("\n");
@@ -1194,18 +1214,18 @@ export class Agent {
1194
1214
  });
1195
1215
  }
1196
1216
  async setGoalVerify(verify) {
1197
- this.goal = { ...this.goal, verify: verify.slice(0, 4000), updatedAt: new Date().toISOString() };
1217
+ this.goal = { ...this.goal, verify, updatedAt: new Date().toISOString() };
1198
1218
  await this.writeGoalFile();
1199
1219
  await this.log.append("goal", this.currentSession, this.currentBranch, {
1200
1220
  event: "verify-set",
1201
- verify: verify.slice(0, 2000),
1221
+ verify,
1202
1222
  });
1203
1223
  }
1204
1224
  async setGoalAudit(verdict, feedback) {
1205
1225
  this.goal = {
1206
1226
  ...this.goal,
1207
1227
  updatedAt: new Date().toISOString(),
1208
- audit: { verdict, feedback: feedback.slice(0, 4000), at: new Date().toISOString() },
1228
+ audit: { verdict, feedback, at: new Date().toISOString() },
1209
1229
  };
1210
1230
  if (verdict === "approved")
1211
1231
  this.goal.status = "done";
@@ -1222,7 +1242,11 @@ export class Agent {
1222
1242
  await this.log.append("goal", this.currentSession, this.currentBranch, {
1223
1243
  event: "audit",
1224
1244
  verdict,
1225
- feedback: feedback.slice(0, 2000),
1245
+ /**
1246
+ * Not cut: `feedback` is what the auditor tells the NEXT turn to fix, so a truncation silently drops requirements —
1247
+ * the same failure mode as the AGENTS.md slice. The bound is only a runaway guard.
1248
+ */
1249
+ feedback: feedback.slice(0, 20_000),
1226
1250
  });
1227
1251
  }
1228
1252
  snapshot() {
@@ -1251,7 +1275,7 @@ export class Agent {
1251
1275
  goal: {
1252
1276
  status: this.goal.status,
1253
1277
  text: this.goal.text,
1254
- ...(this.goal.verify ? { verify: this.goal.verify.slice(0, 1000) } : {}),
1278
+ ...(this.goal.verify ? { verify: this.goal.verify } : {}),
1255
1279
  ...(this.goal.audit ? { audit: this.goal.audit } : {}),
1256
1280
  },
1257
1281
  latestProgress: this.latestProgress,
@@ -1753,7 +1777,7 @@ export class Agent {
1753
1777
  }
1754
1778
  const isSub = !!this.opts.parent;
1755
1779
  const nudge = isSub
1756
- ? this.harnessMessage(`[harness] Auto-nudge. Re-anchor on YOUR task — and only that:\n\n${this.goal.text.slice(0, 1500)}\n\nThe inherited conversation is reference only; other agents own any older tasks in it. If your task is complete, call finish() now instead of continuing. If blocked, explain why briefly and finish().`)
1780
+ ? this.harnessMessage(`[harness] Auto-nudge. Re-anchor on YOUR task — and only that:\n\n${this.goal.text.length > NUDGE_GOAL_CHARS ? this.goal.text.slice(0, NUDGE_GOAL_CHARS) + "\n… (clipped — call get_goal() for the whole goal)" : this.goal.text}\n\nThe inherited conversation is reference only; other agents own any older tasks in it. If your task is complete, call finish() now instead of continuing. If blocked, explain why briefly and finish().`)
1757
1781
  : this.harnessMessage(autoContinueNudge(this.goal.text));
1758
1782
  await this.log.append("prompt", this.currentSession, this.currentBranch, {
1759
1783
  source: "harness",
@@ -1959,7 +1983,7 @@ export class Agent {
1959
1983
  if (text)
1960
1984
  await this.setGoal(text);
1961
1985
  if (typeof a.verify === "string" && a.verify.trim())
1962
- await this.setGoalVerify(a.verify.trim().slice(0, 4000));
1986
+ await this.setGoalVerify(a.verify.trim().slice(0, 20_000));
1963
1987
  await this.answerMeta(call, text ? "goal updated" : "empty goal rejected");
1964
1988
  return "next";
1965
1989
  },
@@ -1974,7 +1998,8 @@ export class Agent {
1974
1998
  },
1975
1999
  ask_operator: async (call, m) => {
1976
2000
  const a = safeParse(call.function.arguments);
1977
- const question = String(a.question ?? "").slice(0, 2000);
2001
+ // a question cut at 2,000 characters asks the operator something else than what the model meant
2002
+ const question = String(a.question ?? "").slice(0, 20_000);
1978
2003
  const options = Array.isArray(a.options)
1979
2004
  ? a.options
1980
2005
  .slice(0, 6)
@@ -2558,19 +2583,34 @@ export class Agent {
2558
2583
  const head = [{ role: "system", content: sys }];
2559
2584
  return hasSystem ? [...head, ...this.messages.slice(1)] : [...head, ...this.messages];
2560
2585
  }
2561
- reloadAgentsMd() {
2562
- if (!this.agentsMdLoaded)
2563
- return null;
2564
- let fresh;
2586
+ /**
2587
+ * AGENTS.md is passed WHOLE, and read in one place.
2588
+ *
2589
+ * It was `readFileSync(...).slice(0, 12_000)` in three places — MEASURED on this repository: 56,290 characters, so
2590
+ * ~79% of the project's rules never reached the model, while the prompt line says "EMBEDDED in this prompt below when
2591
+ * present — read them here, don't re-read_file it". The rules that were cut are exactly the ones written after
2592
+ * repeated bugs (reproduce before fixing, verify the PATH a helper is called from, prefer the real measurement over a
2593
+ * synthetic test), so the harness hid its own hard-won knowledge and then behaved as if it had been told.
2594
+ *
2595
+ * `reloadAgentsMd` compared the same truncated prefix, so an edit in the second half was invisible to the reload too.
2596
+ */
2597
+ readAgentsMd() {
2565
2598
  try {
2566
2599
  const p = path.join(this.opts.workspace, "AGENTS.md");
2567
2600
  if (!existsSync(p))
2568
- return null;
2569
- fresh = readFileSync(p, "utf8").slice(0, 12_000);
2601
+ return "";
2602
+ return readFileSync(p, "utf8");
2570
2603
  }
2571
2604
  catch {
2572
- return null;
2605
+ return "";
2573
2606
  }
2607
+ }
2608
+ reloadAgentsMd() {
2609
+ if (!this.agentsMdLoaded)
2610
+ return null;
2611
+ const fresh = this.readAgentsMd();
2612
+ if (!fresh)
2613
+ return null;
2574
2614
  if (fresh === this.agentsMd)
2575
2615
  return null;
2576
2616
  this.agentsMd = fresh;
@@ -2595,14 +2635,7 @@ export class Agent {
2595
2635
  this.wsSnapshot = "(empty workspace)";
2596
2636
  }
2597
2637
  if (!this.wsSnapshot) {
2598
- try {
2599
- this.agentsMd = existsSync(path.join(this.opts.workspace, "AGENTS.md"))
2600
- ? readFileSync(path.join(this.opts.workspace, "AGENTS.md"), "utf8").slice(0, 12_000)
2601
- : "";
2602
- }
2603
- catch {
2604
- this.agentsMd = "";
2605
- }
2638
+ this.agentsMd = this.readAgentsMd();
2606
2639
  try {
2607
2640
  const entries = readdirSync(this.opts.workspace, { withFileTypes: true });
2608
2641
  const lines = [];
@@ -2633,21 +2666,20 @@ export class Agent {
2633
2666
  }
2634
2667
  }
2635
2668
  else {
2636
- try {
2637
- this.agentsMd = existsSync(path.join(this.opts.workspace, "AGENTS.md"))
2638
- ? readFileSync(path.join(this.opts.workspace, "AGENTS.md"), "utf8").slice(0, 12_000)
2639
- : "";
2640
- }
2641
- catch {
2642
- this.agentsMd = "";
2643
- }
2669
+ this.agentsMd = this.readAgentsMd();
2644
2670
  }
2645
2671
  this.skillCatalogue = this.skillCatalogueText();
2646
2672
  this.memoryDigest = this.memoryDigestText();
2647
2673
  }
2648
2674
  let sys = SYSTEM_TEMPLATE;
2649
2675
  if (this.agentsMd.trim()) {
2650
- sys += `\n\n## Project instructions (AGENTS.md)\n\n${this.agentsMd}`;
2676
+ // the whole file, with its size stated so the model can tell "this is everything" from "this was cut"
2677
+ // the heading stays stable (tests and the model both key on it); the size line says "this is the whole file", so a
2678
+ // model cannot mistake it for an excerpt the way it could when 79% was silently cut
2679
+ sys +=
2680
+ `\n\n## Project instructions (AGENTS.md)\n` +
2681
+ `(complete file, ${this.agentsMd.length.toLocaleString()} characters)\n\n` +
2682
+ this.agentsMd;
2651
2683
  }
2652
2684
  if (this.wsSnapshot) {
2653
2685
  sys += `\n\n## Workspace snapshot (top level)\n${this.wsSnapshot}\nUse list_dir/read_file for anything deeper — do NOT list again what is already here.`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.37.173",
3
+ "version": "0.37.174",
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",