Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

Fix/filter invalid attr tags (#4123)

Jiahui Zhou98a0104aaa97
diff --git a/docs/en/agent-integrations/16-capability-reference.md b/docs/en/agent-integrations/16-capability-reference.md
index 3abbaf2ca..20f53b10b 100644
--- a/docs/en/agent-integrations/16-capability-reference.md
+++ b/docs/en/agent-integrations/16-capability-reference.md
@@ -144,7 +144,7 @@ Core modules at a glance (detailed further in the per-dimension sections):
- `memory.session_auto_commit.default_enabled = false` and `idle_enabled = false` (`memory_config.py:15-16`). Auto-commit is disabled for sessions lacking a storage policy (`session_service.py:637-638`). Furthermore, the idle scanner isn't even instantiated when `idle_enabled=false` (`core.py:440-448`), effectively acting as a double gate.
- The `auto_create` path triggered by `POST /messages` accepts no policy arguments; only `POST /sessions` (creation) and `PATCH /sessions/{id}/config` can set the `auto_commit_policy`.
- Currently, no plugin sends an `auto_commit_policy`. Among first-party clients, only the **ov CLI** does this (`ov session new --auto-commit-policy-json` / `--no-auto-commit`, `ov session config set`).
- - When a policy is explicitly enabled, the server defaults are: `pending_token_threshold=10000` (strictly greater than), `message_count_threshold=50`, `idle_timeout_seconds=86400`, `keep_recent_count=2`, and `min_commit_interval_seconds=0`. Note that this set of server defaults operates independently of the plugin clients' configuration (which is typically 20000/10).
+ - When a policy is explicitly enabled, the server defaults are: `pending_token_threshold=150000` (strictly greater than), `message_count_threshold=100`, `idle_timeout_seconds=86400`, `keep_recent_count=0`, and `min_commit_interval_seconds=0`. Note that this set of server defaults operates independently of the plugin clients' configuration (which is typically 20000/10).
- **Consequence**: As it stands, every auto-commit relies on threshold logic implemented individually by each client ([§3.3](#_3-3-session-and-commit-lifecycle)), with no server-side fallback. If a process dies abnormally, any lingering pending messages are only archived and extracted when a subsequent commit is manually triggered in that same session.
- **Externalized tool output**: The server sets `tool_output_externalization.enabled=True` with `threshold_chars=20000` (`server/config.py:257-258`). Clients commonly raise `captureToolMaxChars` to 1000000 purely as a fallback mechanism, since the actual truncation and externalization occur on the server. Externalized results are then referenced via `tool_output_ref` (for context, openclaw provides three dedicated tools specifically for reading these references).
- **Server-side recall timeout fuses**: Configured via `retrieval.recall_intent_timeout_s=5.0` (for query expansion), `recall_rewrite_timeout_s=30.0` (for digests, [§3.2.5](#_3-2-5-recall-digest)), and `enable_intent=true`. Client timeout budgets are derived directly from these two timeout values ([§3.2.4](#_3-2-4-timeout-and-budget-chain)).
diff --git a/docs/en/api/05-sessions.md b/docs/en/api/05-sessions.md
index 07b9e7512..2f54e7461 100644
--- a/docs/en/api/05-sessions.md
+++ b/docs/en/api/05-sessions.md
@@ -50,10 +50,10 @@ Create a new session. Sessions are containers for conversations, storing message
| Field | Type | Default | Max | Description |
|-------|------|---------|-----|-------------|
-| `pending_token_threshold` | int | 10000 | 50000 | When uncommitted pending tokens exceed this value (strictly greater-than), an auto commit is triggered after a message write. |
-| `message_count_threshold` | int | 50 | 500 | When the uncommitted live message count exceeds this value (strictly greater-than), an auto commit is triggered after a message write. |
+| `pending_token_threshold` | int | 150000 | 1000000 | When uncommitted pending tokens exceed this value (strictly greater-than), an auto commit is triggered after a message write. |
+| `message_count_threshold` | int | 100 | 1000 | When the uncommitted live message count exceeds this value (strictly greater-than), an auto commit is triggered after a message write. |
| `idle_timeout_seconds` | int | 86400 | 604800 | After this many idle seconds, a session with uncommitted content becomes eligible for the server-side idle scheduler. An idle-timeout commit archives the full backlog and ignores `keep_recent_count`. |
-| `keep_recent_count` | int | 2 | 500 | Number of recent live messages to keep (not archived) on a threshold-triggered auto commit. Idle-timeout commits ignore this and commit everything. |
+| `keep_recent_count` | int | 0 | 500 | Number of recent live messages to keep (not archived) on a threshold-triggered auto commit. Idle-timeout commits ignore this and commit everything. |
| `min_commit_interval_seconds` | int | 0 | 604800 | Minimum seconds between two automatic commits (throttle). |
All fields have a minimum of `0` and are clamped into `[0, max]`. Unknown keys are rejected with `InvalidArgumentError`.
@@ -387,10 +387,10 @@ ov session get a1b2c3d4
},
"pending_tokens": 450,
"auto_commit_policy": {
- "pending_token_threshold": 10000,
- "message_count_threshold": 50,
+ "pending_token_threshold": 150000,
+ "message_count_threshold": 100,
"idle_timeout_seconds": 86400,
- "keep_recent_count": 2,
+ "keep_recent_count": 0,
"min_commit_interval_seconds": 0
}
}
@@ -512,10 +512,10 @@ ov session config set a1b2c3d4 --no-auto-commit
"result": {
"session_id": "a1b2c3d4",
"auto_commit_policy": {
- "pending_token_threshold": 10000,
+ "pending_token_threshold": 150000,
"message_count_threshold": 25,
"idle_timeout_seconds": 86400,
- "keep_recent_count": 2,
+ "keep_recent_count": 0,
"min_commit_interval_seconds": 0
},
"memory_extraction_config": {
diff --git a/docs/en/guides/01-configuration.md b/docs/en/guides/01-configuration.md
index ad356be50..62993b336 100644
--- a/docs/en/guides/01-configuration.md
+++ b/docs/en/guides/01-configuration.md
@@ -1253,10 +1253,10 @@ When a session carries an `auto_commit_policy`, any field you omit falls back to
| Field | Type | Default | Max | Description |
|-------|------|---------|-----|-------------|
-| `pending_token_threshold` | int | 10000 | 50000 | When uncommitted pending tokens exceed this value (strictly greater-than), an auto commit is triggered after a message write. |
-| `message_count_threshold` | int | 50 | 500 | When the uncommitted live message count exceeds this value (strictly greater-than), an auto commit is triggered after a message write. |
+| `pending_token_threshold` | int | 150000 | 1000000 | When uncommitted pending tokens exceed this value (strictly greater-than), an auto commit is triggered after a message write. |
+| `message_count_threshold` | int | 100 | 1000 | When the uncommitted live message count exceeds this value (strictly greater-than), an auto commit is triggered after a message write. |
| `idle_timeout_seconds` | int | 86400 | 604800 | After this many idle seconds, a session with uncommitted content becomes eligible for the server-side idle scheduler. Idle-timeout commits archive the full backlog and ignore `keep_recent_count`. |
-| `keep_recent_count` | int | 2 | 500 | Number of recent live messages to keep (not archived) on a threshold-triggered auto commit. Idle-timeout commits ignore this and commit everything. |
+| `keep_recent_count` | int | 0 | 500 | Number of recent live messages to keep (not archived) on a threshold-triggered auto commit. Idle-timeout commits ignore this and commit everything. |
| `min_commit_interval_seconds` | int | 0 | 604800 | Minimum seconds between two automatic commits (throttle). |
Code entry: `openviking/session/auto_commit_policy.py:AutoCommitPolicy`.
diff --git a/docs/zh/agent-integrations/16-capability-reference.md b/docs/zh/agent-integrations/16-capability-reference.md
index 8632b0c21..bab15a402 100644
--- a/docs/zh/agent-integrations/16-capability-reference.md
+++ b/docs/zh/agent-integrations/16-capability-reference.md
@@ -145,7 +145,7 @@ per-harness 章节(档案卡)只写差异;所有共享事实均在本章
- `memory.session_auto_commit.default_enabled = false`、`idle_enabled = false`(`memory_config.py:15-16`);无存储 policy 的会话自动 commit 关闭(`session_service.py:637-638`);idle 扫描器在 `idle_enabled=false` 时根本不创建(`core.py:440-448`),构成双重门控。
- `POST /messages` 的 auto_create 不接受 policy 参数;只有 `POST /sessions`(create)与 `PATCH /sessions/{id}/config` 能设 `auto_commit_policy`。
- 当前没有插件下发 `auto_commit_policy`;第一方客户端中会下发该字段的是 **ov CLI**(`ov session new --auto-commit-policy-json` / `--no-auto-commit`、`ov session config set`)。
- - policy 显式启用时,服务端默认阈值是 `pending_token_threshold=10000(严格大于)/ message_count_threshold=50 / idle_timeout_seconds=86400 / keep_recent_count=2 / min_commit_interval_seconds=0`。注意这组服务端默认值与各插件客户端的 20000/10 是相互独立的两层配置。
+ - policy 显式启用时,服务端默认阈值是 `pending_token_threshold=150000(严格大于)/ message_count_threshold=100 / idle_timeout_seconds=86400 / keep_recent_count=0 / min_commit_interval_seconds=0`。注意这组服务端默认值与各插件客户端的 20000/10 是相互独立的两层配置。
- **由此**:现状下所有自动 commit 都是客户端各自实现的阈值逻辑([§3.3](#_3-3-会话与-commit-生命周期)),服务端不做兜底;进程异常终止后遗留的 pending 消息,需在同一会话后续再触发 commit 才会归档与抽取。
- **tool output 外置**:服务端 `tool_output_externalization.enabled=True`、`threshold_chars=20000`(`server/config.py:257-258`)——客户端普遍把 `captureToolMaxChars` 设到 1000000 仅作兜底,真正的截断/外置在服务端做,externalized 结果通过 `tool_output_ref` 引用(openclaw 有三个专门工具读它)。
- **服务端召回相关熔断**:`retrieval.recall_intent_timeout_s=5.0`(query expansion)、`recall_rewrite_timeout_s=30.0`(digest,[§3.2.5](#_3-2-5-召回再摘要))、`enable_intent=true`。客户端超时预算按这两条推导([§3.2.4](#_3-2-4-超时与预算链))。
diff --git a/docs/zh/api/05-sessions.md b/docs/zh/api/05-sessions.md
index f90e9fab8..c78470ae6 100644
--- a/docs/zh/api/05-sessions.md
+++ b/docs/zh/api/05-sessions.md
@@ -50,10 +50,10 @@ Session API 按认证用户作用域访问会话,并返回 canonical user sess
| 字段 | 类型 | 默认值 | 上限 | 说明 |
|------|------|--------|------|------|
-| `pending_token_threshold` | int | 10000 | 50000 | 当未提交的 pending token 超过该值(严格大于)时,会在消息写入后触发一次自动 commit。 |
-| `message_count_threshold` | int | 50 | 500 | 当未提交的 live message 数量超过该值(严格大于)时,会在消息写入后触发一次自动 commit。 |
+| `pending_token_threshold` | int | 150000 | 1000000 | 当未提交的 pending token 超过该值(严格大于)时,会在消息写入后触发一次自动 commit。 |
+| `message_count_threshold` | int | 100 | 1000 | 当未提交的 live message 数量超过该值(严格大于)时,会在消息写入后触发一次自动 commit。 |
| `idle_timeout_seconds` | int | 86400 | 604800 | 有未提交内容的 session 在空闲这么多秒后,进入服务端 idle scheduler 的处理范围。idle 触发的 commit 会归档全部积压消息,并忽略 `keep_recent_count`。 |
-| `keep_recent_count` | int | 2 | 500 | 阈值触发的自动 commit 后保留(不归档)的最近 live message 数量。idle 超时触发的 commit 会忽略该值并归档所有消息。 |
+| `keep_recent_count` | int | 0 | 500 | 阈值触发的自动 commit 后保留(不归档)的最近 live message 数量。idle 超时触发的 commit 会忽略该值并归档所有消息。 |
| `min_commit_interval_seconds` | int | 0 | 604800 | 两次自动 commit 之间的最小间隔秒数(节流)。 |
所有字段最小值为 `0`,会被 clamp 到 `[0, 上限]`。未知字段会以 `InvalidArgumentError` 拒绝。
@@ -387,10 +387,10 @@ ov session get a1b2c3d4
},
"pending_tokens": 450,
"auto_commit_policy": {
- "pending_token_threshold": 10000,
- "message_count_threshold": 50,
+ "pending_token_threshold": 150000,
+ "message_count_threshold": 100,
"idle_timeout_seconds": 86400,
- "keep_recent_count": 2,
+ "keep_recent_count": 0,
"min_commit_interval_seconds": 0
}
}
@@ -510,10 +510,10 @@ ov session config set a1b2c3d4 --no-auto-commit
"result": {
"session_id": "a1b2c3d4",
"auto_commit_policy": {
- "pending_token_threshold": 10000,
+ "pending_token_threshold": 150000,
"message_count_threshold": 25,
"idle_timeout_seconds": 86400,
- "keep_recent_count": 2,
+ "keep_recent_count": 0,
"min_commit_interval_seconds": 0
},
"memory_extraction_config": {
diff --git a/docs/zh/guides/01-configuration.md b/docs/zh/guides/01-configuration.md
index 38f860d2d..567f1c150 100644
--- a/docs/zh/guides/01-configuration.md
+++ b/docs/zh/guides/01-configuration.md
@@ -1339,10 +1339,10 @@ Redis Sentinel 分别配置数据节点和 Sentinel 的 ACL:
| 字段 | 类型 | 默认值 | 上限 | 说明 |
|------|------|--------|------|------|
-| `pending_token_threshold` | int | 10000 | 50000 | 当未提交的 pending token 超过该值(严格大于)时,会在消息写入后触发一次自动 commit。 |
-| `message_count_threshold` | int | 50 | 500 | 当未提交的 live message 数量超过该值(严格大于)时,会在消息写入后触发一次自动 commit。 |
+| `pending_token_threshold` | int | 150000 | 1000000 | 当未提交的 pending token 超过该值(严格大于)时,会在消息写入后触发一次自动 commit。 |
+| `message_count_threshold` | int | 100 | 1000 | 当未提交的 live message 数量超过该值(严格大于)时,会在消息写入后触发一次自动 commit。 |
| `idle_timeout_seconds` | int | 86400 | 604800 | 有未提交内容的 session 在空闲这么多秒后,进入服务端 idle scheduler 的处理范围。idle 触发的 commit 会归档全部积压消息,并忽略 `keep_recent_count`。 |
-| `keep_recent_count` | int | 2 | 500 | 阈值触发的自动 commit 后保留(不归档)的最近 live message 数量。idle 超时触发的 commit 会忽略该值并归档所有消息。 |
+| `keep_recent_count` | int | 0 | 500 | 阈值触发的自动 commit 后保留(不归档)的最近 live message 数量。idle 超时触发的 commit 会忽略该值并归档所有消息。 |
| `min_commit_interval_seconds` | int | 0 | 604800 | 两次自动 commit 之间的最小间隔秒数(节流)。 |
代码入口:`openviking/session/auto_commit_policy.py:AutoCommitPolicy`。
diff --git a/openviking/server/routers/filesystem.py b/openviking/server/routers/filesystem.py
index 17b674d1a..dd90683fb 100644
--- a/openviking/server/routers/filesystem.py
+++ b/openviking/server/routers/filesystem.py
@@ -20,6 +20,7 @@ from openviking.server.routers.content import SetTagsRequest
from openviking.server.routers.content import set_tags as content_set_tags
from openviking.storage.expr import And, Eq, In
from openviking.storage.vikingdb_manager import VikingDBManagerProxy
+from openviking.utils.tags import normalize_search_tags
from openviking_cli.exceptions import NotFoundError
router = APIRouter(prefix="/api/v1/fs", tags=["filesystem"])
@@ -59,7 +60,7 @@ async def _tags_attr(
records = sorted(records, key=lambda item: item.get("level", 99))
tags: list[str] = []
for record in records:
- for tag in record.get("search_tags") or []:
+ for tag in normalize_search_tags(record.get("search_tags"), discard_invalid=True):
if tag not in tags:
tags.append(tag)
return tags
diff --git a/openviking/session/auto_commit_policy.py b/openviking/session/auto_commit_policy.py
index 7efd6230b..e01eb34ec 100644
--- a/openviking/session/auto_commit_policy.py
+++ b/openviking/session/auto_commit_policy.py
@@ -16,15 +16,15 @@ from typing import Any
from openviking_cli.exceptions import InvalidArgumentError
# Recommended defaults, aligned with the memory-bank streaming_write behavior.
-DEFAULT_PENDING_TOKEN_THRESHOLD = 10000
-DEFAULT_MESSAGE_COUNT_THRESHOLD = 50
+DEFAULT_PENDING_TOKEN_THRESHOLD = 150000
+DEFAULT_MESSAGE_COUNT_THRESHOLD = 100
DEFAULT_IDLE_TIMEOUT_SECONDS = 86400 # 1 day
-DEFAULT_KEEP_RECENT_COUNT = 2
+DEFAULT_KEEP_RECENT_COUNT = 0
DEFAULT_MIN_COMMIT_INTERVAL_SECONDS = 0
# PRD upper bounds.
-MAX_PENDING_TOKEN_THRESHOLD = 50000
-MAX_MESSAGE_COUNT_THRESHOLD = 500
+MAX_PENDING_TOKEN_THRESHOLD = 1000000
+MAX_MESSAGE_COUNT_THRESHOLD = 1000
MAX_IDLE_TIMEOUT_SECONDS = 604800 # 7 days
_POLICY_KEYS = {
diff --git a/tests/server/test_api_content_write.py b/tests/server/test_api_content_write.py
index ddfe4b10b..69570e654 100644
--- a/tests/server/test_api_content_write.py
+++ b/tests/server/test_api_content_write.py
@@ -3,8 +3,12 @@
"""Tests for content write endpoint."""
+from types import SimpleNamespace
+
import pytest
+from openviking.server.routers import filesystem
+
async def _first_file_uri(client, root_uri: str) -> str:
resp = await client.get(
@@ -27,6 +31,31 @@ async def test_set_tags_endpoint_registered(client):
assert resp.status_code == 405
+async def test_fs_attrs_filters_legacy_non_kv_search_tags(monkeypatch):
+ class FakeVikingDBManagerProxy:
+ def __init__(self, *_args):
+ pass
+
+ async def filter(self, **_kwargs):
+ return [
+ {
+ "level": 2,
+ "search_tags": ["default", "team=search", "bad=", "channel=app"],
+ }
+ ]
+
+ monkeypatch.setattr(filesystem, "VikingDBManagerProxy", FakeVikingDBManagerProxy)
+
+ tags = await filesystem._tags_attr(
+ SimpleNamespace(vikingdb_manager=object()),
+ "viking://user/default/memories/events/example.md",
+ SimpleNamespace(),
+ is_dir=False,
+ )
+
+ assert tags == ["team=search", "channel=app"]
+
+
async def test_write_rejects_directory_uri(client_with_resource):
client, uri = client_with_resource
resp = await client.post(
diff --git a/tests/unit/session/test_auto_commit_policy.py b/tests/unit/session/test_auto_commit_policy.py
index 84e8f08b4..c24256c52 100644
--- a/tests/unit/session/test_auto_commit_policy.py
+++ b/tests/unit/session/test_auto_commit_policy.py
@@ -22,10 +22,10 @@ from openviking_cli.exceptions import InvalidArgumentError
def test_default_matches_prd_recommended_values():
policy = AutoCommitPolicy.default()
- assert policy.pending_token_threshold == DEFAULT_PENDING_TOKEN_THRESHOLD == 10000
- assert policy.message_count_threshold == DEFAULT_MESSAGE_COUNT_THRESHOLD == 50
+ assert policy.pending_token_threshold == DEFAULT_PENDING_TOKEN_THRESHOLD == 150_000
+ assert policy.message_count_threshold == DEFAULT_MESSAGE_COUNT_THRESHOLD == 100
assert policy.idle_timeout_seconds == DEFAULT_IDLE_TIMEOUT_SECONDS == 86400
- assert policy.keep_recent_count == DEFAULT_KEEP_RECENT_COUNT == 2
+ assert policy.keep_recent_count == DEFAULT_KEEP_RECENT_COUNT == 0
assert policy.min_commit_interval_seconds == DEFAULT_MIN_COMMIT_INTERVAL_SECONDS == 0
@@ -59,6 +59,8 @@ def test_from_dict_clamps_to_upper_bounds():
assert policy.idle_timeout_seconds == MAX_IDLE_TIMEOUT_SECONDS
assert policy.keep_recent_count == MAX_MESSAGE_COUNT_THRESHOLD
assert policy.min_commit_interval_seconds == MAX_IDLE_TIMEOUT_SECONDS
+ assert MAX_PENDING_TOKEN_THRESHOLD == 1_000_000
+ assert MAX_MESSAGE_COUNT_THRESHOLD == 1_000
def test_from_dict_clamps_negatives_to_zero():