fix: explicitly forbid extra frontmatter fields in output format instruction
buildOutputFormatInstruction now includes explicit language telling agents to output ONLY schema-defined fields and to focus on their role's deliverable. Fixes #394
This commit is contained in:
@@ -141,6 +141,28 @@ describe("buildOutputFormatInstruction", () => {
|
|||||||
expect(result).toContain("shared: <string> # required");
|
expect(result).toContain("shared: <string> # required");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("explicitly forbids extra frontmatter fields", () => {
|
||||||
|
const result = buildOutputFormatInstruction(PLANNER_SCHEMA);
|
||||||
|
expect(result).toMatch(/\b(only|exclusively)\b.*fields/i);
|
||||||
|
expect(result).toMatch(/do not add (extra|additional|other) fields/i);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("forbids extra fields even for empty schema", () => {
|
||||||
|
const result = buildOutputFormatInstruction({});
|
||||||
|
expect(result).toMatch(/do not add (extra|additional|other) fields/i);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("forbids extra fields for anyOf/oneOf schemas", () => {
|
||||||
|
const schema = {
|
||||||
|
anyOf: [
|
||||||
|
{ type: "object", properties: { alpha: { type: "string" } } },
|
||||||
|
{ type: "object", properties: { beta: { type: "number" } } },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
const result = buildOutputFormatInstruction(schema);
|
||||||
|
expect(result).toMatch(/do not add (extra|additional|other) fields/i);
|
||||||
|
});
|
||||||
|
|
||||||
test("includes focus reminder about role scope", () => {
|
test("includes focus reminder about role scope", () => {
|
||||||
const result = buildOutputFormatInstruction({});
|
const result = buildOutputFormatInstruction({});
|
||||||
expect(result).toContain("Focus exclusively on YOUR role");
|
expect(result).toContain("Focus exclusively on YOUR role");
|
||||||
|
|||||||
@@ -191,5 +191,7 @@ Your meta output must satisfy these fields:
|
|||||||
|
|
||||||
${fieldList}
|
${fieldList}
|
||||||
|
|
||||||
|
Output ONLY the fields listed above. Do not add extra fields that are not specified in the schema.
|
||||||
|
|
||||||
Focus exclusively on YOUR role's deliverable. Do not perform actions outside your role's scope.`;
|
Focus exclusively on YOUR role's deliverable. Do not perform actions outside your role's scope.`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user