diff --git a/CHANGELOG.md b/CHANGELOG.md index cd8b18851..dc119aa4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - Typing indicators now start only once a reply payload is produced (no "thinking" typing for silent runs). - WhatsApp group typing now starts immediately only when the bot is mentioned; otherwise it waits until real output exists. - Streamed `` segments are stripped before partial replies are emitted. +- System prompt now tags allowlisted owner numbers as the user identity to avoid mistaken “friend” assumptions. - Canvas defaults/A2UI auto-nav aligned; debug status overlay centered; redundant await removed in `CanvasManager`. - Gateway launchd loop fixed by removing redundant `kickstart -k`. - CLI now hints when Peekaboo is unauthorized. diff --git a/src/agents/pi-embedded-runner.ts b/src/agents/pi-embedded-runner.ts index a9d617501..c0360c139 100644 --- a/src/agents/pi-embedded-runner.ts +++ b/src/agents/pi-embedded-runner.ts @@ -269,6 +269,7 @@ export async function runEmbeddedPiAgent(params: { }) => void; enqueue?: typeof enqueueCommand; extraSystemPrompt?: string; + ownerNumbers?: string[]; }): Promise { const enqueue = params.enqueue ?? enqueueCommand; return enqueue(async () => { @@ -337,6 +338,7 @@ export async function runEmbeddedPiAgent(params: { workspaceDir: resolvedWorkspace, defaultThinkLevel: params.thinkLevel, extraSystemPrompt: params.extraSystemPrompt, + ownerNumbers: params.ownerNumbers, runtimeInfo, }), contextFiles, diff --git a/src/agents/system-prompt.ts b/src/agents/system-prompt.ts index fafe24220..683d77ef2 100644 --- a/src/agents/system-prompt.ts +++ b/src/agents/system-prompt.ts @@ -4,6 +4,7 @@ export function buildAgentSystemPromptAppend(params: { workspaceDir: string; defaultThinkLevel?: ThinkLevel; extraSystemPrompt?: string; + ownerNumbers?: string[]; runtimeInfo?: { host?: string; os?: string; @@ -18,6 +19,13 @@ export function buildAgentSystemPromptAppend(params: { : "Default thinking level: off."; const extraSystemPrompt = params.extraSystemPrompt?.trim(); + const ownerNumbers = (params.ownerNumbers ?? []) + .map((value) => value.trim()) + .filter(Boolean); + const ownerLine = + ownerNumbers.length > 0 + ? `Owner numbers: ${ownerNumbers.join(", ")}. Treat messages from these numbers as the user (Peter).` + : undefined; const runtimeInfo = params.runtimeInfo; const runtimeLines: string[] = []; if (runtimeInfo?.host) runtimeLines.push(`Host: ${runtimeInfo.host}`); @@ -49,6 +57,9 @@ export function buildAgentSystemPromptAppend(params: { `Your working directory is: ${params.workspaceDir}`, "Treat this directory as the single global workspace for file operations unless explicitly instructed otherwise.", "", + ownerLine ? "## User Identity" : "", + ownerLine ?? "", + ownerLine ? "" : "", "## Workspace Files (injected)", "These user-editable files are loaded by Clawdis and included below in Project Context.", "", diff --git a/src/auto-reply/reply.ts b/src/auto-reply/reply.ts index 98e5754be..e9242d85b 100644 --- a/src/auto-reply/reply.ts +++ b/src/auto-reply/reply.ts @@ -885,6 +885,7 @@ export async function getReplyFromConfig( skillsSnapshot, prompt: commandBody, extraSystemPrompt: groupIntro || undefined, + ownerNumbers: ownerList.length > 0 ? ownerList : undefined, provider, model, thinkLevel: resolvedThinkLevel,