Handoff examples
Runnable file: agentium-examples/handoff/agent-handoff.ts. Guide: Handoff1. Front desk → specialist
frontDesk. The specialist sees the same thread.Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Front desk agent transfers the chat to billing or tech. Context comes along.
import { Agent, openai, defineTool } from "@agentium/core";
import { z } from "zod";
const billingAgent = new Agent({
name: "billing",
model: openai("gpt-4o-mini"),
instructions: "You handle invoices and payments. Be precise with numbers.",
tools: [
defineTool({
name: "get_invoice",
description: "Look up an invoice",
parameters: z.object({ userId: z.string() }),
execute: async ({ userId }) => `Invoice for ${userId}: $49.99/month`,
}),
],
});
const techAgent = new Agent({
name: "tech-support",
model: openai("gpt-4o-mini"),
instructions: "You debug and configure. Be concrete.",
});
const frontDesk = new Agent({
name: "front-desk",
model: openai("gpt-4o"),
instructions: `Greet the user.
Billing or payment → transfer to billing.
Bugs or setup → transfer to tech-support.
Otherwise answer yourself.`,
handoff: {
targets: [
{ agent: billingAgent, description: "Billing, invoices, payments" },
{ agent: techAgent, description: "Technical support, debugging" },
],
maxHandoffs: 3,
},
});
await frontDesk.run("My last invoice looks wrong.", { userId: "u-1" });
frontDesk. The specialist sees the same thread.