Add a tool

You want to add a new tool to a route and call it with full type safety. Here's how.

The code

import { z } from "zod"
 
export default z.object({
  tenant: z.string(),
  count: z.number().default(0),
})

Notes

  • No registration. Drop the file into tools/. Dawn discovers it on the next dawn typegen or dev-server reload.
  • Inline type on the input. Dawn's compiler pass reads the inline type from the function signature. Aliases imported from elsewhere are not extracted.
  • Plain JSON in, plain JSON out. Tool inputs and outputs cross the runtime boundary. No Date, no Map, no class instances.
  • agent routes don't call ctx.tools. The LLM picks tools by name once dawn build binds them. The example above uses a workflow route to show the typed call site.

Related