As asked
Write a TypeScript tool definition for creating a support ticket, then explain how you would make the schema safe for agent use.
Sample answer outline
The schema should make required fields explicit, restrict enums, and avoid accepting vague free-form blobs for important state. Tool descriptions should say when to call the tool and when not to call it, but the server must still validate permissions and business rules. A good answer includes idempotency keys or deduplication because agents may retry after timeouts. The tool should return a small structured result the agent can reason over, not an entire database record. Candidates often make tools too broad, which increases accidental side effects and makes eval failures hard to diagnose.
Reference implementation (typescript)
import { z } from "zod";
export const createSupportTicketTool = {
name: "create_support_ticket",
description:
"Create one support ticket after the user has described a concrete problem. Do not call for general questions.",
inputSchema: z.object({
customerId: z.string().min(1),
idempotencyKey: z.string().uuid(),
severity: z.enum(["low", "normal", "high", "urgent"]),
subject: z.string().min(5).max(120),
description: z.string().min(20).max(4000),
orderId: z.string().optional(),
}),
async execute(input: unknown) {
const args = this.inputSchema.parse(input);
return {
ticketId: await createTicket(args),
status: "created" as const,
};
},
};Expect these follow-ups
- How do you version this tool without breaking old agents?
- Where does human approval fit?
- What should the tool return on validation failure?