diff --git a/src/auto-reply/command-reply.test.ts b/src/auto-reply/command-reply.test.ts index d7887826d..98461fd82 100644 --- a/src/auto-reply/command-reply.test.ts +++ b/src/auto-reply/command-reply.test.ts @@ -91,6 +91,29 @@ describe("runCommandReply", () => { expect(finalArgv.at(-1)).toContain("You are Clawd (Claude)"); }); + it("omits identity prefix on resumed session 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: false, + isFirstTurnInSession: false, + systemSent: true, + timeoutMs: 1000, + timeoutSeconds: 1, + commandRunner: runner, + enqueue: enqueueImmediate, + }); + const finalArgv = captures[0].argv as string[]; + expect(finalArgv.at(-1)).not.toContain("You are Clawd (Claude)"); + }); + it("picks session resume args when not new", async () => { const captures: ReplyPayload[] = []; const runner = makeRunner({ stdout: "hi" }, captures); diff --git a/src/auto-reply/command-reply.ts b/src/auto-reply/command-reply.ts index d5f2e586b..914f25d96 100644 --- a/src/auto-reply/command-reply.ts +++ b/src/auto-reply/command-reply.ts @@ -179,7 +179,9 @@ export async function runCommandReply( let finalArgv = argv; const isClaudeInvocation = finalArgv.length > 0 && path.basename(finalArgv[0]) === CLAUDE_BIN; - if (isClaudeInvocation && finalArgv.length > 0) { + const shouldPrependIdentity = + isClaudeInvocation && !(sendSystemOnce && systemSent); + if (shouldPrependIdentity && finalArgv.length > 0) { const bodyIdx = finalArgv.length - 1; const existingBody = finalArgv[bodyIdx] ?? ""; finalArgv = [