Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 1.03 KB

types.md

File metadata and controls

26 lines (21 loc) · 1.03 KB

Specifying types

We use Zod under the hood to enforce typed responses from the agent. You can use this to enforce predictable output for your application.

For example, in the example repository we include the following in extensions/schema.ts:

export const CustomSchema = ModelResponseSchema(ObjectiveComplete.extend({
  restaurants: z.array(
    z.string().optional().describe("The name of a restaurant")
)}));

In this example, we inform the agent that we expect the response that reports a completed objective to also include an array of restaurants. When we finally get ObjectiveComplete back from the agent as an answer, we will also see restaurants as part of the response:

// inside the event response from the server, under `{ result: {...} }`
type ObjectiveCompleteResult = {
  description: string;
  objectiveComplete: {
    kind: "ObjectiveComplete";
    restaurants: string[];
    result: string;
  }
};