Tiptap Editor 3.0 Beta is out. Start here

Configure the AI Agent's tools

Tools are the building blocks of the AI Agent. They define the actions that the AI model can take to interact with its environment. This includes: reading/editing the document, searching external data sources, and planning the work.

Although the AI Agent extension provides a set of built-in tools, you can also define custom tools to extend the AI Agent's capabilities.

Built-in tools

read_first_chunk

Starts reading the current document from the beginning.

read_next_chunk

Reads the next chunk of the document.

read_previous_chunk

Reads the previous chunk of the document.

apply_diff

This is the main tool the AI Agent has for making changes to the document. It applies a list of diffs to the document. Each diff contains:

  • The content before the change, used to locate the place to edit.
  • The content to delete
  • The content to insert

replace_document

Replaces the entire document with new content.

plan

Plans the work to be done. It generates a list of steps in Markdown format.

ask_user

Asks the user a question.

finish_with_summary

Marks the task as completed, and provides a summary in Markdown format.

Customize built-in tools

You can remove or replace the built-in tools by configuring the AiAgentToolkit instance.

import {
  AiAgentToolkit,
  planTool,
  askUserTool,
  readFirstChunkTool,
  readNextChunkTool,
  readPreviousChunkTool,
  replaceDocumentTool,
  finishWithSummaryTool,
  applyDiffTool,
} from '@tiptap-pro/extension-ai-agent-server'

const toolkit = new AiAgentToolkit({
  tools: [
    // These are all the built-in tools. Remove or replace them as needed.
    planTool(),
    askUserTool(),
    readFirstChunkTool(),
    readNextChunkTool(),
    readPreviousChunkTool(),
    replaceDocumentTool(),
    finishWithSummaryTool(),
    applyDiffTool(),
  ],
})

Custom tools

Besides the built-in tools, you can define additional tools. There are two types of custom tools:

  • Client-side tools run in the client. They interact with the editor's content. For example: a tool that counts the number of words in the document, or a tool that formats the document. All built-in tools are client-side tools.
  • Server-side tools run in the server. They interact with external data sources. For example: a tool that searches the web, or a tool that queries a database.