const middleware = createMiddleware({
name: "counter",
stateSchema: z.object({ count: z.number() }),
});
const agent = createAgent({
model: "gpt-4",
tools: [],
stateSchema: z.object({ userId: z.string() }),
middleware: [middleware],
});
type State = InferAgentState<typeof agent>;
// { userId: string; count: number }
Helper type to infer the full merged state from an agent, including:
stateSchema)This matches the state type returned by
invokeand used throughout the agent.