Multiplayer agent harness for work.
Accept the prompted no-title sentinel without recording an error (#1378)
Regan Bell12eccde13f2d
diff --git a/src/harness/pi-harness.ts b/src/harness/pi-harness.tsindex c1d534412..3d30a764f 100644--- a/src/harness/pi-harness.ts+++ b/src/harness/pi-harness.ts@@ -394,9 +394,10 @@ const APPROVAL_SUMMARY_PROMPT = [const MAX_TITLE_CHARS = 60;-export function sanitizeTitle(out = ""): string {+export function sanitizeTitle(out = ""): string | undefined {let t = (out.trim().split("\n")[0] ?? "").trim();if (!t) throw new TitleRejected("empty", out);+ if (/^none$/i.test(out.trim())) return undefined;if (/^none$/i.test(t)) throw new TitleRejected("none", out);t = t.replace(/^(?:title|chat title)\s*[:-]\s*/i, "");t = t.replace(/^["'“”‘’`]+|["'“”‘’`]+$/g, "").trim();diff --git a/test/pi-harness-oneshot.test.ts b/test/pi-harness-oneshot.test.tsindex b6bc7319e..72cf5deb1 100644--- a/test/pi-harness-oneshot.test.ts+++ b/test/pi-harness-oneshot.test.ts@@ -293,6 +293,66 @@ test("Pi title generation rejects a reply-shaped answer with the rule that fired});});+test("Pi title generation accepts the prompted NONE sentinel without reporting a failure", async (t) => {+ const server = createServer((request, response) => {+ request.resume();+ request.on("end", () => {+ response.writeHead(200, { "content-type": "text/event-stream" });+ for (const event of [+ {+ type: "message_start",+ message: {+ id: "msg_title",+ type: "message",+ role: "assistant",+ model: "title-model",+ content: [],+ stop_reason: null,+ stop_sequence: null,+ usage: { input_tokens: 1, output_tokens: 0 },+ },+ },+ { type: "content_block_start", index: 0, content_block: { type: "text", text: "" } },+ { type: "content_block_delta", index: 0, delta: { type: "text_delta", text: " NONE\n" } },+ { type: "content_block_stop", index: 0 },+ {+ type: "message_delta",+ delta: { stop_reason: "end_turn", stop_sequence: null },+ usage: { output_tokens: 1 },+ },+ { type: "message_stop" },+ ]) {+ response.write(`event: ${event.type}\ndata: ${JSON.stringify(event)}\n\n`);+ }+ response.end();+ });+ });+ await new Promise<void>((resolve, reject) => {+ server.once("error", reject);+ server.listen(0, "127.0.0.1", resolve);+ });+ t.after(+ () =>+ new Promise<void>((resolve, reject) => {+ server.close((error) => (error ? reject(error) : resolve()));+ }),+ );+ const address = server.address();+ assert(address && typeof address !== "string");+ const harness = createPiHarness({+ defaultModelId: "claude-opus-4-8",+ titleModelId: "claude-haiku-4-5",+ modelGateway: {+ url: `http://127.0.0.1:${address.port}`,+ apiKey: "gateway-key",+ apiKeyHeader: "api-key",+ models: { "claude-haiku-4-5": "title-model" },+ },+ });++ assert.equal(await harness.models.generateTitle!("User:\nHello"), undefined);+});+test("piHarnessConfigOptions omits the optional fields when the config leaves them unset", () => {const opts = piHarnessConfigOptions(testConfig());for (const key of ["defaultModelId", "detectModelId", "titleModelId", "apiKey"] as const) {diff --git a/test/session-title.test.ts b/test/session-title.test.tsindex ba9a80885..645709a63 100644--- a/test/session-title.test.ts+++ b/test/session-title.test.ts@@ -201,7 +201,8 @@ test("sanitizeTitle rejects reply-shaped output and names the rule plus a samplerejects("Here's what I found in the logs", "reply_opener");rejects("**Fix** the thing", "markdown");rejects("# Fix the thing", "markdown");- rejects("NONE", "none");+ for (const sentinel of ["NONE", "none", " NONE\n"]) assert.equal(sanitizeTitle(sentinel), undefined);+ rejects("NONE\nexplanation", "none");rejects(" ", "empty");rejects('Title: "..."', "empty");rejects("", "empty");