Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/en/agent-integrations/04-codex.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Credential source: env vars win by default — when any `OPENVIKING_*` credentia
| `OPENVIKING_CODEX_LOCK_WAIT_MS` | `120000` (SessionEnd), `40000` (PreCompact) | How long a capture hook waits for the per-session state lock |
| `OPENVIKING_CODEX_COMMITTED_TTL_MS` | `2592000000` | How long a committed session's transcript cursor is kept before its state file is retired |
| `OPENVIKING_RECALL_QUERY_FILTERS` | `""` | CSV of sed-style regex rules applied to the prompt before it becomes a query ([grammar and examples](https://github.com/volcengine/OpenViking/blob/main/examples/codex-memory-plugin/README.md#input-filters)) |
| `OPENVIKING_RECALL_EVENTS_DECAY_PROTECTION` | `30d` | Event memories keep their original score for this period during auto recall and decay afterward. Set `off` to disable decay or select another period. MCP `find` and `search` use their own request parameters. |
| `OPENVIKING_CAPTURE_FILTERS` | `""` | CSV of sed-style regex rules applied to every captured turn (same grammar) |
| `OPENVIKING_DEBUG` | `false` | Write logs to `~/.openviking/logs/codex-hooks.log` |

Expand Down
2 changes: 1 addition & 1 deletion docs/en/agent-integrations/16-capability-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Skills follow their own path. Create, install, or replace them with the MCP `add
Every integration except OpenClaw and Hermes uses the shared plugin code, which tries up to three requests:

1. **Context search.** `POST /api/v1/search/search` with `mode: "context"`, `purpose: "coding"`, and the session ID. Budgets, quotas, query expansion, and digest options are sent only when you configure them; otherwise the server defaults apply, including a 1,600-token injection budget (`max_tokens`).
2. **Legacy recall.** If the server rejects context mode as an older version, the plugin records that in `~/.openviking/state/context-face.json` for six hours and calls `/api/v1/search/recall` instead. The file is shared by every integration on the machine, so one integration's result applies to all of them.
2. **Legacy recall.** If Context search is unavailable, the plugin can fall back to `/api/v1/search/recall`. A Context request rejected with HTTP `400` or `422` ends recall for that turn. Codex and Claude Code display the server error as a hook warning, and other callers of the shared recall pipeline write it to stderr.
3. **Plain find.** As a last resort the plugin runs `find` on `viking://~/memories` and `viking://~/skills`, ranks the results locally, and fills its own token budget. `recallTokenBudget`, `recallMaxContentChars`, and `recallPreferAbstract` apply only at this step.

The shared-plugin recall pipeline excludes resources; the model searches resource documents by calling `search` itself. Hermes can include resources when its resource-recall option is enabled.
Expand Down
2 changes: 1 addition & 1 deletion docs/en/api/06-retrieval.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ Event time decay applies to results tagged `memory_type=events` in semantic `fin

New and updated memories produced by memory extraction automatically receive a `memory_type=<type>` search tag. With decay enabled, both local and cloud backends recall records tagged `memory_type=events` separately and merge them with the complementary untagged/non-event branch; both branches preserve the original scope, permission and level filters, without requiring a peer ID. Existing data is not backfilled; untagged memories keep their original scores. Direct content refreshes and ordinary tag updates preserve the existing memory type without inferring it from the URI.

The local vector engine expands the requested event window by at most 3x internally (capped at 100,000), computes decay and sorts in C++, then returns top-k before any abstract or payload fields are fetched. This is a bounded candidate approximation, so events outside that semantic window are not guaranteed to be promoted. The HTTP vector service forwards the same native rule. Cloud adapters use VikingDB score fusion and request only the required limit plus offset, without a fixed 100,000-input override. cuVS collections use their native scalar/vector index for decay requests. openGauss accepts the forwarded parameters but does not apply time decay; it retains ordinary vector scoring.
The local vector engine expands the requested event window by at most 3x internally (capped at 100,000), computes decay and sorts in C++, then returns top-k before any abstract or payload fields are fetched. This is a bounded candidate approximation, so events outside that semantic window are not guaranteed to be promoted. The HTTP vector service forwards the same native rule. Cloud adapters use VikingDB score fusion and request only the required limit plus offset, without a fixed 100,000-input override. cuVS collections use their native scalar/vector index for decay requests. Distributed openGauss handles decay requests with ordinary vector retrieval and scoring.

When model rerank is enabled, each recall branch requests `2 × limit` results. Event decay is already applied inside VikingDB for cloud backends, or inside the local C++ engine, before the two branches merge. The best `2 × limit` merged candidates go through one model rerank; model scores determine the final ranking and score threshold. There is no additional decay after the model. If rerank fails, retrieval keeps the already-decayed recall scores. `origin_score` and `time_score` remain recall-stage details, so their product need not equal a successful model rerank score. Parent-directory scores and hotness are not mixed into the result.

Expand Down
1 change: 1 addition & 0 deletions docs/zh/agent-integrations/04-codex.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ memory 插件默认内置 OV-Usage。报告汇总自动召回和显式 OpenVikin
| `OPENVIKING_CODEX_LOCK_WAIT_MS` | `120000`(SessionEnd)、`40000`(PreCompact) | 捕获类 hook 等待单会话状态锁的时长(毫秒) |
| `OPENVIKING_CODEX_COMMITTED_TTL_MS` | `2592000000` | 已提交会话的转录游标保留时长(毫秒),过期后删除状态文件 |
| `OPENVIKING_RECALL_QUERY_FILTERS` | `""` | CSV 格式的 sed 风格正则规则,在 prompt 变成检索 query 前生效([语法与示例](https://github.com/volcengine/OpenViking/blob/main/examples/codex-memory-plugin/README.md#input-filters)) |
| `OPENVIKING_RECALL_EVENTS_DECAY_PROTECTION` | `30d` | 自动召回时,事件记忆在保护期内保持原分,超过保护期后开始衰减。可设为 `off` 或指定其他保护期。MCP `find` 和 `search` 由调用方传入各自的参数。 |
| `OPENVIKING_CAPTURE_FILTERS` | `""` | CSV 格式的 sed 风格正则规则,作用于每个被捕获的回合(同一套语法) |
| `OPENVIKING_DEBUG` | `false` | 是否将日志写入 `~/.openviking/logs/codex-hooks.log` |

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/agent-integrations/16-capability-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ skill 走单独的路径。创建、安装或替换 skill 用 MCP `add_skill`
除 OpenClaw 和 Hermes 外,所有集成都使用共享插件代码,最多依次尝试三种请求:

1. **context 检索**。`POST /api/v1/search/search`,带 `mode: "context"`、`purpose: "coding"` 和会话 ID。预算、配额、查询扩写和摘要选项只在你配置后才发送;否则使用服务端默认值,包括 1,600 token 的注入预算(`max_tokens`)。
2. **旧版 recall**。服务端版本较旧、拒绝 context 模式时,插件在 `~/.openviking/state/context-face.json` 中记录这一结果,有效 6 小时,并改调 `/api/v1/search/recall`。这个文件由本机所有集成共享,一个集成的判断对所有集成生效。
2. **旧版 recall**。Context 检索不可用时,插件可回退到 `/api/v1/search/recall`。Context 请求返回 HTTP `400` 或 `422` 时,本轮召回结束。Codex 和 Claude Code 会在 hook 提示中显示服务端错误,共享召回管线的其他调用方会将错误写入 stderr。
3. **普通 find**。最后一步,插件对 `viking://~/memories` 和 `viking://~/skills` 执行 `find`,在本地排序,并按自己的 token 预算装填。`recallTokenBudget`、`recallMaxContentChars` 和 `recallPreferAbstract` 只在这一步生效。

共享插件的召回不包含资源;资源文档由模型自己调用 `search` 检索。Hermes 开启资源召回选项后可以包含资源。
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/api/06-retrieval.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ ov find "红色海报风格" --image ./poster.png --uri "viking://resources/imag

由记忆提取流程新生成或更新的记忆会自动写入 `memory_type=<类型>` 检索标签。启用衰减时,本地和云端均将按是否带 `memory_type=events` 标签拆成互斥且完整覆盖原范围的两路,再合并排序;两路均保留原 scope 的权限、目录和 level 限制,无需指定 peer id。存量数据不补标签,无标签记忆保持原分。直接内容刷新和普通标签更新保留已有类型,不从 URI 推断或重设类型。

本地向量引擎按所需 event 条数在内部最多放大 3 倍候选(上限 100,000),在 C++ 中计算衰减并排序,截取 top-k 后才读取摘要等字段。这是有界候选近似,不能保证将语义候选窗口以外的事件提升进结果。HTTP 向量服务透传同一规则;云端 Adapter 使用 VikingDB 分数融合,仅请求 limit + offset,不设置固定 100,000 条输入预算。cuVS 集合的衰减请求使用其原生标量/向量索引。openGauss 接收透传参数但不执行时间衰减,保留普通向量分数。
本地向量引擎按所需 event 条数在内部最多放大 3 倍候选(上限 100,000),在 C++ 中计算衰减并排序,截取 top-k 后才读取摘要等字段。这是有界候选近似,不能保证将语义候选窗口以外的事件提升进结果。HTTP 向量服务透传同一规则;云端 Adapter 使用 VikingDB 分数融合,仅请求 limit + offset,不设置固定 100,000 条输入预算。cuVS 集合的衰减请求使用其原生标量/向量索引。分布式 openGauss 收到衰减请求时,仍按普通向量检索和排序返回结果。

启用模型 rerank 时,两路各请求 `2 × limit` 条结果。事件分支在召回时已完成衰减:云端由 VikingDB 计算,开源本地由 C++ 引擎计算。两路按召回分合并,取前 `2 × limit` 条统一执行一次模型 rerank,再按模型分排序、过滤阈值并取最终结果,模型后不再衰减。模型失败时使用已经衰减过的召回分。`origin_score` 和 `time_score` 始终描述召回阶段的原向量分与时间因子,因此二者乘积不一定等于成功 rerank 后的模型分。最终分数不混入父目录分数或热度分。

Expand Down
2 changes: 1 addition & 1 deletion examples/agent-hook-plugin/hosts/codebuddy/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openviking-memory",
"version": "0.5.36",
"version": "0.5.37",
"description": "Long-term semantic memory for the CodeBuddy Code CLI, powered by OpenViking. Injects relevant context at session start and on each prompt, and captures the conversation back into OpenViking.",
"author": {
"name": "OpenViking",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "openviking-memory",
"version": "0.5.36",
"version": "0.5.37",
"clients": [
"cursor"
],
Expand Down
2 changes: 1 addition & 1 deletion examples/agent-hook-plugin/hosts/kimicode/kimi.plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openviking-memory",
"version": "0.5.36",
"version": "0.5.37",
"description": "Long-term semantic memory for Kimi Code CLI, powered by OpenViking.",
"author": {
"name": "OpenViking",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "openviking-memory",
"version": "0.5.36",
"version": "0.5.37",
"clients": [
"kimicode"
],
Expand Down
2 changes: 1 addition & 1 deletion examples/agent-hook-plugin/hosts/qoder/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openviking-memory",
"version": "0.5.36",
"version": "0.5.37",
"description": "Long-term semantic memory for the Qoder CLI, powered by OpenViking. Injects relevant context at session start and on each prompt, and captures the conversation back into OpenViking.",
"author": {
"name": "OpenViking",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "openviking-memory",
"version": "0.5.36",
"version": "0.5.37",
"clients": [
"trae",
"trae-cn"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "openviking-memory",
"version": "0.5.36",
"version": "0.5.37",
"clients": [
"zcode"
],
Expand Down
2 changes: 1 addition & 1 deletion examples/agent-hook-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agent-hook-plugin",
"version": "0.5.36",
"version": "0.5.37",
"description": "Long-term semantic memory for Cursor, TRAE, TRAE CN, ZCode, Kimi Code, CodeBuddy Code, Qoder CLI and Antigravity — powered by OpenViking. Auto-recall relevant memories and capture the conversation as it happens.",
"author": {
"name": "OpenViking",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openviking-memory",
"version": "0.7.27",
"version": "0.7.28",
"description": "Long-term semantic memory for Claude Code, powered by OpenViking. Auto-recall relevant memories at session start and capture important information during conversations.",
"author": {
"name": "OpenViking",
Expand Down
2 changes: 1 addition & 1 deletion examples/claude-code-memory-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Upgrading from the path-derived peer needs no action: memories written under the
| `OPENVIKING_RECALL_PEER_SCOPE` | `all` | `all` can recall other project memories with a score penalty; `actor` only sees global plus the current project |
| `OPENVIKING_RECALL_MAX_TOKENS` | `1600` | Token budget for the server-assembled context block (independent of local compression limits) |
| `OPENVIKING_RECALL_DEDUP_TURNS` | `5` | Cross-turn cooldown: URIs served in the last N turns are skipped |
| `OPENVIKING_RECALL_EVENTS_DECAY_PROTECTION` | (off) | Event memories keep their score for this period (`7d`, `12h`) and decay after it, so older events stop outranking recent ones. Sent as `events_time_decay_protection`. |
| `OPENVIKING_RECALL_EVENTS_DECAY_PROTECTION` | `30d` | Auto recall keeps event scores unchanged for this long after the event record was updated and decays them afterward. Set `off` to disable decay, or set another period such as `7d` or `12h`. |
| `OPENVIKING_RECALL_QUERY_EXPANSION` | `auto` | `auto` lets the server widen short prompts using session context; `off` disables it |
| `OPENVIKING_RECALL_COMPRESS` | `auto` | Digest compression: `off`, `client` (host CLI), `server`, or `auto` (local first, server fallback) |
| `OPENVIKING_RECALL_COMPRESS_MAX_BULLETS` | `6` | Digest bullet ceiling |
Expand Down
2 changes: 1 addition & 1 deletion examples/claude-code-memory-plugin/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ claude
| `OPENVIKING_LOG_RANKING_DETAILS` | `false` | 每候选打分日志(很啰嗦) |
| `OPENVIKING_RECALL_MAX_TOKENS` | `1600` | 服务端组装上下文块的 token 预算(与本地压缩输入上限相互独立) |
| `OPENVIKING_RECALL_DEDUP_TURNS` | `5` | 跨轮冷却:最近 N 轮已注入过的 URI 本轮跳过 |
| `OPENVIKING_RECALL_EVENTS_DECAY_PROTECTION` | (关) | 事件记忆在此期限内(`7d`、`12h`)保持原分,之后衰减,较早的事件不再压过新的。以 `events_time_decay_protection` 发送。 |
| `OPENVIKING_RECALL_EVENTS_DECAY_PROTECTION` | `30d` | 自动召回时,事件更新后在保护期内保持原分,超过保护期后开始衰减。设为 `off` 关闭衰减,或指定 `7d`、`12h` 等其他保护期。 |
| `OPENVIKING_RECALL_QUERY_EXPANSION` | `auto` | `auto` 让服务端结合会话上下文扩展短提问;`off` 关闭 |
| `OPENVIKING_RECALL_COMPRESS` | `auto` | digest 压缩:`off`、`client`(本地宿主 CLI)、`server`、`auto`(本地优先、失败回落服务端) |
| `OPENVIKING_RECALL_COMPRESS_MAX_BULLETS` | `6` | digest 条数上限 |
Expand Down
2 changes: 1 addition & 1 deletion examples/claude-code-memory-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "claude-code-openviking-memory",
"version": "0.7.27",
"version": "0.7.28",
"description": "OpenViking memory plugin for Claude Code — semantic long-term memory",
"type": "module",
"scripts": {
Expand Down
9 changes: 5 additions & 4 deletions examples/claude-code-memory-plugin/scripts/auto-recall.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ function output(obj) {
process.stdout.write(JSON.stringify(obj) + "\n");
}

function approve(msg) {
function approve({ block, error } = {}) {
const out = { decision: "approve" };
if (msg) out.hookSpecificOutput = { hookEventName: "UserPromptSubmit", additionalContext: msg };
if (block) out.hookSpecificOutput = { hookEventName: "UserPromptSubmit", additionalContext: block };
if (error) out.systemMessage = error;
output(out);
}

Expand Down Expand Up @@ -127,7 +128,7 @@ runHookStage({
if (!recalled.block) {
log("skip", { reason: recalled.stage });
writeRecallState({ count: 0, reason: recalled.stage, cc_session_id: sessionId });
return;
return recalled;
}

writeRecallState({
Expand All @@ -143,5 +144,5 @@ runHookStage({
cc_session_id: sessionId,
reason: "ok",
});
return recalled.block;
return recalled;
}).catch((err) => { logError("uncaught", err); approve(); });
23 changes: 23 additions & 0 deletions examples/claude-code-memory-plugin/scripts/auto-recall.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,29 @@ const NO_SERVER_ASSEMBLY = {
"POST /api/v1/search/recall": () => ({ status: 404, body: { status: "error", error: { message: "gone" } } }),
};

test("auto-recall displays the server validation error with debug disabled", async () => {
let requests = 0;
const message = "Invalid request parameters: events_time_decay_protection";
const { stdout, state } = await recallTurn({
env: { OPENVIKING_DEBUG: "0" },
routes: {
...HEALTHY,
"POST /api/v1/search/search": () => {
requests++;
return { status: 422, body: { status: "error", error: { code: "INVALID_ARGUMENT", message } } };
},
"POST /api/v1/search/recall": () => assert.fail("parameter errors must not fall back to /recall"),
},
});

assert.deepEqual(JSON.parse(stdout), {
decision: "approve",
systemMessage: `OpenViking auto recall failed (HTTP 422): ${message}`,
});
assert.equal(state.reason, "request_rejected");
assert.equal(requests, 1);
});

function memory(uri, score, abstract) {
return { uri, score, abstract, level: 1, category: "entities" };
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading