agent: use Effect schema for generated agent object (#26973)

This commit is contained in:
Kit Langton 2026-05-11 21:42:04 -04:00 committed by GitHub
parent 1007630347
commit c43d606f8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,4 @@
import { Config } from "@/config/config"
import z from "zod"
import { Provider } from "@/provider/provider"
import { ModelID, ProviderID } from "../provider/schema"
import { generateObject, streamObject, type ModelMessage } from "ai"
@ -49,6 +48,12 @@ export const Info = Schema.Struct({
}).annotate({ identifier: "Agent" })
export type Info = DeepMutable<Schema.Schema.Type<typeof Info>>
const GeneratedAgent = Schema.Struct({
identifier: Schema.String,
whenToUse: Schema.String,
systemPrompt: Schema.String,
})
export interface Interface {
readonly get: (agent: string) => Effect.Effect<Info>
readonly list: () => Effect.Effect<Info[]>
@ -405,11 +410,10 @@ export const layer = Layer.effect(
},
],
model: language,
schema: z.object({
identifier: z.string(),
whenToUse: z.string(),
systemPrompt: z.string(),
}),
schema: Object.assign(
Schema.toStandardSchemaV1(GeneratedAgent),
Schema.toStandardJSONSchemaV1(GeneratedAgent),
),
} satisfies Parameters<typeof generateObject>[0]
if (isOpenaiOauth) {