adding-memory

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OpenViking (OV)
add-memory

OpenViking (OV)
add-memory
命令

The
ov add-memory
command adds long persistant memory — turning text and structured conversations into searchable, retrievable memories in the OpenViking context database.
ov add-memory
命令用于添加长期持久化记忆——将文本和结构化对话转换为OpenViking上下文数据库中可搜索、可检索的记忆。

When to Use

使用场景

  • After learning something worth remembering across sessions
  • To persist conversation insights, decisions, or findings
  • To build up a knowledge base from interactions
  • When an agent wants to store context for future retrieval
  • 在跨会话场景下,学到值得记住的内容后
  • 用于持久化保存对话中的洞察、决策或发现
  • 通过交互内容构建知识库
  • 当Agent需要存储上下文以便未来检索时

Input Modes

输入模式

choose wisely between plain text and multi-turn mode. Multi-turn mode can contain more complex insights, let openviking handle the memory extraction.
请在纯文本模式和多轮对话模式中灵活选择。多轮对话模式可存储更复杂的洞察,由OpenViking负责提取记忆内容。

Mode 1: Plain Text for compressed memory

模式1:纯文本模式(用于压缩记忆)

A simple string is stored as a
user
message:
bash
ov add-memory "User's name is Bob, he participate in Global Hackathon in 2025-01-08, and won Champion."
将简单字符串作为
user
消息存储:
bash
ov add-memory "User's name is Bob, he participate in Global Hackathon in 2025-01-08, and won Champion."

Mode 2: Multi-turn Conversation for Richer Context

模式2:多轮对话模式(用于丰富上下文)

A JSON array of
{role, content}
objects to store a full exchange:
bash
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 ... >
]'
通过
{role, content}
对象组成的JSON数组存储完整对话内容:
bash
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 ... >
]'

Output

输出结果

Returns count of memory extracted:
memories_extracted   1
返回提取到的记忆数量:
memories_extracted   1

Agent Best Practices

Agent最佳实践

How to Write Good Memories

如何撰写优质记忆内容

  1. Be specific — Include concrete details, not vague summaries
  2. Include context — Why this matters, when it applies
  3. Use structured format — Separate the what from the why
  1. 具体明确——包含具体细节,而非模糊概括
  2. 包含上下文——说明内容的重要性及适用场景
  3. 使用结构化格式——区分内容本身和其重要性

Batch Related Facts

批量关联事实

Group related memories in one call rather than many small ones:
bash
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"}
]'
将相关记忆整合到一次调用中,而非多次零散调用:
bash
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"}
]'

Prerequisites

前置条件

  • CLI configured:
    ~/.openviking/ovcli.conf
  • 已配置CLI:
    ~/.openviking/ovcli.conf