Give an agent a tool: a typed function it can call, which says what it needs and when to use it, and runs on the server.
Before you start
You need an agent. See Create an agent.
Add a tool
- Create the tool. Its
idis how agents name it:tools/get-time.tsimport { tool } from "veryfront/tool"; export default tool({ id: "get-time", description: "Get the current time in a time zone, such as Asia/Tokyo.", inputSchema: { type: "object", properties: { timeZone: { type: "string", description: "An IANA time zone, such as Asia/Tokyo" }, }, required: ["timeZone"], additionalProperties: false, }, execute: async ({ timeZone }) => ({ time: new Date().toLocaleString("en-GB", { timeZone, dateStyle: "full", timeStyle: "short" }), }),}); - Add it to your agent's
tools. An agent uses only the tools it lists:agents/support.tsimport { agent } from "veryfront/agent"; export default agent({ id: "support", name: "Support assistant", system: "Answer customer questions about orders and refunds. Keep replies to two sentences.", tools: { "get-time": true },}); - Start the project with
npm run dev. - Open Chat in Studio.
- Pick Support assistant.
- Ask "What time is it in Tokyo?". You should now see it call
get-timeand reply with the time in Tokyo.
Try it in a sandbox
Create a project
Create the tool
Add it to your agent
Start it
Ask it