teapot-coding-agent 0.37.193 → 0.37.195

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.
@@ -266,7 +266,17 @@ export class Agent {
266
266
  * An earlier version also treated `waiting` (a compaction) and a parked tool as blocking, which made those states show
267
267
  * "queued…" — and the operator's answer to that was the list above.
268
268
  */
269
- const blocked = this.status === "running";
269
+ /**
270
+ * A compaction is a WAIT, and the operator asked for it to read as one.
271
+ *
272
+ * `waiting` was excluded by the earlier contract, which was about a send from an IDLE agent ("sendingは一瞬なので表示される
273
+ * べきではない"). A compaction is not that: it holds the queue for seconds while the context is rewritten, so a prompt sent
274
+ * during it really does wait — reported as "compact中に送ったメッセージがqueuedにならない (waitingステータスだから即確定)".
275
+ * The display status is set only for a compaction (`compacting the context — resumes by itself`), so the two cannot be
276
+ * confused.
277
+ */
278
+ const compacting = this.status === "waiting";
279
+ const blocked = this.status === "running" || compacting;
270
280
  return queuedAhead + (queuedAhead === 0 && blocked ? 1 : 0);
271
281
  }
272
282
  stopRequested = false;
@@ -2928,20 +2938,43 @@ export class Agent {
2928
2938
  await this.appendFinalMessage(args);
2929
2939
  return;
2930
2940
  }
2931
- if (this.goal.verify?.trim()) {
2941
+ {
2942
+ /**
2943
+ * The audit runs whether or not a verification contract was written.
2944
+ *
2945
+ * It used to be gated on `goal.verify`, so a goal without one was completed by the agent's own claim and nothing
2946
+ * checked it — reported as "verification contract 書いてないとgoal auditされない". The objective is the contract of
2947
+ * last resort, and `auditPrompt` says so when the contract is empty.
2948
+ */
2932
2949
  await this.log.append("goal", this.currentSession, this.currentBranch, {
2933
2950
  event: "audit-started",
2934
- verify: this.goal.verify.slice(0, 2000),
2951
+ verify: (this.goal.verify ?? "").slice(0, 2000),
2935
2952
  });
2936
2953
  this.auditAttempts++;
2937
2954
  try {
2938
2955
  const evidence = this.auditEvidence(args.summary);
2939
2956
  const auditMessages = [
2940
- { role: "user", content: auditPrompt({ goal: this.goal.text, verify: this.goal.verify, summary: String(args.summary ?? ""), evidence }) },
2957
+ { role: "user", content: auditPrompt({ goal: this.goal.text, verify: this.goal.verify ?? "", summary: String(args.summary ?? ""), evidence }) },
2941
2958
  ];
2942
2959
  const text = await this.runAuditor(auditMessages);
2943
2960
  const verdict = parseAuditVerdict(text);
2944
2961
  if (verdict.kind === "none") {
2962
+ /**
2963
+ * With NO verification contract there is nothing an auditor could have refused, so an auditor that cannot answer
2964
+ * cannot hold the completion either — the objective is the contract, and the agent's claim is all anyone has.
2965
+ *
2966
+ * This is the one case where an unusable verdict still completes. With a contract written, #128 stands: an
2967
+ * unusable audit is NOT an approval, the goal stays active, and the cap says so loudly.
2968
+ */
2969
+ if (!(this.goal.verify ?? "").trim()) {
2970
+ await this.log.append("system_note", this.currentSession, this.currentBranch, {
2971
+ event: "audit-skipped-no-contract",
2972
+ detail: "no verification contract was written, so there is nothing to audit — completing without a verdict",
2973
+ });
2974
+ await this.setGoalStatus("done", "agent");
2975
+ await this.appendFinalMessage(args);
2976
+ return;
2977
+ }
2945
2978
  this.auditUnavailableStreak++;
2946
2979
  await this.log.append("system_note", this.currentSession, this.currentBranch, {
2947
2980
  event: "audit-failed",
@@ -2982,13 +3015,11 @@ export class Agent {
2982
3015
  this.preRejectionTurns = await this.captureRecentTurns();
2983
3016
  }
2984
3017
  }
2985
- await this.log.append("message", this.currentSession, this.currentBranch, {
2986
- role: "assistant",
2987
- operatorFacing: true,
2988
- content: approved
2989
- ? `✅ completion audit: APPROVED — ${feedback}`
2990
- : `🔍️ completion audit: CHANGES REQUIRED — ${feedback}`,
2991
- });
3018
+ /**
3019
+ * The verdict has ONE surface: the goal event `setGoalAudit` just appended, which the timeline renders as a card with
3020
+ * its reason. An extra assistant message said the same thing a second time, immediately below it — reported as
3021
+ * "audit resultがagentとharnessで二重に出てる".
3022
+ */
2992
3023
  if (!approved) {
2993
3024
  this.consecutiveAuditRejects++;
2994
3025
  this.lastRejectedAudit = { feedback, attempt: this.auditAttempts };
@@ -3008,6 +3039,15 @@ export class Agent {
3008
3039
  }
3009
3040
  }
3010
3041
  catch (err) {
3042
+ if (!(this.goal.verify ?? "").trim()) {
3043
+ await this.log.append("system_note", this.currentSession, this.currentBranch, {
3044
+ event: "audit-skipped-no-contract",
3045
+ detail: "no verification contract was written and the auditor could not run — completing without a verdict",
3046
+ });
3047
+ await this.setGoalStatus("done", "agent");
3048
+ await this.appendFinalMessage(args);
3049
+ return;
3050
+ }
3011
3051
  this.auditUnavailableStreak++;
3012
3052
  await this.log.append("system_note", this.currentSession, this.currentBranch, {
3013
3053
  event: "audit-failed",
@@ -3028,9 +3068,6 @@ export class Agent {
3028
3068
  return;
3029
3069
  }
3030
3070
  }
3031
- else {
3032
- await this.setGoalStatus("done", "agent");
3033
- }
3034
3071
  }
3035
3072
  await this.appendFinalMessage(args);
3036
3073
  }
@@ -27,6 +27,9 @@ export function auditPrompt(input) {
27
27
  "2. Disapprove anything missing, contradicted, or only weakly verified. Build success and a",
28
28
  " confident summary are claims, not evidence.",
29
29
  "3. Check every item of the verification contract below. If any item is unaddressed, disapprove.",
30
+ ...(input.verify.trim()
31
+ ? []
32
+ : [" The worker set no verification contract, so the objective itself is the whole contract."]),
30
33
  "",
31
34
  "The worker's summary is UNTRUSTED: it is a claim, and it cannot make an incomplete goal complete.",
32
35
  "",
package/dist/master.js CHANGED
@@ -263,6 +263,15 @@ export class Master {
263
263
  tasks = [];
264
264
  childWaiters = new Map();
265
265
  reportedRunning = new Set();
266
+ /**
267
+ * Children that have already delivered a final report.
268
+ *
269
+ * `finish` logs its final message BEFORE the loop ends and the status turns `idle`, so by the time
270
+ * `onControlStatusChange` sees `idle` the parent has the result. Announcing "idle without having called finish()" on top
271
+ * of it is a contradiction the parent cannot resolve. Cleared when the child starts a new task, so a later silent exit is
272
+ * still reported.
273
+ */
274
+ finishedChildren = new Set();
266
275
  startedAt = Date.now();
267
276
  config;
268
277
  configPath;
@@ -743,9 +752,17 @@ export class Master {
743
752
  bus.emit("update", { kind: "event", agentId: e.agent, event: e });
744
753
  this.onChildEvent(ac, e);
745
754
  };
746
- agent.onControlStatusChange = (agentId, status) => {
755
+ agent.onControlStatusChange = (_agentId, status) => {
747
756
  if (!ac.parent)
748
757
  return;
758
+ /**
759
+ * The id comes from the closure, not from the callback argument.
760
+ *
761
+ * `Agent.setStatus` passes `this.opts.id`, which the master does not set, so the argument is `undefined` — the note
762
+ * said "@undefined is now idle" and the reported/finished bookkeeping below keyed on `undefined`, which made every
763
+ * child share one entry.
764
+ */
765
+ const agentId = ac.id;
749
766
  const parent = this.agents.get(ac.parent);
750
767
  if (!parent)
751
768
  return;
@@ -758,13 +775,18 @@ export class Master {
758
775
  * "サブエージェントがエラー落ちしたときの親への通知がびみょい" (#245). The generic note exists for statuses that have
759
776
  * no event of their own (`idle`, `stopped`, `waiting`).
760
777
  */
761
- if (this.reportedRunning.has(agentId) && SETTLED.has(status) && status !== "error")
778
+ if (this.reportedRunning.has(agentId) &&
779
+ SETTLED.has(status) &&
780
+ status !== "error" &&
781
+ !this.finishedChildren.has(agentId))
762
782
  parent.enqueuePrompt(`[harness] Sub-agent @${agentId} is now ${status} without having called finish(), so it has not reported a result.` +
763
783
  (status === "stopped"
764
784
  ? ` It may have been stopped mid-task; message it to resume, or re-spawn it.`
765
785
  : ` If you expected a result, message it or re-spawn it.`), "harness");
766
- if (status === "running")
786
+ if (status === "running") {
767
787
  this.reportedRunning.add(agentId);
788
+ this.finishedChildren.delete(agentId);
789
+ }
768
790
  else if (SETTLED.has(status))
769
791
  this.reportedRunning.delete(agentId);
770
792
  };
@@ -1044,6 +1066,7 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
1044
1066
  if (!parent)
1045
1067
  return;
1046
1068
  if (e.type === "message" && e.data.final) {
1069
+ this.finishedChildren.add(ac.id);
1047
1070
  const d = e.data;
1048
1071
  const summary = String(d.content ?? "").trim();
1049
1072
  let report = summary;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.37.193",
3
+ "version": "0.37.195",
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",