> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cowagent.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# memory - 记忆与知识

> 搜索和读取长期记忆及知识库文件

记忆工具包含两个子工具：`memory_search`（搜索记忆）和 `memory_get`（读取记忆或知识文件）。

当 [知识库](/zh/knowledge) 功能开启时，这两个工具同时支持访问 `memory/` 和 `knowledge/` 目录下的文件。

## 依赖

无额外依赖，默认可用。由 Agent Core 的记忆系统管理。

## memory\_search

搜索历史记忆和知识库内容，支持关键词和向量混合检索。

| 参数      | 类型     | 必填 | 说明   |
| ------- | ------ | -- | ---- |
| `query` | string | 是  | 搜索查询 |

## memory\_get

读取特定记忆文件或知识库文件的内容。

| 参数           | 类型      | 必填 | 说明                                                                        |
| ------------ | ------- | -- | ------------------------------------------------------------------------- |
| `path`       | string  | 是  | 文件的相对路径（如 `MEMORY.md`、`memory/2026-01-01.md`、`knowledge/concepts/rag.md`） |
| `start_line` | integer | 否  | 起始行号                                                                      |
| `end_line`   | integer | 否  | 结束行号                                                                      |

## 工作方式

Agent 会在以下场景自动调用记忆工具：

* 用户分享重要信息时 → 存储到记忆
* 需要参考历史信息时 → 搜索相关记忆
* 对话达到一定长度时 → 提取摘要存储
* 讨论到专业知识时 → 检索知识库中的相关页面

<Note>
  当 `knowledge` 配置为 `false` 时，工具的描述和搜索范围会自动调整为仅包含记忆文件。
</Note>
