Skip to content

Commit 7d4ef07

Browse files
committed
fix: handle unclosed yaml code fence from small models (0.6.3)
Small/local models (e.g. qwen via ollama) sometimes emit ```yaml without a closing ```, causing the raw fence marker to be saved into the workflow file. Added fallback regex to strip it.
1 parent 73dc8cf commit 7d4ef07

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "agency-orchestrator",
3-
"version": "0.6.2",
3+
"version": "0.6.3",
44
"description": "Multi-agent YAML workflow engine — 211 AI roles, auto DAG parallelism, zero code. One sentence → multiple AI roles collaborate → complete plan in minutes. 10 LLM providers, 7 need no API key.",
55
"keywords": [
66
"multi-agent",

src/cli/compose.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ export function extractYamlFromResponse(response: string): string {
292292
const codeBlock = response.match(/```\s*\n([\s\S]*?)```/);
293293
if (codeBlock) return codeBlock[1].trim();
294294

295+
// 小模型可能只有开头的 ``` 没有闭合,兜底去掉
296+
const unclosed = response.match(/```ya?ml?\s*\n([\s\S]+)/);
297+
if (unclosed) return unclosed[1].trim().replace(/```\s*$/, '').trim();
298+
295299
// 没有代码块,整个回复当 YAML
296300
return response.trim();
297301
}

test/compose.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ test('多个代码块时取第一个 yaml 块', () => {
6767
assert(!yaml.includes('second'), '不应包含第二个代码块');
6868
});
6969

70+
test('未闭合的 ```yaml 代码块(小模型兜底)', () => {
71+
const response = '```yaml\nname: "test"\nsteps:\n - id: s1\n role: "engineering/engineering-senior-developer"';
72+
const yaml = extractYamlFromResponse(response);
73+
assert(yaml.includes('name: "test"'), '应提取内容');
74+
assert(!yaml.includes('```'), '不应包含代码块标记');
75+
});
76+
7077
// ─── formatCatalogForPrompt ───
7178

7279
console.log('\n─── formatCatalogForPrompt ───');

0 commit comments

Comments
 (0)