fix: todos scan task ballooned to 2.5MB and analysis produced no output
The todos pre-scan walked .output/ (Nitro) and .vercel/ (Vercel) build dirs, flagging 119 of 124 candidates inside minified bundles (single lines up to 162KB). buildTodosScanTask embedded full candidate lines in the task prompt, producing a 2.5MB prompt on freno-dev; the analysis agent settled with ok:true + empty text + no findings.md, verify failed, and resume re-ran the same oversized prompt and failed identically. - scope: exclude .output/.vercel/.netlify (shared by all checks) - todos: truncate candidate code at 160 chars in the prompt + fallback - agent-runner: a session settling with no text and no observed message/ tool events now fails the run loudly instead of reporting ok:true - agent prompts: add the three dirs to each skip list - tests: excluded-dir scan, prompt truncation, emptySessionError cases
This commit is contained in:
@@ -10,12 +10,13 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import {
|
||||
applySessionEvent,
|
||||
emptySessionError,
|
||||
type SessionEventAccumulator,
|
||||
} from "../src/agent-runner.js";
|
||||
import type { AgentSessionEvent } from "@earendil-works/pi-coding-agent";
|
||||
|
||||
function fresh(): SessionEventAccumulator {
|
||||
return { text: "" };
|
||||
return { text: "", sawMessage: false };
|
||||
}
|
||||
|
||||
/** Build a typed-as-unknown event so malformed shapes compile in tests. */
|
||||
@@ -134,4 +135,54 @@ describe("applySessionEvent", () => {
|
||||
expect(forwarded).toEqual([]);
|
||||
expect(acc.text).toBe("x");
|
||||
});
|
||||
|
||||
it("marks sawMessage when any message or tool event is observed", () => {
|
||||
const fromUpdate = fresh();
|
||||
applySessionEvent(fromUpdate, event({ type: "message_update" }));
|
||||
expect(fromUpdate.sawMessage).toBe(true);
|
||||
|
||||
const fromEnd = fresh();
|
||||
applySessionEvent(fromEnd, event({ type: "message_end", message: null }));
|
||||
expect(fromEnd.sawMessage).toBe(true);
|
||||
|
||||
const fromTool = fresh();
|
||||
applySessionEvent(fromTool, event({ type: "tool_execution_start" }));
|
||||
expect(fromTool.sawMessage).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("emptySessionError", () => {
|
||||
it("fails a session that settled with no text and no observed events", () => {
|
||||
expect(emptySessionError({ text: "", sawMessage: false })).toContain(
|
||||
"no output",
|
||||
);
|
||||
});
|
||||
|
||||
it("fails an empty session whose final message reported stopReason error", () => {
|
||||
expect(
|
||||
emptySessionError({ text: "", sawMessage: true, stopReason: "error" }),
|
||||
).toBe("sub-agent session ended in error with no output.");
|
||||
});
|
||||
|
||||
it("surfaces a recorded errorMessage regardless of text", () => {
|
||||
expect(
|
||||
emptySessionError({
|
||||
text: "partial output",
|
||||
sawMessage: true,
|
||||
errorMessage: "upstream 529",
|
||||
}),
|
||||
).toBe("upstream 529");
|
||||
});
|
||||
|
||||
it("accepts an empty-text session that demonstrably ran (tool activity)", () => {
|
||||
expect(
|
||||
emptySessionError({ text: "", sawMessage: true, stopReason: "end_turn" }),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("accepts any session with text", () => {
|
||||
expect(
|
||||
emptySessionError({ text: "report", sawMessage: false }),
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user