From 93a103dde5f5ff25f22ba354ebe86607ed13fcc2 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 27 Nov 2025 04:40:03 +0100 Subject: [PATCH] Tests: cover identity prefix gating --- src/auto-reply/command-reply.test.ts | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/auto-reply/command-reply.test.ts b/src/auto-reply/command-reply.test.ts index 98461fd82..fb47c0414 100644 --- a/src/auto-reply/command-reply.test.ts +++ b/src/auto-reply/command-reply.test.ts @@ -114,6 +114,52 @@ describe("runCommandReply", () => { expect(finalArgv.at(-1)).not.toContain("You are Clawd (Claude)"); }); + it("prepends identity on first turn when sendSystemOnce=true", async () => { + const captures: ReplyPayload[] = []; + const runner = makeRunner({ stdout: "ok" }, captures); + await runCommandReply({ + reply: { + mode: "command", + command: ["claude", "{{Body}}"], + claudeOutputFormat: "json", + }, + templatingCtx: noopTemplateCtx, + sendSystemOnce: true, + isNewSession: true, + isFirstTurnInSession: true, + systemSent: false, + timeoutMs: 1000, + timeoutSeconds: 1, + commandRunner: runner, + enqueue: enqueueImmediate, + }); + const finalArgv = captures[0].argv as string[]; + expect(finalArgv.at(-1)).toContain("You are Clawd (Claude)"); + }); + + it("still prepends identity if resume session but systemSent=false", async () => { + const captures: ReplyPayload[] = []; + const runner = makeRunner({ stdout: "ok" }, captures); + await runCommandReply({ + reply: { + mode: "command", + command: ["claude", "{{Body}}"], + claudeOutputFormat: "json", + }, + templatingCtx: noopTemplateCtx, + sendSystemOnce: true, + isNewSession: false, + isFirstTurnInSession: false, + systemSent: false, + timeoutMs: 1000, + timeoutSeconds: 1, + commandRunner: runner, + enqueue: enqueueImmediate, + }); + const finalArgv = captures[0].argv as string[]; + expect(finalArgv.at(-1)).toContain("You are Clawd (Claude)"); + }); + it("picks session resume args when not new", async () => { const captures: ReplyPayload[] = []; const runner = makeRunner({ stdout: "hi" }, captures);