refactor(core): migrate MessageV2.Format to Effect Schema (#23744)

This commit is contained in:
Kit Langton
2026-04-21 17:30:08 -04:00
committed by GitHub
parent 7933657135
commit 2ae64f426b
4 changed files with 103 additions and 28 deletions

View File

@@ -5,7 +5,7 @@ import { SessionID, MessageID } from "../../src/session/schema"
describe("structured-output.OutputFormat", () => {
test("parses text format", () => {
const result = MessageV2.Format.safeParse({ type: "text" })
const result = MessageV2.Format.zod.safeParse({ type: "text" })
expect(result.success).toBe(true)
if (result.success) {
expect(result.data.type).toBe("text")
@@ -13,7 +13,7 @@ describe("structured-output.OutputFormat", () => {
})
test("parses json_schema format with defaults", () => {
const result = MessageV2.Format.safeParse({
const result = MessageV2.Format.zod.safeParse({
type: "json_schema",
schema: { type: "object", properties: { name: { type: "string" } } },
})
@@ -27,7 +27,7 @@ describe("structured-output.OutputFormat", () => {
})
test("parses json_schema format with custom retryCount", () => {
const result = MessageV2.Format.safeParse({
const result = MessageV2.Format.zod.safeParse({
type: "json_schema",
schema: { type: "object" },
retryCount: 5,
@@ -39,17 +39,17 @@ describe("structured-output.OutputFormat", () => {
})
test("rejects invalid type", () => {
const result = MessageV2.Format.safeParse({ type: "invalid" })
const result = MessageV2.Format.zod.safeParse({ type: "invalid" })
expect(result.success).toBe(false)
})
test("rejects json_schema without schema", () => {
const result = MessageV2.Format.safeParse({ type: "json_schema" })
const result = MessageV2.Format.zod.safeParse({ type: "json_schema" })
expect(result.success).toBe(false)
})
test("rejects negative retryCount", () => {
const result = MessageV2.Format.safeParse({
const result = MessageV2.Format.zod.safeParse({
type: "json_schema",
schema: { type: "object" },
retryCount: -1,