diff --git a/examples/claude-code-memory-plugin/README.md b/examples/claude-code-memory-plugin/README.md index 296a50ba23a..73028f95808 100644 --- a/examples/claude-code-memory-plugin/README.md +++ b/examples/claude-code-memory-plugin/README.md @@ -178,6 +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_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 | diff --git a/examples/claude-code-memory-plugin/README_CN.md b/examples/claude-code-memory-plugin/README_CN.md index 6ecc5cfac3a..483212046b4 100644 --- a/examples/claude-code-memory-plugin/README_CN.md +++ b/examples/claude-code-memory-plugin/README_CN.md @@ -153,6 +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_QUERY_EXPANSION` | `auto` | `auto` 让服务端结合会话上下文扩展短提问;`off` 关闭 | | `OPENVIKING_RECALL_COMPRESS` | `auto` | digest 压缩:`off`、`client`(本地宿主 CLI)、`server`、`auto`(本地优先、失败回落服务端) | | `OPENVIKING_RECALL_COMPRESS_MAX_BULLETS` | `6` | digest 条数上限 | diff --git a/examples/claude-code-memory-plugin/scripts/shared/config-schema.mjs b/examples/claude-code-memory-plugin/scripts/shared/config-schema.mjs index c79d4f11e3e..cc7152fbb12 100644 --- a/examples/claude-code-memory-plugin/scripts/shared/config-schema.mjs +++ b/examples/claude-code-memory-plugin/scripts/shared/config-schema.mjs @@ -84,6 +84,9 @@ export const KNOBS = [ { name: "recallMaxContentChars", type: "int", default: 500, min: 100, max: 5000, env: "OPENVIKING_RECALL_MAX_CONTENT_CHARS", capability: "recall" }, { name: "recallPreferAbstract", type: "bool", default: true, env: "OPENVIKING_RECALL_PREFER_ABSTRACT", capability: "recall" }, { name: "recallPeerScope", type: "enum", values: ["all", "actor"], default: "all", env: "OPENVIKING_RECALL_PEER_SCOPE", workspace: "recall.peer_scope", capability: "recall" }, + // Sent as events_time_decay_protection ("7d", "12h"): event memories keep their score for + // that long and decay afterwards. Empty leaves decay off, as the server does by default. + { name: "recallEventsDecayProtection", type: "string", default: "", env: "OPENVIKING_RECALL_EVENTS_DECAY_PROTECTION", capability: "recall" }, { name: "recallDedupTurns", type: "int", default: 5, min: 0, max: 20, env: "OPENVIKING_RECALL_DEDUP_TURNS", workspace: "recall.dedup_turns", capability: "recall" }, { name: "recallMaxTokens", type: "int", default: 1600, min: 64, max: 200000, env: "OPENVIKING_RECALL_MAX_TOKENS", sendOnlyWhenConfigured: true, capability: "recall" }, { name: "recallQueryExpansion", type: "enum", values: ["auto", "off"], default: "auto", env: "OPENVIKING_RECALL_QUERY_EXPANSION", sendOnlyWhenConfigured: true, capability: "recall" }, diff --git a/examples/claude-code-memory-plugin/scripts/shared/recall-core.mjs b/examples/claude-code-memory-plugin/scripts/shared/recall-core.mjs index cf0f684c95c..ecbaed1b2ec 100644 --- a/examples/claude-code-memory-plugin/scripts/shared/recall-core.mjs +++ b/examples/claude-code-memory-plugin/scripts/shared/recall-core.mjs @@ -129,6 +129,8 @@ export function buildContextSearchBody(cfg = {}, options = {}) { if (limitConfigured) body.quotas = codingQuotas(limit); if (maxTokensConfigured) body.max_tokens = maxTokens; if (cfg.recallPeerScope === "actor") body.peer_scope = "actor"; + const decayProtection = String(cfg.recallEventsDecayProtection || "").trim(); + if (decayProtection) body.events_time_decay_protection = decayProtection; const sessionId = String(options.sessionId || "").trim(); if (sessionId) { diff --git a/examples/codex-memory-plugin/README.md b/examples/codex-memory-plugin/README.md index 91ca14d7f15..ec84bc9afb9 100644 --- a/examples/codex-memory-plugin/README.md +++ b/examples/codex-memory-plugin/README.md @@ -357,6 +357,7 @@ Config knobs: | `OPENVIKING_RECALL_COMPRESS_DETECT_TTL_MS` | `604800000` | Cache TTL used by `UserPromptSubmit` when reading the latest profile. | | `OPENVIKING_RECALL_MAX_TOKENS` | `1600` | Token budget the server assembles the context block within, independent of the local compressor input limit. | | `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_QUERY_EXPANSION` | `auto` | `auto` lets the server widen short prompts using session context; `off` disables it. | | `OPENVIKING_RECALL_QUERY_FILTERS` | `""` | Comma-separated regex rules applied to the prompt before it becomes a query — see [Input filters](#input-filters). | diff --git a/examples/codex-memory-plugin/scripts/shared/config-schema.mjs b/examples/codex-memory-plugin/scripts/shared/config-schema.mjs index c79d4f11e3e..cc7152fbb12 100644 --- a/examples/codex-memory-plugin/scripts/shared/config-schema.mjs +++ b/examples/codex-memory-plugin/scripts/shared/config-schema.mjs @@ -84,6 +84,9 @@ export const KNOBS = [ { name: "recallMaxContentChars", type: "int", default: 500, min: 100, max: 5000, env: "OPENVIKING_RECALL_MAX_CONTENT_CHARS", capability: "recall" }, { name: "recallPreferAbstract", type: "bool", default: true, env: "OPENVIKING_RECALL_PREFER_ABSTRACT", capability: "recall" }, { name: "recallPeerScope", type: "enum", values: ["all", "actor"], default: "all", env: "OPENVIKING_RECALL_PEER_SCOPE", workspace: "recall.peer_scope", capability: "recall" }, + // Sent as events_time_decay_protection ("7d", "12h"): event memories keep their score for + // that long and decay afterwards. Empty leaves decay off, as the server does by default. + { name: "recallEventsDecayProtection", type: "string", default: "", env: "OPENVIKING_RECALL_EVENTS_DECAY_PROTECTION", capability: "recall" }, { name: "recallDedupTurns", type: "int", default: 5, min: 0, max: 20, env: "OPENVIKING_RECALL_DEDUP_TURNS", workspace: "recall.dedup_turns", capability: "recall" }, { name: "recallMaxTokens", type: "int", default: 1600, min: 64, max: 200000, env: "OPENVIKING_RECALL_MAX_TOKENS", sendOnlyWhenConfigured: true, capability: "recall" }, { name: "recallQueryExpansion", type: "enum", values: ["auto", "off"], default: "auto", env: "OPENVIKING_RECALL_QUERY_EXPANSION", sendOnlyWhenConfigured: true, capability: "recall" }, diff --git a/examples/codex-memory-plugin/scripts/shared/recall-core.mjs b/examples/codex-memory-plugin/scripts/shared/recall-core.mjs index cf0f684c95c..ecbaed1b2ec 100644 --- a/examples/codex-memory-plugin/scripts/shared/recall-core.mjs +++ b/examples/codex-memory-plugin/scripts/shared/recall-core.mjs @@ -129,6 +129,8 @@ export function buildContextSearchBody(cfg = {}, options = {}) { if (limitConfigured) body.quotas = codingQuotas(limit); if (maxTokensConfigured) body.max_tokens = maxTokens; if (cfg.recallPeerScope === "actor") body.peer_scope = "actor"; + const decayProtection = String(cfg.recallEventsDecayProtection || "").trim(); + if (decayProtection) body.events_time_decay_protection = decayProtection; const sessionId = String(options.sessionId || "").trim(); if (sessionId) { diff --git a/examples/memory-plugin-shared/lib/config-schema.mjs b/examples/memory-plugin-shared/lib/config-schema.mjs index c49188a4b51..3422782192c 100644 --- a/examples/memory-plugin-shared/lib/config-schema.mjs +++ b/examples/memory-plugin-shared/lib/config-schema.mjs @@ -83,6 +83,9 @@ export const KNOBS = [ { name: "recallMaxContentChars", type: "int", default: 500, min: 100, max: 5000, env: "OPENVIKING_RECALL_MAX_CONTENT_CHARS", capability: "recall" }, { name: "recallPreferAbstract", type: "bool", default: true, env: "OPENVIKING_RECALL_PREFER_ABSTRACT", capability: "recall" }, { name: "recallPeerScope", type: "enum", values: ["all", "actor"], default: "all", env: "OPENVIKING_RECALL_PEER_SCOPE", workspace: "recall.peer_scope", capability: "recall" }, + // Sent as events_time_decay_protection ("7d", "12h"): event memories keep their score for + // that long and decay afterwards. Empty leaves decay off, as the server does by default. + { name: "recallEventsDecayProtection", type: "string", default: "", env: "OPENVIKING_RECALL_EVENTS_DECAY_PROTECTION", capability: "recall" }, { name: "recallDedupTurns", type: "int", default: 5, min: 0, max: 20, env: "OPENVIKING_RECALL_DEDUP_TURNS", workspace: "recall.dedup_turns", capability: "recall" }, { name: "recallMaxTokens", type: "int", default: 1600, min: 64, max: 200000, env: "OPENVIKING_RECALL_MAX_TOKENS", sendOnlyWhenConfigured: true, capability: "recall" }, { name: "recallQueryExpansion", type: "enum", values: ["auto", "off"], default: "auto", env: "OPENVIKING_RECALL_QUERY_EXPANSION", sendOnlyWhenConfigured: true, capability: "recall" }, diff --git a/examples/memory-plugin-shared/lib/recall-core.mjs b/examples/memory-plugin-shared/lib/recall-core.mjs index 3b76612107b..32d279808b5 100644 --- a/examples/memory-plugin-shared/lib/recall-core.mjs +++ b/examples/memory-plugin-shared/lib/recall-core.mjs @@ -128,6 +128,8 @@ export function buildContextSearchBody(cfg = {}, options = {}) { if (limitConfigured) body.quotas = codingQuotas(limit); if (maxTokensConfigured) body.max_tokens = maxTokens; if (cfg.recallPeerScope === "actor") body.peer_scope = "actor"; + const decayProtection = String(cfg.recallEventsDecayProtection || "").trim(); + if (decayProtection) body.events_time_decay_protection = decayProtection; const sessionId = String(options.sessionId || "").trim(); if (sessionId) { diff --git a/examples/memory-plugin-shared/recall-core.test.mjs b/examples/memory-plugin-shared/recall-core.test.mjs index 24c1f502fe4..d8221cb1a4f 100644 --- a/examples/memory-plugin-shared/recall-core.test.mjs +++ b/examples/memory-plugin-shared/recall-core.test.mjs @@ -36,6 +36,12 @@ test("context requests preserve the configured recall width and server budget", assert.equal(body.purpose, "coding"); }); +test("context requests send an event decay window only when one is configured", () => { + assert.equal(buildContextSearchBody({}).events_time_decay_protection, undefined); + assert.equal(buildContextSearchBody({ recallEventsDecayProtection: " " }).events_time_decay_protection, undefined); + assert.equal(buildContextSearchBody({ recallEventsDecayProtection: "7d" }).events_time_decay_protection, "7d"); +}); + test("context requests omit defaults owned by the server", () => { const body = buildContextSearchBody({ recallLimit: 10, diff --git a/examples/openclaw-plugin/shared/recall-core.mjs b/examples/openclaw-plugin/shared/recall-core.mjs index cf0f684c95c..ecbaed1b2ec 100644 --- a/examples/openclaw-plugin/shared/recall-core.mjs +++ b/examples/openclaw-plugin/shared/recall-core.mjs @@ -129,6 +129,8 @@ export function buildContextSearchBody(cfg = {}, options = {}) { if (limitConfigured) body.quotas = codingQuotas(limit); if (maxTokensConfigured) body.max_tokens = maxTokens; if (cfg.recallPeerScope === "actor") body.peer_scope = "actor"; + const decayProtection = String(cfg.recallEventsDecayProtection || "").trim(); + if (decayProtection) body.events_time_decay_protection = decayProtection; const sessionId = String(options.sessionId || "").trim(); if (sessionId) {