UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

48 lines (47 loc) • 2.42 kB
//#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(question, inFlightPrompt) { const lines = ["Answer this side question only.", "Ignore any unfinished task in the conversation while answering it."]; const trimmedPrompt = inFlightPrompt?.trim(); if (trimmedPrompt) lines.push("", "Current in-flight main task request for background context only:", "<in_flight_main_task>", trimmedPrompt, "</in_flight_main_task>", "Do not continue or complete that task while answering the side question."); lines.push("", "<btw_side_question>", question.trim(), "</btw_side_question>"); return lines.join("\n"); } function collectBtwMessageText(content) { if (typeof content === "string") return content.trim(); if (!Array.isArray(content)) return ""; return content.flatMap((part) => { if (part.type === "text") return part.text; if (part.type === "image") return "[Image content omitted from CLI side-question context.]"; return []; }).join("\n").trim(); } function buildBtwCliPrompt(params) { const lines = [ "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 message of params.messages) { const text = collectBtwMessageText(message.content); if (!text) continue; lines.push(`${message.role === "assistant" ? "Assistant" : "User"}:`, text, ""); } lines.push("</conversation_history>", ""); lines.push(buildBtwQuestionPrompt(params.question, params.inFlightPrompt)); if (params.imageCount > 0) lines.push(`[${params.imageCount} attached image(s) omitted from CLI side-question input.]`); return lines.join("\n"); } //#endregion export { buildBtwQuestionPrompt as n, buildBtwSystemPrompt as r, buildBtwCliPrompt as t };