Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(agent-evolution): recognize namespaced MCP reads (#4349)
agent1bb629461b87
diff --git a/openviking/session/memory/experience_lineage.py b/openviking/session/memory/experience_lineage.pyindex b213f6640..146e9b4fe 100644--- a/openviking/session/memory/experience_lineage.py+++ b/openviking/session/memory/experience_lineage.py@@ -22,7 +22,10 @@ _READ_TOOL_OPERATIONS = {"ov_read": "read","ov_multi_read": "multi_read",}-_MCP_OPENVIKING_READ_RE = re.compile(r"^mcp__openviking__(read|multi_read)$")+_MCP_OPENVIKING_READ_RE = re.compile(+ r"^mcp__(?:openviking|plugin_.+_openviking)__(read|multi_read)$",+ re.IGNORECASE,+)TRAJECTORY_OUTCOMES = ("success", "failure", "partial", "unknown", "unfinished")@@ -154,7 +157,7 @@ def _read_operation(tool_name: str) -> str | None:if operation is not None:return operationmatch = _MCP_OPENVIKING_READ_RE.fullmatch(name)- return match.group(1) if match is not None else None+ return match.group(1).lower() if match is not None else Nonedef _load_value(value: Any) -> Any:diff --git a/openviking/usage_reporter/extractors.py b/openviking/usage_reporter/extractors.pyindex 085b454f4..7f649c636 100644--- a/openviking/usage_reporter/extractors.py+++ b/openviking/usage_reporter/extractors.py@@ -36,7 +36,10 @@ _INJECTION_TOOL_OPERATIONS: dict[str, ToolOperation] = {"ov_read": "read","ov_multi_read": "multi_read",}-_MCP_OPENVIKING_TOOL_RE = re.compile(r"^mcp__openviking__(find|search|list|read|multi_read)$")+_MCP_OPENVIKING_TOOL_RE = re.compile(+ r"^mcp__(?:openviking|plugin_.+_openviking)__(find|search|list|read|multi_read)$",+ re.IGNORECASE,+)_MCP_SEARCH_RESULT_RE = re.compile(r"^- \[[^]]+\]\s+(viking://.+?)\s*$")_OPENVIKING_SEARCH_TABLE_ROW_RE = re.compile(r"^\s*\d+\s{2,}(?:memory|resource|skill)\s{2,}"@@ -90,7 +93,7 @@ def _tool_usage(tool_name: str) -> tuple[UsageKind, ToolOperation] | None:match = _MCP_OPENVIKING_TOOL_RE.fullmatch(name)if match is None:return None- operation = cast(ToolOperation, match.group(1))+ operation = cast(ToolOperation, match.group(1).lower())if operation in {"find", "search", "list"}:return "recall", operationreturn "injection", operationdiff --git a/tests/unit/session/memory/test_experience_lineage.py b/tests/unit/session/memory/test_experience_lineage.pyindex 8ecae41c4..876bb93dd 100644--- a/tests/unit/session/memory/test_experience_lineage.py+++ b/tests/unit/session/memory/test_experience_lineage.py@@ -80,7 +80,42 @@ def test_collect_read_experience_uris_supports_generic_openviking_reads():assert collect_read_experience_uris(messages, ctx=_ctx()) == [uri, opencode_uri][email protected]("tool_name", ["multi_read", "openviking_multi_read"])+ "tool_name",+ [+ "mcp__plugin_openviking-memory_openviking__read",+ "mcp__PLUGIN_openviking-memory_OpenViking__READ",+ ],+)+def test_collect_read_experience_uris_supports_plugin_namespaced_reads(tool_name):+ uri = "viking://user/alice/memories/experiences/plugin-read.md"+ messages = [+ Message(+ id="plugin-read",+ role="user",+ parts=[+ ToolPart(+ tool_id="plugin-read-1",+ tool_name=tool_name,+ tool_input={"uri": uri},+ tool_status="completed",+ )+ ],+ )+ ]++ assert collect_read_experience_uris(messages, ctx=_ctx()) == [uri]+++ "tool_name",+ [+ "multi_read",+ "openviking_multi_read",+ "mcp__plugin_openviking-memory_openviking__multi_read",+ "mcp__PLUGIN_openviking-memory_OpenViking__MULTI_READ",+ ],+)def test_collect_read_experience_uris_filters_failed_multi_read_results(tool_name):first_uri = "viking://user/alice/memories/experiences/first.md"failed_uri = "viking://user/alice/memories/experiences/failed.md"@@ -107,6 +142,25 @@ def test_collect_read_experience_uris_filters_failed_multi_read_results(tool_namassert collect_read_experience_uris(messages, ctx=_ctx()) == [first_uri]+def test_collect_read_experience_uris_ignores_other_plugin_read_tools():+ messages = [+ Message(+ id="other-plugin-read",+ role="user",+ parts=[+ ToolPart(+ tool_id="other-plugin-read-1",+ tool_name="mcp__plugin_other-memory_other__read",+ tool_input={"uri": "viking://user/alice/memories/experiences/other.md"},+ tool_status="completed",+ )+ ],+ )+ ]++ assert collect_read_experience_uris(messages, ctx=_ctx()) == []++def test_collect_read_experience_uris_ignores_removed_dedicated_tool():messages = [Message(diff --git a/tests/unit/usage_reporter/test_memory_usage_extractor.py b/tests/unit/usage_reporter/test_memory_usage_extractor.pyindex 62c35ec9c..1f349ae89 100644--- a/tests/unit/usage_reporter/test_memory_usage_extractor.py+++ b/tests/unit/usage_reporter/test_memory_usage_extractor.py@@ -240,7 +240,7 @@ async def test_memory_usage_extractor_parses_mcp_text_search_and_list_results():parts=[ToolPart(tool_id="call-find",- tool_name="mcp__openviking__find",+ tool_name="mcp__plugin_openviking-memory_openviking__find",tool_status="completed",tool_output=("Found 2 item(s):\n\n"@@ -352,6 +352,10 @@ async def test_memory_usage_extractor_canonicalizes_home_alias_list_uri():"mcp__openviking__read",{"uris": "viking://user/test/memories/experiences/read.md"},),+ (+ "mcp__plugin_openviking-memory_openviking__read",+ {"uris": "viking://user/test/memories/experiences/read.md"},+ ),],)async def test_memory_usage_extractor_recognizes_generic_read_tools(tool_name, tool_input):@@ -387,6 +391,8 @@ async def test_memory_usage_extractor_recognizes_generic_read_tools(tool_name, t"openviking_multi_read","ov_multi_read","mcp__openviking__multi_read",+ "mcp__plugin_openviking-memory_openviking__multi_read",+ "mcp__PLUGIN_openviking-memory_OpenViking__MULTI_READ",],)async def test_memory_usage_extractor_multi_read_counts_only_successful_experiences(tool_name):@@ -443,6 +449,12 @@ async def test_memory_usage_extractor_does_not_fuzzy_match_other_mcp_tools():tool_status="completed",tool_input={"uri": experience_uri},),+ ToolPart(+ tool_id="call-plugin-read",+ tool_name="mcp__plugin_other-memory_other__read",+ tool_status="completed",+ tool_input={"uri": experience_uri},+ ),],)]