Docs
Tools

Tools

The built-in shared tools, their Zod schemas, and the needsApproval flag.

What a Tool Is

A tool is a tool() call from the Vercel AI SDK with three required fields. Input schemas are defined with Zod.

import { tool } from "ai";
import { z } from "zod";
 
export const myTool = tool({
  description:
    "What this tool does — the LLM reads this to decide when to call it",
  inputSchema: z.object({
    query: z.string().describe("The search query"),
  }),
  execute: async ({ query }) => {
    // Always return an object, never throw
    return { result: "..." };
  },
});

Every field in the Zod schema must have a .describe() string. The LLM uses these descriptions to fill in parameters. Without them, the model guesses — and guesses wrong.

The needsApproval Flag

Some tools are marked with needsApproval: true. When the ToolLoopAgent encounters one of these, it pauses execution and emits a tool-approval-request event instead of running the tool immediately.

The UI renders an approval UI. Once the user approves, the tool runs and the loop continues.

Currently only format_post uses this flag — the agent pauses and shows the user the generated outline before committing to writing the final post.

In the Workflow context, this same flag triggers an email to the team owner for out-of-band approval.

Factory Tools

Some tools need runtime context (team ID) and are exported as factory functions:

// Usage: buildGenerateImageTool(team.id)
export function buildGenerateImageTool(teamId: string) {
  return tool({
    description: "Generate an image using GPT Image",
    inputSchema: z.object({
      visualPrompt: z.string().describe("Detailed image description"),
    }),
    execute: async ({ visualPrompt }) => {
      // uses teamId to namespace Supabase storage path
    },
  });
}

Factory tools: buildGenerateImageTool(teamId), memoryTool(teamId).

Tool Reference

ToolFileDescriptionneedsApproval
web_searchTavily SDKSearch the web for current informationNo
web_extractTavily SDKExtract full content from a URLNo
generate_outlinegenerate-outline.tsStructure content into sections before writingNo
format_postformat-post.tsWrite the final formatted post from an approved outlineYes
generate_imagegenerate-image.tsGenerate an image via GPT ImageNo
generate_reel_scriptgenerate-reel-script.tsWrite a short-form video scriptNo
format_reelformat-reel.tsFinalize the reel package with caption, hashtags, scenesNo
generate_script_outlinegenerate-script-outline.tsStructure a long-form scriptNo
format_scriptformat-script.tsWrite a full long-form script with acts and timestampsNo
generate_thumbnail_conceptgenerate-thumbnail-concept.tsGenerate 3 thumbnail design conceptsNo
extract_receipt_dataextract-receipt-data.tsOCR a receipt image into structured line itemsNo
read_documentread-document.tsFetch and parse a PDF from a URLNo
analyze_legal_documentanalyze-legal-document.tsDeep risk and obligation analysis of a legal documentNo
send_analysis_emailsend-analysis-email.tsEmail an analysis result to a recipientNo
memorymemory-tool.tsRead, write, or search the team's persistent memoryNo

Tool Output Shape

Tools should always return an object, never throw. On failure:

execute: async ({ url }) => {
  try {
    // ...
  } catch (err) {
    return { error: "Failed to fetch document", details: String(err) };
  }
};

Returning { error: "..." } lets the agent surface the error in its response and decide whether to retry or inform the user.