fix: 1.1.45 第二轮发送不再因 undefined.length 直接死掉。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-10-02 02:21:39 +08:00
1 parent 6f50df28f3
commit 11aa390cc3
5 files changed
+81 -62

No files matched your search

+51
View File
@@ -3699,6 +3699,57 @@ const NEW_TOOL_PATCHES = [
],
markers: ["[dsh-purge] system prompt replaces the first node"],
},
{
id: 66,
name: "SYSTEM_PROMPT_RENDER_GUARD",
layer: "代码",
layer_en: "Code",
desc: "renderPrompt 对 undefined section.text 兜底,避免第二轮 gateway/internal / guard undefined section text in renderPrompt",
file: ["system-prompt", "system-prompt-nested"],
replacements: [
{
pattern:
"function renderPrompt(assembly) {\n" +
'\treturn assembly.sections.map((section) => section.interpolate === false ? section.text : interpolate(section, assembly.variables, "section")).filter((text) => text.length > 0).join("\\n\\n");\n' +
"}",
replace:
"function renderPrompt(assembly) {\n" +
'\treturn assembly.sections.map((section) => section.interpolate === false ? section.text : interpolate(section, assembly.variables, "section")).filter((text) => typeof text === "string" && text.length > 0).join("\\n\\n"); // [dsh-purge] guard undefined section text\n' +
"}",
},
{
pattern: "function interpolate(input, variables, kind) {\n\tconst text = input.text;",
replace:
"function interpolate(input, variables, kind) {\n" +
'\tconst text = typeof input.text === "string" ? input.text : ""; // [dsh-purge] guard undefined section text',
},
{
pattern: "})).filter((section) => section.text.length > 0);",
replace:
'})).filter((section) => typeof section.text === "string" && section.text.length > 0); // [dsh-purge] guard undefined section text',
},
],
markers: ["[dsh-purge] guard undefined section text"],
},
{
id: 67,
name: "AGENT_LOOP_MESSAGES_GUARD",
layer: "代码",
layer_en: "Code",
desc: "decision.messages 缺省时按空数组处理,避免第二轮 gateway/internal / treat missing decision.messages as empty",
file: ["agent-loop"],
replacements: [
{
pattern:
"\t\t\t\tif (turnEnds && decision.messages.length === 0) break;\n" +
"\t\t\t\tif (phase.step === 0 && decision.messages.length === 0) {\n",
replace:
"\t\t\t\tif (turnEnds && (decision.messages?.length ?? 0) === 0) break; // [dsh-purge] guard undefined messages\n" +
"\t\t\t\tif (phase.step === 0 && (decision.messages?.length ?? 0) === 0) { // [dsh-purge] guard undefined messages\n",
},
],
markers: ["[dsh-purge] guard undefined messages"],
},
{
id: 56,
name: "REWIND_HIDE_CUT_ONLY",