import { Agent, openai, getTextContent } from "@radaros/core";
const agent = new Agent({
name: "assistant",
model: openai("gpt-4o"),
instructions: "You are a helpful assistant.",
hooks: {
beforeRun: async (ctx) => {
console.log(`[${ctx.runId}] Starting run`);
},
afterRun: async (ctx, output) => {
console.log(`[${ctx.runId}] Done: ${output.usage.totalTokens} tokens`);
},
},
guardrails: {
input: [
{
name: "non-empty",
validate: async (input) => {
const t = typeof input === "string" ? input : getTextContent(input);
if (!t.trim()) return { pass: false, reason: "Input is empty." };
return { pass: true };
},
},
],
},
});