diff --git a/packages/workflow-agent-kit/__tests__/build-output-format-instruction.test.ts b/packages/workflow-agent-kit/__tests__/build-output-format-instruction.test.ts index fad5030..c6b824c 100644 --- a/packages/workflow-agent-kit/__tests__/build-output-format-instruction.test.ts +++ b/packages/workflow-agent-kit/__tests__/build-output-format-instruction.test.ts @@ -141,6 +141,28 @@ describe("buildOutputFormatInstruction", () => { expect(result).toContain("shared: # 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", () => { const result = buildOutputFormatInstruction({}); expect(result).toContain("Focus exclusively on YOUR role"); diff --git a/packages/workflow-agent-kit/src/build-output-format-instruction.ts b/packages/workflow-agent-kit/src/build-output-format-instruction.ts index 52f4356..e286c6c 100644 --- a/packages/workflow-agent-kit/src/build-output-format-instruction.ts +++ b/packages/workflow-agent-kit/src/build-output-format-instruction.ts @@ -191,5 +191,7 @@ Your meta output must satisfy these fields: ${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.`; }