diff --git a/apps/web/src/services/ai/orchestrator-sub-agent.ts b/apps/web/src/services/ai/orchestrator-sub-agent.ts index 35b5a0079..db0656ef7 100644 --- a/apps/web/src/services/ai/orchestrator-sub-agent.ts +++ b/apps/web/src/services/ai/orchestrator-sub-agent.ts @@ -451,6 +451,23 @@ async function executeSubAgent( reducedComplexity, ); + // When element tools are enabled, the ELEMENT_TOOL_OUTPUT_FORMAT block + // (appended below) is the authoritative output-format instruction — + // teaching the model to emit `` tags. The jsonl-format / + // jsonl-format-simplified skills lead with a CRITICAL directive saying + // "Output ONLY ```json … Do NOT use tool calls", which directly conflicts + // with `` and confuses weak models (MiniMax / GLM / Kimi): + // they anchor on the front-of-prompt CRITICAL and emit raw JSONL, + // bypassing every element tool — which defeats the entire point of the + // n-tools-per-element design (stability for weak models in the built-in + // sub-agent path). Drop those two skills here so ELEMENT_TOOL_OUTPUT_FORMAT + // is the only output-format instruction the model sees. + if (elementToolsEnabled) { + resolvedSkills = resolvedSkills.filter( + (s) => s.meta.name !== 'jsonl-format' && s.meta.name !== 'jsonl-format-simplified', + ); + } + const skillPrompt = resolvedSkills.map((s) => s.content).join('\n\n'); const systemPrompt = elementToolsEnabled ? skillPrompt + '\n\n' + ELEMENT_TOOL_OUTPUT_FORMAT diff --git a/packages/pen-ai-skills/skills/phases/generation/elements.md b/packages/pen-ai-skills/skills/phases/generation/elements.md index e2d143437..5be1229f0 100644 --- a/packages/pen-ai-skills/skills/phases/generation/elements.md +++ b/packages/pen-ai-skills/skills/phases/generation/elements.md @@ -10,14 +10,16 @@ category: base ---