MCPcopy Create free account
hub / github.com/coder/mux / buildSideQuestionMessages

Function buildSideQuestionMessages

src/node/services/sideQuestionService.ts:102–143  ·  view source on GitHub ↗
(
  question: string,
  transcript: string
)

Source from the content-addressed store, hash-verified

100 * conversation-grounded" contract.
101 */
102export function buildSideQuestionMessages(
103 question: string,
104 transcript: string
105): { system: string; messages: ModelMessage[] } {
106 const trimmedQuestion = question.trim();
107 const renderedTranscript = transcript.trim().length > 0 ? transcript : "(empty transcript)";
108
109 const system = [
110 "You are answering a quick side question about an ongoing AI coding chat.",
111 "This is a forked, single-turn branch. Your answer will be appended to the",
112 "chat as a clearly-marked side answer so the user can re-read it later,",
113 "but no follow-up turn is possible on this branch.",
114 "",
115 "Rules:",
116 "- Answer directly from the conversation context provided below.",
117 "- No tools are available on this turn. Do not pretend to call tools,",
118 " do not emit tool-call JSON, and do not promise future actions.",
119 "- If the conversation does not contain enough information to answer,",
120 " say so plainly instead of guessing or fabricating details.",
121 "- Keep the answer concise and use markdown when it improves clarity.",
122 ].join("\n");
123
124 const userPrompt = [
125 "Current conversation (oldest first, newest last):",
126 "<conversation>",
127 renderedTranscript,
128 "</conversation>",
129 "",
130 "<system-reminder>",
131 "The user just asked a side question (/btw). Answer directly using the",
132 "conversation above. No tools are available. This is a one-shot response;",
133 "no follow-up turn will reach you.",
134 "</system-reminder>",
135 "",
136 `Side question: ${trimmedQuestion}`,
137 ].join("\n");
138
139 return {
140 system,
141 messages: [{ role: "user", content: userPrompt }],
142 };
143}
144
145/**
146 * Run a /btw side question. Persists the user question, streams the answer,

Callers 2

askSideQuestionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected