Merge pull request #115 from continuedev/dont-be-chatty
Add headless mode support to system message construction
This commit is contained in:
commit
e3bb327b5a
4 changed files with 38 additions and 3 deletions
|
|
@ -72,7 +72,8 @@ export async function initializeChatHistory(
|
|||
const systemMessage = await constructSystemMessage(
|
||||
rulesSystemMessage,
|
||||
options.rule,
|
||||
options.format
|
||||
options.format,
|
||||
options.headless
|
||||
);
|
||||
if (systemMessage) {
|
||||
chatHistory.push({ role: "system", content: systemMessage });
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ export async function serve(prompt?: string, options: ServeOptions = {}) {
|
|||
|
||||
// Initialize chat history
|
||||
let chatHistory: ChatCompletionMessageParam[] = [];
|
||||
const systemMessage = await constructSystemMessage("", options.rule);
|
||||
const systemMessage = await constructSystemMessage("", options.rule, undefined, true);
|
||||
if (systemMessage) {
|
||||
chatHistory.push({ role: "system", content: systemMessage });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,4 +101,29 @@ Rule 3: Third rule`;
|
|||
expect(result).toContain("AGENTS.md");
|
||||
expect(result).toContain("</context>");
|
||||
});
|
||||
|
||||
it("should add headless mode instructions when headless is true", async () => {
|
||||
const result = await constructSystemMessage("", undefined, undefined, true);
|
||||
|
||||
expect(result).toContain("You are an agent in the Continue CLI");
|
||||
expect(result).toContain("IMPORTANT: You are running in headless mode");
|
||||
expect(result).toContain("Provide ONLY your final answer");
|
||||
expect(result).toContain("Do not include explanations, reasoning, or additional commentary");
|
||||
});
|
||||
|
||||
it("should not add headless mode instructions when headless is false", async () => {
|
||||
const result = await constructSystemMessage("", undefined, undefined, false);
|
||||
|
||||
expect(result).toContain("You are an agent in the Continue CLI");
|
||||
expect(result).not.toContain("IMPORTANT: You are running in headless mode");
|
||||
expect(result).not.toContain("Provide ONLY your final answer");
|
||||
});
|
||||
|
||||
it("should not add headless mode instructions when headless is undefined", async () => {
|
||||
const result = await constructSystemMessage("");
|
||||
|
||||
expect(result).toContain("You are an agent in the Continue CLI");
|
||||
expect(result).not.toContain("IMPORTANT: You are running in headless mode");
|
||||
expect(result).not.toContain("Provide ONLY your final answer");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -98,12 +98,14 @@ ${getGitStatus()}
|
|||
* @param rulesSystemMessage - The rules system message from the assistant
|
||||
* @param additionalRules - Additional rules from --rule flags
|
||||
* @param format - Output format for headless mode
|
||||
* @param headless - Whether running in headless mode
|
||||
* @returns The comprehensive system message with base message and rules section
|
||||
*/
|
||||
export async function constructSystemMessage(
|
||||
rulesSystemMessage: string,
|
||||
additionalRules?: string[],
|
||||
format?: "json"
|
||||
format?: "json",
|
||||
headless?: boolean
|
||||
): Promise<string> {
|
||||
const agentFiles = ["AGENTS.md", "AGENT.md", "CLAUDE.md", "CODEX.md"];
|
||||
|
||||
|
|
@ -141,6 +143,13 @@ export async function constructSystemMessage(
|
|||
// Construct the comprehensive system message
|
||||
let systemMessage = baseSystemMessage;
|
||||
|
||||
// In headless mode, add instructions to be concise and only provide final answers
|
||||
if (headless) {
|
||||
systemMessage += `
|
||||
|
||||
IMPORTANT: You are running in headless mode. Provide ONLY your final answer to the user's question. Do not include explanations, reasoning, or additional commentary unless specifically requested. Be direct and concise.`;
|
||||
}
|
||||
|
||||
// Add JSON formatting instructions if format is json
|
||||
if (format === "json") {
|
||||
systemMessage += `
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue