const middleware = createMiddleware({
name: "auth",
contextSchema: z.object({ userId: z.string() }),
});
const agent = createAgent({
model: "gpt-4",
tools: [],
contextSchema: z.object({ sessionId: z.string() }),
middleware: [middleware],
});
type Context = InferAgentContext<typeof agent>;
// { sessionId: string; userId: string }
Helper type to infer the full merged context from an agent, including:
contextSchema)This matches the context type available throughout the agent runtime.