import { agent, tool } from "@highvelocity/sdk";
import { z } from "zod";
import { billing, helpdesk } from "../connectors";
const refund = tool({
name: "billing.refunds.create",
input: z.object({ chargeId: z.string(), amount: z.number().int() }),
run: ({ chargeId, amount }) =>
billing.refunds.create({ chargeId, amount }),
});
export default agent({
name: "refunds-agent",
model: "auto",
tools: [refund, billing.charges.list, helpdesk.tickets.reply],
});
import { guardrails } from "@highvelocity/sdk";
export default guardrails({
budget: { usdPerRun: 0.05, maxSteps: 12 },
scopes: ["billing:refund", "helpdesk:reply"],
approve: {
when: ({ tool, input }) =>
tool === "billing.refunds.create" && input.amount > 4000,
by: "team:support-leads",
timeout: "15m",
},
redact: ["card_number", "iban"],
});
import { memory } from "@highvelocity/sdk";
export const policies = memory.collection("policies", {
source: "notion://support/policies",
isolation: "tenant",
refresh: "hourly",
});
// Agents that use this memory must cite what they relied on.
export const instructions =
"Cite the policy section behind every decision.";
import { evals } from "@highvelocity/sdk";
import refunds from "../agents/refunds";
evals.suite("refunds", {
agent: refunds,
cases: "./cases/refunds/*.yaml",
expect: [
evals.resolved(),
evals.cites("policies"),
evals.costBelow(0.01),
],
passRate: 0.95, // fail the build below 95%
});