Tiptap Editor 3.0 Beta is out. Start here

Manage Checkpoints

Checkpoints are snapshots of the editor's content and conversation state at a specific point in time. They allow you to save the current state of the document and conversation, and restore it later if needed.

Setting a checkpoint

To create a checkpoint, use the setCheckpoint method:

const checkpointMessage = provider.setCheckpoint()

This method returns a checkpoint message that includes the current chat messages and editor content.

Restoring a checkpoint

To restore a previously saved checkpoint, use the restoreCheckpoint method:

provider.restoreCheckpoint(checkpointMessage.checkpoint)

This will revert the editor content and conversation messages to the point when the checkpoint was created.

Automatic checkpoints

You can configure the provider to automatically save checkpoints when the user sends a message:

const provider = new AiAgentProvider({
  // ...other options
  autoSaveCheckpoints: true,
})

When autoSaveCheckpoints is enabled, checkpoints are saved before a user message is sent and before a tool is called. To save a checkpoint at other times, you can call setCheckpoint manually.