fix: inject group activation in system prompt

This commit is contained in:
Peter Steinberger
2025-12-23 13:32:07 +00:00
parent 96d57a18ee
commit cba12a1abd
7 changed files with 81 additions and 7 deletions

View File

@@ -267,6 +267,7 @@ export async function runEmbeddedPiAgent(params: {
data: Record<string, unknown>;
}) => void;
enqueue?: typeof enqueueCommand;
extraSystemPrompt?: string;
}): Promise<EmbeddedPiRunResult> {
const enqueue = params.enqueue ?? enqueueCommand;
return enqueue(async () => {
@@ -326,6 +327,7 @@ export async function runEmbeddedPiAgent(params: {
appendPrompt: buildAgentSystemPromptAppend({
workspaceDir: resolvedWorkspace,
defaultThinkLevel: params.thinkLevel,
extraSystemPrompt: params.extraSystemPrompt,
}),
contextFiles,
skills: promptSkills,

View File

@@ -3,13 +3,16 @@ import type { ThinkLevel } from "../auto-reply/thinking.js";
export function buildAgentSystemPromptAppend(params: {
workspaceDir: string;
defaultThinkLevel?: ThinkLevel;
extraSystemPrompt?: string;
}) {
const thinkHint =
params.defaultThinkLevel && params.defaultThinkLevel !== "off"
? `Default thinking level: ${params.defaultThinkLevel}.`
: "Default thinking level: off.";
return [
const extraSystemPrompt = params.extraSystemPrompt?.trim();
const lines = [
"You are Clawd, a personal assistant running inside Clawdis.",
"",
"## Tooling",
@@ -35,6 +38,13 @@ export function buildAgentSystemPromptAppend(params: {
"Never send streaming/partial replies to external messaging surfaces; only final replies should be delivered there.",
"Clawdis handles message transport automatically; respond normally and your reply will be delivered to the current chat.",
"",
];
if (extraSystemPrompt) {
lines.push("## Group Chat Context", extraSystemPrompt, "");
}
lines.push(
"## Heartbeats",
'If you receive a heartbeat poll (a user message containing just "HEARTBEAT"), and there is nothing that needs attention, reply exactly:',
"HEARTBEAT_OK",
@@ -42,7 +52,9 @@ export function buildAgentSystemPromptAppend(params: {
"",
"## Runtime",
thinkHint,
]
);
return lines
.filter(Boolean)
.join("\n");
}