openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
47 lines (46 loc) • 2.17 kB
JavaScript
//#region src/agents/btw-prompts.ts
function buildBtwSystemPrompt() {
return [
"You are answering an ephemeral /btw side question about the current conversation.",
"Use the conversation only as background context.",
"Answer only the side question in the last user message.",
"Do not continue, resume, or complete any unfinished task from the conversation.",
"Do not emit tool calls, pseudo-tool calls, shell commands, file writes, patches, or code unless the side question explicitly asks for them.",
"Do not say you will continue the main task after answering.",
"If the question can be answered briefly, answer briefly."
].join("\n");
}
function buildBtwQuestionPrompt(e, t) {
const n = ["Answer this side question only.", "Ignore any unfinished task in the conversation while answering it."];
const r = t?.trim();
if (r) n.push("", "Current in-flight main task request for background context only:", "<in_flight_main_task>", r, "</in_flight_main_task>", "Do not continue or complete that task while answering the side question.");
n.push("", "<btw_side_question>", e.trim(), "</btw_side_question>");
return n.join("\n");
}
function collectBtwMessageText(e) {
if (typeof e === "string") return e.trim();
return e.flatMap((e) => {
if (e.type === "text") return e.text;
if (e.type === "image") return "[Image content omitted from CLI side-question context.]";
return [];
}).join("\n").trim();
}
function buildBtwCliPrompt(e) {
const t = [
"Use this sanitized conversation history as background context only.",
"Do not continue, resume, or complete any unfinished task from the conversation.",
"",
"<conversation_history>"
];
for (const n of e.messages) {
const e = collectBtwMessageText(n.content);
if (!e) continue;
t.push(`${n.role === "assistant" ? "Assistant" : "User"}:`, e, "");
}
t.push("</conversation_history>", "");
t.push(buildBtwQuestionPrompt(e.question, e.inFlightPrompt));
if (e.imageCount > 0) t.push(`[${e.imageCount} attached image(s) omitted from CLI side-question input.]`);
return t.join("\n");
}
//#endregion
export { buildBtwQuestionPrompt as n, buildBtwSystemPrompt as r, buildBtwCliPrompt as t };