fix: add reasoning tag hint for local providers
This commit is contained in:
@@ -333,12 +333,15 @@ export async function runEmbeddedPiAgent(params: {
|
||||
node: process.version,
|
||||
model: `${provider}/${modelId}`,
|
||||
};
|
||||
const reasoningTagHint =
|
||||
provider === "lmstudio" || provider === "ollama";
|
||||
const systemPrompt = buildSystemPrompt({
|
||||
appendPrompt: buildAgentSystemPromptAppend({
|
||||
workspaceDir: resolvedWorkspace,
|
||||
defaultThinkLevel: params.thinkLevel,
|
||||
extraSystemPrompt: params.extraSystemPrompt,
|
||||
ownerNumbers: params.ownerNumbers,
|
||||
reasoningTagHint,
|
||||
runtimeInfo,
|
||||
}),
|
||||
contextFiles,
|
||||
|
||||
@@ -22,4 +22,14 @@ describe("buildAgentSystemPromptAppend", () => {
|
||||
expect(prompt).not.toContain("## User Identity");
|
||||
expect(prompt).not.toContain("Owner numbers:");
|
||||
});
|
||||
|
||||
it("adds reasoning tag hint when enabled", () => {
|
||||
const prompt = buildAgentSystemPromptAppend({
|
||||
workspaceDir: "/tmp/clawd",
|
||||
reasoningTagHint: true,
|
||||
});
|
||||
|
||||
expect(prompt).toContain("## Reasoning Format");
|
||||
expect(prompt).toContain("<think>...</think>");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@ export function buildAgentSystemPromptAppend(params: {
|
||||
defaultThinkLevel?: ThinkLevel;
|
||||
extraSystemPrompt?: string;
|
||||
ownerNumbers?: string[];
|
||||
reasoningTagHint?: boolean;
|
||||
runtimeInfo?: {
|
||||
host?: string;
|
||||
os?: string;
|
||||
@@ -26,6 +27,9 @@ export function buildAgentSystemPromptAppend(params: {
|
||||
ownerNumbers.length > 0
|
||||
? `Owner numbers: ${ownerNumbers.join(", ")}. Treat messages from these numbers as the user (Peter).`
|
||||
: undefined;
|
||||
const reasoningHint = params.reasoningTagHint
|
||||
? "If you must think, put all reasoning inside <think>...</think> only, and never include analysis outside those tags."
|
||||
: undefined;
|
||||
const runtimeInfo = params.runtimeInfo;
|
||||
const runtimeLines: string[] = [];
|
||||
if (runtimeInfo?.host) runtimeLines.push(`Host: ${runtimeInfo.host}`);
|
||||
@@ -72,6 +76,9 @@ export function buildAgentSystemPromptAppend(params: {
|
||||
if (extraSystemPrompt) {
|
||||
lines.push("## Group Chat Context", extraSystemPrompt, "");
|
||||
}
|
||||
if (reasoningHint) {
|
||||
lines.push("## Reasoning Format", reasoningHint, "");
|
||||
}
|
||||
|
||||
lines.push(
|
||||
"## Heartbeats",
|
||||
|
||||
Reference in New Issue
Block a user