Handle object-shaped changed sections

This commit is contained in:
Codex
2026-06-21 23:43:03 +08:00
parent adf844f752
commit 5a627bcaa8
2 changed files with 75 additions and 1 deletions
@@ -4,6 +4,7 @@ import {
articleInputSchema,
confirmedFactCardSchema,
candidateFactCardSchema,
optimizedArticleSchema,
qaReportSchema,
} from "../validation";
@@ -144,4 +145,23 @@ describe("domain validation", () => {
}),
).toThrow();
});
it("normalizes object-shaped changed sections from LLM output", () => {
const parsed = optimizedArticleSchema.parse({
title: "Optimized article",
summary: "Summary constrained by the confirmed fact card.",
body_markdown: "## Body\nUpdated body.",
image_suggestions: [],
changed_sections: [
{ section: "title", change: "Improved keyword clarity." },
{ name: "body", reason: "Fixed sentence flow." },
],
requires_user_confirmation: [],
});
expect(parsed.changed_sections).toEqual([
"title: Improved keyword clarity.",
"body: Fixed sentence flow.",
]);
});
});