---
title: "可用方法"
description: "了解 AI Agent 提供程序中的可用方法。"
canonical_url: "https://tiptap.zhcndoc.com/content-ai/capabilities/agent/features/methods"
---

# 可用方法

了解 AI Agent 提供程序中的可用方法。

AI Agent 提供程序暴露了若干方法。

## 核心方法

| 方法                              | 描述                                                                                                     | 参数                              |
| ------------------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------- |
| `run()`                         | 启动一个新的 AI Agent [生命周期](https://tiptap.zhcndoc.com/content-ai/capabilities/agent/features/lifecycle.md) | 无                               |
| `stop()`                        | 停止当前 AI Agent 生命周期                                                                                     | 无                               |
| `reset(chatMessages?)`          | 重置 AI Agent 提供程序至初始状态                                                                                  | `chatMessages?`：`ChatMessage[]` |
| `setSystemPrompt(systemPrompt)` | 设置 [系统提示](https://tiptap.zhcndoc.com/content-ai/capabilities/agent/configure/system-prompt.md)         | `systemPrompt`：`string \| null` |

## 会话管理

| 方法                                  | 描述                                                                                                                  | 参数                                                    |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| `addUserMessage(message, options?)` | 向会话中添加一条用户消息                                                                                                        | `message`：`string`，`options?`：`AddUserMessageOptions` |
| `addChatMessages(messages)`         | 向会话中添加多条聊天消息                                                                                                        | `messages`：`ChatMessage[]`                            |
| `setChatMessages(messages)`         | 替换会话中的所有消息                                                                                                          | `messages`：`ChatMessage[]`                            |
| `setAutoAccept(autoAccept)`         | 更改 [自动接受](https://tiptap.zhcndoc.com/content-ai/capabilities/agent/features/review.md#auto-accept-configuration) 设置 | `autoAccept`：`"always" \| "never" \| "onlyRead"`      |
| `setCheckpoint()`                   | 将当前状态保存为一个[检查点](https://tiptap.zhcndoc.com/content-ai/capabilities/agent/features/checkpoints.md)                   | 无                                                     |
| `restoreCheckpoint(checkpoint)`     | 恢复之前保存的检查点                                                                                                          | `checkpoint`：`Checkpoint`                             |

## 工具调用审核

| 方法                 | 描述         | 参数 |
| ------------------ | ---------- | -- |
| `acceptToolCall()` | 接受待处理的工具调用 | 无  |
| `rejectToolCall()` | 拒绝待处理的工具调用 | 无  |
