关于 adding-memory
这是用于 OpenViking 的技能,可将文本或多轮对话保存为持久记忆,供 Agent 在后续会话中检索。
主要功能
- 01保存纯文本记忆
- 02存储多轮对话
- 03从对话中提取记忆
- 04返回提取的记忆数量
适用场景
- 01保存决策和发现
- 02留存供后续检索的上下文
- 03从交互中构建知识库
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ volcengine/ openviking --skill adding-memory安装后在 Claude Code 中输入/adding-memory确认已加载。
详细介绍
OpenViking (OV) add-memory
ov add-memory 命令可添加长期持久记忆 —— 将文本和结构化对话转化为 OpenViking 上下文数据库中可搜索、可检索的记忆。
何时使用
- 在了解到值得跨会话记住的内容之后
- 用于持久化对话见解、决策或发现
- 用于从交互中积累知识库
- 当 Agent 想要存储上下文以供将来检索时
输入模式
在纯文本模式和多轮模式之间明智选择。多轮模式可包含更复杂的见解,让 openviking 处理记忆提取。
模式 1:用于压缩记忆的纯文本
简单字符串会作为 user 消息存储:
ov add-memory "User's name is Bob, he participate in Global Hackathon in 2025-01-08, and won Champion."
模式 2:用于更丰富上下文的多轮对话
由 {role, content} 对象组成的 JSON 数组,用于存储完整的交流:
ov add-memory '[
{"role": "user", "content": "I love traveling. Give me some options of Transport from Beijing to Shanghai."},
{"role": "assistant", "content": "You can use train, bus, or plane. Train is the fastest, but you need to book in advance. Bus is cheaper, but you need to wait. Plane is the most expensive, but you can get there any time of day."},
{"role": "user", "content": "I prefer train. I like sightseeing on the train. Can you give me the train schedule?"},
< ... more possible conversation about schedule and tickest need to be memorized ... >
]'
输出
返回提取的记忆数量:
memories_extracted 1
Agent 最佳实践
如何编写优质记忆
- 要具体 —— 包含具体细节,而不是模糊的概括
- 包含上下文 —— 说明为什么重要、何时适用
- 使用结构化格式 —— 将“是什么”与“为什么”分开
批量处理相关事实
在一次调用中分组相关记忆,而不是使用许多零散的小调用:
ov add-memory '[
{"role": "user", "content": "Key facts about the ov_cli Rust crate"},
{"role": "assistant", "content": "1. runs faster than python cli\n2. uses HttpClient to connect openviking server\n3. Output formatting supports table and JSON modes\n4. Config lives at ~/.openviking/ovcli.conf"}
]'
前提条件
- 已配置命令行:
~/.openviking/ovcli.conf
评论
支持 Markdown