Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

fix(mcp): report a command turn's unread file as unverified, not failed

Jack Rudenko2f1fcc27c3c8
diff --git a/packages/cli/src/pane/pane-session.integration.test.ts b/packages/cli/src/pane/pane-session.integration.test.ts
index a0e67b9b..21d0e0aa 100644
--- a/packages/cli/src/pane/pane-session.integration.test.ts
+++ b/packages/cli/src/pane/pane-session.integration.test.ts
@@ -429,6 +429,20 @@ describe.skipIf(!MAGMUX)(
);
});
+ describe.concurrent("command turns with a file", () => {
+ test(
+ "R3-M3: a command whose expansion never Reads the file → complete null + read_coverage_unverified, not prompt_not_read",
+ async () => {
+ const r = await start("answer", { initialPrompt: "/pear\nsecond line\nthird line" });
+ const snap = await finish(r);
+ expect(snap.state).toBe("COMPLETED");
+ expect(r.turns[0]?.delivery).toMatchObject({ mode: "command", complete: null });
+ expect(snap.anomalies).toContain("read_coverage_unverified");
+ },
+ T
+ );
+ });
+
describe.concurrent("panel commands", () => {
test(
"/cost opens a panel that writes no record: Esc at once, no turn, the next prompt is not held",
diff --git a/packages/cli/src/pane/pane-session.ts b/packages/cli/src/pane/pane-session.ts
index 2478679e..8a1e8854 100644
--- a/packages/cli/src/pane/pane-session.ts
+++ b/packages/cli/src/pane/pane-session.ts
@@ -1118,6 +1118,11 @@ export class PaneSessionImpl implements PaneSession, RegisteredPane {
private settledTurnOf(t: TurnView, decision: SettleDecision & { settled: true }): SettledTurn {
const d = this.currentDelivery;
+ // R3-M3: a file-carrying COMMAND turn hands its text to the command's own expansion,
+ // which may never Read the pointer file (directly or through a subagent). Zero Reads is
+ // then unverified coverage, not a failed read: complete null, never prompt_not_read.
+ const unverified = d?.mode === "command" && !!t.delivery && t.readCoverage.reads === 0;
+ if (unverified) this.anomaly("read_coverage_unverified");
return {
index: t.index,
// a local command's answer is its own stdout: it has no assistant message (path L)
@@ -1134,7 +1139,7 @@ export class PaneSessionImpl implements PaneSession, RegisteredPane {
mode: d && d.mode !== "refused" ? d.mode : "typed",
linesTotal: t.delivery ? t.delivery.lines : null,
linesRead: t.delivery ? t.readCoverage.linesReturned : null,
- complete: t.delivery ? t.readCoverage.complete : null,
+ complete: t.delivery && !unverified ? t.readCoverage.complete : null,
preambleBytes: t.preambleBytes,
},
};