fix: add reasoning tag hint for local providers
parent
42f1a56832
commit
b05981ef27
|
|
@ -333,12 +333,15 @@ export async function runEmbeddedPiAgent(params: {
|
||||||
node: process.version,
|
node: process.version,
|
||||||
model: `${provider}/${modelId}`,
|
model: `${provider}/${modelId}`,
|
||||||
};
|
};
|
||||||
|
const reasoningTagHint =
|
||||||
|
provider === "lmstudio" || provider === "ollama";
|
||||||
const systemPrompt = buildSystemPrompt({
|
const systemPrompt = buildSystemPrompt({
|
||||||
appendPrompt: buildAgentSystemPromptAppend({
|
appendPrompt: buildAgentSystemPromptAppend({
|
||||||
workspaceDir: resolvedWorkspace,
|
workspaceDir: resolvedWorkspace,
|
||||||
defaultThinkLevel: params.thinkLevel,
|
defaultThinkLevel: params.thinkLevel,
|
||||||
extraSystemPrompt: params.extraSystemPrompt,
|
extraSystemPrompt: params.extraSystemPrompt,
|
||||||
ownerNumbers: params.ownerNumbers,
|
ownerNumbers: params.ownerNumbers,
|
||||||
|
reasoningTagHint,
|
||||||
runtimeInfo,
|
runtimeInfo,
|
||||||
}),
|
}),
|
||||||
contextFiles,
|
contextFiles,
|
||||||
|
|
|
||||||
|
|
@ -22,4 +22,14 @@ describe("buildAgentSystemPromptAppend", () => {
|
||||||
expect(prompt).not.toContain("## User Identity");
|
expect(prompt).not.toContain("## User Identity");
|
||||||
expect(prompt).not.toContain("Owner numbers:");
|
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;
|
defaultThinkLevel?: ThinkLevel;
|
||||||
extraSystemPrompt?: string;
|
extraSystemPrompt?: string;
|
||||||
ownerNumbers?: string[];
|
ownerNumbers?: string[];
|
||||||
|
reasoningTagHint?: boolean;
|
||||||
runtimeInfo?: {
|
runtimeInfo?: {
|
||||||
host?: string;
|
host?: string;
|
||||||
os?: string;
|
os?: string;
|
||||||
|
|
@ -26,6 +27,9 @@ export function buildAgentSystemPromptAppend(params: {
|
||||||
ownerNumbers.length > 0
|
ownerNumbers.length > 0
|
||||||
? `Owner numbers: ${ownerNumbers.join(", ")}. Treat messages from these numbers as the user (Peter).`
|
? `Owner numbers: ${ownerNumbers.join(", ")}. Treat messages from these numbers as the user (Peter).`
|
||||||
: undefined;
|
: 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 runtimeInfo = params.runtimeInfo;
|
||||||
const runtimeLines: string[] = [];
|
const runtimeLines: string[] = [];
|
||||||
if (runtimeInfo?.host) runtimeLines.push(`Host: ${runtimeInfo.host}`);
|
if (runtimeInfo?.host) runtimeLines.push(`Host: ${runtimeInfo.host}`);
|
||||||
|
|
@ -72,6 +76,9 @@ export function buildAgentSystemPromptAppend(params: {
|
||||||
if (extraSystemPrompt) {
|
if (extraSystemPrompt) {
|
||||||
lines.push("## Group Chat Context", extraSystemPrompt, "");
|
lines.push("## Group Chat Context", extraSystemPrompt, "");
|
||||||
}
|
}
|
||||||
|
if (reasoningHint) {
|
||||||
|
lines.push("## Reasoning Format", reasoningHint, "");
|
||||||
|
}
|
||||||
|
|
||||||
lines.push(
|
lines.push(
|
||||||
"## Heartbeats",
|
"## Heartbeats",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue