teapot-coding-agent 0.37.16 → 0.37.18

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/master.js CHANGED
@@ -1741,7 +1741,7 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
1741
1741
  const a = this.config.agents.find((x) => x.id === agentId);
1742
1742
  if (!a || a.session !== sessionId)
1743
1743
  return undefined; // the label belongs to the CURRENT session
1744
- const t = a.sessionTitle?.trim();
1744
+ const t = typeof a.sessionTitle === "string" ? a.sessionTitle.trim() : "";
1745
1745
  return t ? t : undefined;
1746
1746
  }
1747
1747
  /**
@@ -1758,10 +1758,9 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
1758
1758
  if (a.sessionTitle?.trim())
1759
1759
  return;
1760
1760
  const dir = path.join(this.sessionsRoot(), sessionId);
1761
- const title = this.sessionTitleOf(dir);
1762
- if (!title)
1763
- return;
1764
- a.sessionTitle = title;
1761
+ // the session id when nothing is derivable — see the migration: it never changes, so this
1762
+ // cannot leave the field unset and have the derivation re-run on every boot
1763
+ a.sessionTitle = this.sessionTitleOf(dir) ?? sessionId;
1765
1764
  this.saveConfig();
1766
1765
  }
1767
1766
  sessionTitleOf(dirPath) {
@@ -2316,7 +2315,15 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
2316
2315
  uptimeSec: Math.floor((Date.now() - this.startedAt) / 1000),
2317
2316
  rssMb: +(mu.rss / 1048576).toFixed(1),
2318
2317
  heapUsedMb: +(mu.heapUsed / 1048576).toFixed(1),
2319
- cpuMsTotal: cu.user + cu.system,
2318
+ /**
2319
+ * `process.cpuUsage()` reports MICROseconds, so this is divided by 1000.
2320
+ *
2321
+ * The field is named `cpuMsTotal` and was not converted, so it read 1000x too high — a
2322
+ * 1900-second-old process reported 18,313,198 "ms" against a real 18,310ms of CPU, which
2323
+ * looks like 9.6 cores burning continuously. That is how a healthy idle server got
2324
+ * investigated as a runaway loop.
2325
+ */
2326
+ cpuMsTotal: Math.round((cu.user + cu.system) / 1000),
2320
2327
  loadavg1: +(os.loadavg()[0]).toFixed(2),
2321
2328
  agents: [...this.agents.values()].map((a) => ({
2322
2329
  id: a.opts_id(),
@@ -33,9 +33,16 @@ export const sessionTitles = {
33
33
  if (session.includes("/") || session.includes(".."))
34
34
  continue; // never a path segment
35
35
  const title = firstUserPromptText(path.join(ctx.dataDir, "sessions", session, "chat.jsonl"));
36
- if (!title)
37
- continue;
38
- a.sessionTitle = title;
36
+ /**
37
+ * The SESSION ID is the fallback, not a marker.
38
+ *
39
+ * A sub-agent session receives only harness prompts, so no title can ever be derived from it —
40
+ * and a session id does not change either, so there is nothing to retry for. Writing the id
41
+ * makes the field ALWAYS present, which is what makes the pass idempotent without an extra
42
+ * flag: the next boot sees a title and skips. The sidebar already shows the id in this case,
43
+ * so nothing visible changes.
44
+ */
45
+ a.sessionTitle = title ?? session;
39
46
  changed = true;
40
47
  }
41
48
  if (changed)
@@ -49,13 +56,22 @@ export const sessionTitles = {
49
56
  * Bounded (256KB) and stops at the first prompt, so one enormous log cannot dominate boot. A torn
50
57
  * final line at a chunk boundary is skipped rather than aborting the read.
51
58
  */
59
+ /**
60
+ * ONE reusable read buffer for the whole pass.
61
+ *
62
+ * `Buffer.alloc` per session is what made the first boot spike: 830 sessions x 16KB of short-lived
63
+ * buffer, MEASURED as heap 28.2MB → 108.5MB during `start()` (33.4MB after GC). The scan is a
64
+ * single-threaded loop, so sharing one buffer is safe and removes the churn entirely.
65
+ */
66
+ let scanBuffer;
52
67
  function firstUserPromptText(file) {
53
68
  let fd;
54
69
  try {
55
70
  fd = openSync(file, "r");
56
71
  const CHUNK = 16 * 1024;
57
72
  const CAP = 256 * 1024;
58
- const buf = Buffer.alloc(CHUNK);
73
+ scanBuffer ??= Buffer.alloc(CHUNK);
74
+ const buf = scanBuffer;
59
75
  let offset = 0;
60
76
  let carry = "";
61
77
  while (offset < CAP) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.37.16",
3
+ "version": "0.37.18",
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",