A tool is a typed function an agent can call. It declares input, describes when to use it, and runs server-side code.
Prerequisites
- A Veryfront project running locally (see Create project).
- An agent that will call the tool, or an API route that invokes the tool directly (see Agents and API routes).
defineSchemais available fromveryfront/schemas.
Define a tool
Create a file in tools/:
import { defineSchema } from "veryfront/schemas";import { tool } from "veryfront/tool"; export default tool({ description: "Get the current weather for a city", inputSchema: defineSchema((v) => v.object({ city: v.string().describe("City name"), units: v.enum(["celsius", "fahrenheit"]).default("celsius") .describe("Temperature unit"), }) )(), execute: async ({ city, units }) => { const temperature = units === "fahrenheit" ? 72 : 22; return { city, temperature, units, conditions: "sunny" }; },});The filename becomes the tool's ID. tools/get-weather.ts registers as getWeather.
Platform and project tool names
For project agents running in Veryfront Cloud, select platform tools with the
reserved veryfront__ prefix, for example veryfront__bash or
veryfront__get_file. Project tools keep their local IDs. An agent can select
both platform veryfront__bash and a project tool named bash:
import { agent } from "veryfront/agent"; export default agent({ system: "Use veryfront__bash for shell commands and bash for the project action.", tools: { veryfront__bash: true, bash: true },});Use canonical platform selectors such as veryfront__get_file.
Integration tools retain names such as github__list_repos. Project tool IDs
cannot use the reserved double-underscore namespace. Platform tools retain their project scope and policy restrictions.
Connector allowlists do not remove trusted platform capabilities. That exception requires host-owned provenance; a remote source cannot claim it with a tool name or source ID. Hosted wrappers and child forks preserve provenance.
Managed executor installations carry broker-derived platform source and host-tool metadata, then restore provenance on the executor-local facades. Reserved platform names resolve only through trusted sources, regardless of custom server ordering. Hosted discovery applies connector policy to the same catalog snapshot it lists, without fetching each catalog a second time.
Parent, child, hosted-project, and standalone API sources publish only canonical
veryfront__ names from the authenticated catalog. Bare transport names are
normalized internally and do not create duplicate tool definitions. Internal
policy checks recognize both spellings; an explicit tool-name ceiling remains
restrictive. Host-provided platform tools also publish one canonical identity.
Runtime dispatch reuses the source selected during authorization for that call.
Code-owned platform dependencies
A project tool can call a platform operation from its implementation without
exposing that operation to the model. Declare the exact canonical operations in
delegatedPlatformTools:
import { tool } from "veryfront/tool"; export default tool({ id: "save-note", description: "Save the prepared note", inputSchema: { type: "object", properties: {}, additionalProperties: false }, delegatedPlatformTools: ["veryfront__create_file"], execute: async (_input, context) => { if (!context?.executePlatformTool) throw new Error("Hosted tool authority is required"); return await context.executePlatformTool("veryfront__create_file", { project_reference: context.projectId, path: "notes/prepared.txt", content: "Prepared note", }); },});Veryfront resolves declarations from selected project tool source and seals the
map for the admitted run. Explicit platform denials still apply. Each wrapper
can call only its own declared operations while that invocation remains active.
Tool identity and platform dependency declarations are immutable after construction
or registration. Create a new tool definition to change them.
A copied callback, another run, or a settled invocation cannot reuse authority.
The API still verifies project access, integration bindings and operation policy.
This contract applies to API-dispatched project agent runs and their
control-plane-dispatched children, including default hosted forks admitted with
their own authenticated child writer credential. Generic local agentAsTool
execution does not establish this capability. Child runs receive their own
source declarations; they do not inherit the parent's map. Hosted dependency
authority requires the operator writer key and service identity captured at
process startup; a custom authentication verifier cannot grant this authority.
The declaration and callback never contain authentication tokens.
Try a tool directly
Agents usually invoke tools, but direct execution is useful for testing and for API routes that expose a specific action:
import getWeather from "../../../tools/get-weather.ts"; export async function GET(request: Request) { const city = new URL(request.url).searchParams.get("city") ?? "Tokyo"; const result = await getWeather.execute({ city, units: "celsius" }); return Response.json(result);}Run the dev server and call the route:
curl "http://localhost:3000/api/weather?city=Tokyo"Use this pattern to verify the tool contract before giving the tool to an agent.
How agents use tools
An explicit tool map authorizes only the selected tools and sends those schemas
to the model immediately. Use tools: true for a broad authorized scope. The
framework initially sends only the veryfront__load_skill bootstrap schema when it is
authorized, plus veryfront__tool_search, then loads matching schemas for the next model
step. veryfront__form_input is authorized but deferred until it is needed. Omit tools
to expose no project tools. Search results contain names and descriptions, not
input or output schemas.
import { agent } from "veryfront/agent"; export default agent({ system: "You are a weather assistant. Use the getWeather tool to answer weather questions.", tools: true, maxSteps: 3,});Use an explicit map such as tools: { getWeather: true } when the model needs a
selected schema on its first step. Schema loading and tool authorization stay
separate, and execution rechecks authorization.
veryfront__tool_search accepts exactly one of four mode fields. All arguments are
top-level strings or integers:
schema: "<exact name>"returns one exact tool's input schema and loads it for the next model step.search: "<phrase>"finds tools by a short capability phrase without loading schemas.inventory: "all" | "platform"browses tool metadata pages.platformlists only Veryfront platform tools. The inventory-only fieldsdomainandresourcematch a tool'sdiscoverymetadata exactly, andcursorandlimitpage through results.query: "<name or phrase>"searches and loads matching schemas for the next model step.
Search uses deterministic, case-insensitive matching. It treats underscores as spaces and ranks results in this order:
- Exact tool name.
- Tool name substring.
- Tool description substring.
- Input parameter description substring.
An exact canonical integration query such as gmail__list_emails never loads a
sibling action when that action is unavailable. It can return an authorized
catalog reader with integration guidance, or report a miss.
Equal-rank matches use ASCII tool-name order. Each search returns at most five matches. Results contain the tool name, description, and loading status, but no input or output schema. The search tool has no page or pagination parameter. Refine the query when the required tool is not in the first five matches. For multi-term queries, search suppresses filler that only matches a query's least selective term unless the candidate also matches a more selective term or every query term.
Search work is bounded to 4,096 catalog candidates. Each parameter schema is inspected iteratively with depth, node, and byte budgets, and the whole search has an aggregate schema-work budget. A malformed, cyclic, or over-budget schema cannot abort the search; that tool cannot match by parameter description. Name and description matching remains available for other healthy tools.
The search loads schemas from the current authorized tools catalog. It also
loads configured providerTools that the selected model supports. A
provider-native search entry contains only its name and description. The
runtime attaches the provider's native schema on the next model step and never
executes it as a local tool.
The runtime reapplies the current authorization policy, configured provider tools, and model support before execution and checkpoint restoration, so a previously loaded name cannot restore a removed permission.
Deferred loading works with direct provider model strings and provider API keys. Veryfront Cloud is not required for that path. Hosted durable execution uses the same framework search, but it requires the Veryfront API durable run-event contract. Before the next model step, the hosted runtime persists a private loaded-tool checkpoint. It fails the continuation if required persistence is unavailable, and it excludes the checkpoint from public messages and replay.
Omit model to use the Cloud default (mistral/mistral-small-2503) with hosted
context, or openai/gpt-5-nano with direct credentials. Set
model: "auto" when you want runtime defaults to choose local or Veryfront
Cloud inference automatically.
When a user asks "What's the weather in Tokyo?", an agent with tools: true:
- Sends the question with
veryfront__tool_searchto the model. - The model searches for a weather capability.
- The framework loads the matching authorized
getWeatherschema. - The next model step calls
getWeather({ city: "Tokyo" }). - The tool returns
{ temperature: 22, conditions: "sunny" }. - The model formats a natural language response.
Tool surfaces in agent config
Agent config separates tools by execution boundary:
Use tools for functions you define in the project. Do not add provider-native
tools or skill loader tools to tools.
Use providerTools for provider-executed capabilities. In deferred mode,
veryfront__tool_search can load a configured capability when the selected model supports
it:
import { agent } from "veryfront/agent"; export default agent({ id: "researcher", system: "Research current information before answering.", providerTools: ["web_search"],});For veryfront-cloud/* models, the served catalogue for your project and
credential determines which provider tools are available. Configuring a tool
cannot grant it when the selected deployment omits it. Before the catalogue
loads, or when its tool declaration is missing, no provider tools are offered.
The gateway remains responsible for enforcing policy before dispatch. Read its served web-tool data-flow facts for processing recipients and boundary coverage; inference residency alone does not approve web search or fetch.
Direct provider models, such as anthropic/* and openai/*, use the runtime's
implemented provider tools and your own endpoint configuration. Running offline
or self-hosting does not bypass catalogue checks for a veryfront-cloud/* model.
Use mcpServers for remote MCP tools. Put remote visibility policy on the MCP
server. When tools is an explicit object, also list the remote tool name in
tools so the model can use it.
When mcpServers is omitted, explicitly named tools that are not local are
resolved from the Veryfront API MCP server if server bootstrap credentials are
available. This makes a project pulled from Studio runnable locally without
duplicating transport configuration.
export default agent({ id: "project-reader", system: "Use project evidence when answering.", tools: { veryfront__get_file: true, veryfront__list_files: true },});VERYFRONT_API_URL selects the endpoint, while VERYFRONT_API_TOKEN and
VERYFRONT_PROJECT_SLUG provide server-side identity. Environment variables
never grant tools: only explicitly named unresolved tools are requested, and
the remote tools/list response defines their schemas. Use mcpServers: []
to opt out, or declare { kind: "veryfront-api", toolPolicy: ... } to make the
connection policy explicit. Direct application routes and hosted runtimes do
not accept browser-supplied credentials or project identity for this server.
import { agent } from "veryfront/agent"; export default agent({ id: "docs", system: "Use the docs server when the user asks about internal docs.", tools: { search_docs: true }, mcpServers: [ { id: "docs", transport: { type: "http", url: "https://docs.example.com/mcp", }, auth: { type: "bearer", token: () => process.env.DOCS_MCP_TOKEN ?? "", }, toolPolicy: { allow: ["search_docs"], approval: "never", }, }, ],});Tool configuration
Writing good descriptions
The description field is what the model reads to decide when to call your tool. Be specific, and use .describe() on schema fields to help the model understand what to pass:
import { defineSchema } from "veryfront/schemas"; export default tool({ description: "Search the product catalog by name, category, or price range", inputSchema: defineSchema((v) => v.object({ query: v.string().min(1).describe("Search term"), category: v.string().optional().describe("Product category filter"), maxPrice: v.number().optional().describe("Maximum price in USD"), }) )(), execute: async ({ query, category, maxPrice }) => {/* ... */},});Returning errors
Throw from execute to signal an error. The agent sees the error message and can retry or respond accordingly:
import { defineSchema } from "veryfront/schemas"; export default tool({ description: "Look up a user by email", inputSchema: defineSchema((v) => v.object({ email: v.string().email().describe("User email address"), }) )(), execute: async ({ email }) => { const user = await db.users.findByEmail(email); if (!user) throw new Error(`No user found with email ${email}`); return { id: user.id, name: user.name }; },});Tools with context
The execute function receives an optional second argument with runtime context:
import { defineSchema } from "veryfront/schemas"; export default tool({ description: "List repos for the current account", inputSchema: defineSchema((v) => v.object({ sort: v.enum(["created", "updated"]).default("updated") .describe("Repository sort order"), }) )(), execute: async ({ sort }, context) => { const accountId = typeof context?.accountId === "string" ? context.accountId : "anonymous"; return await fetchRepos(accountId, { sort }); },});Pass context from the API route:
import { createAgUiHandler } from "veryfront/agent"; export const POST = createAgUiHandler("assistant", { context: { accountId: "account-123", },});Inline tools
For one-off tools that don't need auto-discovery, define them inline:
import { agent } from "veryfront/agent";import { defineSchema } from "veryfront/schemas";import { tool } from "veryfront/tool"; export default agent({ system: "You are a math tutor.", tools: { calculate: tool({ description: "Evaluate a math expression", inputSchema: defineSchema((v) => v.object({ expression: v.string().describe("Math expression to evaluate"), }) )(), execute: async ({ expression }) => ({ result: evaluateMathExpression(expression), }), }), },});evaluateMathExpression is your own validated math evaluator. Avoid passing
free-form input into eval() or Function().
Verify it worked
Restart veryfront dev after creating the tool file. To run the tool by
itself, expose a small debug API route:
import { toolRegistry } from "veryfront/tool"; export async function POST(request: Request) { const { name, input } = await request.json(); const result = await toolRegistry.get(name)?.execute(input); return Response.json(result);}curl -X POST http://localhost:3000/api/debug/tools \ -H "Content-Type: application/json" \ -H "Cookie: __Host-vf_csrf=local-check" \ -H "x-csrf-token: local-check" \ -d '{"name":"getWeather","input":{"city":"Berlin"}}'A working tool returns the JSON your execute function produced. Remove the
debug route before deploying.