Harden runtime debug and task pipeline

This commit is contained in:
Youzini-afk
2026-03-27 01:26:56 +08:00
parent b20e8dbb44
commit c31af1d1a4
17 changed files with 1750 additions and 238 deletions

View File

@@ -11,7 +11,7 @@ import {
getNodeEdges,
} from "./graph.js";
import { callLLMForJSON } from "./llm.js";
import { buildTaskPrompt } from "./prompt-builder.js";
import { buildTaskExecutionDebugContext, buildTaskPrompt } from "./prompt-builder.js";
import { applyTaskRegex } from "./task-regex.js";
import { getSTContextForPrompt } from "./st-context.js";
import { findSimilarNodesByText, validateVectorConfig } from "./vector-index.js";
@@ -22,6 +22,12 @@ function createAbortError(message = "操作已终止") {
return error;
}
function createTaskLlmDebugContext(promptBuild, regexInput) {
return typeof buildTaskExecutionDebugContext === "function"
? buildTaskExecutionDebugContext(promptBuild, { regexInput })
: null;
}
function isAbortError(error) {
return error?.name === "AbortError";
}
@@ -428,6 +434,7 @@ async function llmRecall(
graphStats: `candidate_count=${candidates.length}`,
...getSTContextForPrompt(),
});
const recallRegexInput = { entries: [] };
const systemPrompt = applyTaskRegex(
settings,
"recall",
@@ -440,6 +447,8 @@ async function llmRecall(
"输出严格的 JSON 格式:",
'{"selected_ids": ["id1", "id2", ...], "reason": "简要说明选择理由"}',
].join("\n"),
recallRegexInput,
"system",
);
const userPrompt = [
@@ -461,6 +470,10 @@ async function llmRecall(
maxRetries: 1,
signal,
taskType: "recall",
debugContext: createTaskLlmDebugContext(
recallPromptBuild,
recallRegexInput,
),
additionalMessages:
recallPromptBuild.privateTaskMessages || [
...(recallPromptBuild.customMessages || []),