OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: Agent Evolution lineage is never populated for the official Claude Code plugin - tool-name prefix mismatch + injection-based recall

Open devstar-korea opened this issue 3 months ago • 4 comments

Bug Description

GET /api/v1/agent-evolution/experiences/{trajectories,outcomes} returns an empty result for every Experience on our instance, including ones that have been revised 18 times. After tracing it end to end, the cause is not our data — the lineage tag the endpoint filters on can never be written when OpenViking is driven by the official Claude Code memory plugin (and, by the same reasoning, the OpenClaw plugin).

Two independent problems stack:

  1. a tool-name mismatch — the server only recognises the DeepSeek-Harness tool prefix, and
  2. an architectural mismatch — the official plugins are explicitly designed to recall without tool calls, and to strip the injected block before it reaches the session.

Problem 1 — the lineage matcher only knows the dsh tool prefix

AgentEvolutionService filters trajectories on a scalar tag derived from the Experience URI (service/agent_evolution_service.py:86):

Eq("search_tags", experience_source_tag(experience_uri))

That tag is only attached when collect_read_experience_uris finds a read tool call in the committed messages (session/memory/experience_lineage.py:152-158):

_READ_TOOL_OPERATIONS = {"read", "multi_read", "openviking_read",
                         "openviking_multi_read", "ov_read", "ov_multi_read"}
_MCP_OPENVIKING_READ_RE = re.compile(r"^mcp__openviking__(read|multi_read)$")

mcp__openviking__* is documented as the DeepSeek Harness prefix specifically:

"…published under mcp__openviking__*, so a server upgrade adds tools without a bundle release" — agent-integrations/16-capability-reference → dsh profile card, and 17-dsh

Meanwhile the capability reference states the server does not vary the surface per client:

"All MCP clients receive the exact same server-produced schema; there are no client-specific variants." — 16-capability-reference §2.1

So the prefix is chosen by each harness, and the Claude Code plugin publishes its tools as mcp__plugin_openviking-memory_openviking__<tool>. The lineage regex cannot match it. Two further mismatches in the same table:

  • multi_read is not among the 15 tools listed in §2.1 — it looks like a legacy name.
  • Matching is case-sensitive, so Claude Code's native Read never matches either. (The same class of issue is already acknowledged elsewhere: "uri-guard matches tool names without normalizing case.")

Measured on our instance (v0.4.15, Claude Code plugin 0.4.4):

tool name seen in committed sessions calls recognised by the lineage matcher
Read (Claude Code native) 19,136 ❌ (case)
mcp__plugin_openviking-memory_openviking__read 524 ❌ (prefix)
openviking_multi_read 11 ✅
— total ToolParts scanned 256,713 11 recognised

Problem 2 — the official plugins recall without tool calls, by design

Even with the regex fixed, the dominant recall path emits no tool call at all. This is intentional and documented:

"every conversation automatically recalls relevant memories and captures new content without requiring the model to make any tool calls." — agent-integrations/02-claude-code, opening paragraph

"auto-capture strips <openviking-context> … from each turn before pushing to OV. Without this, the recall context the plugin injects this turn would be captured back … creating a self-referential pollution loop." — plugin README, Memory pollution prevention

The OpenClaw design doc takes the same position explicitly:

"不新增 experience_recall 工具" (no experience_recall tool is added) "afterTurn 写 session 前剥离 <openviking-context>" (strip the block before writing the session)

But collect_read_experience_uris only iterates ToolParts (experience_lineage.py:121-127), and the API contract is defined in terms of reads:

"Return a paginated list of trajectories that successfully read the specified Experience." — api/19-agent-evolution.md

⇒ Injected recall is invisible to lineage, and the injected block is deliberately removed before the session is committed. The two halves cannot meet.

Impact

  • experiences/trajectories → total: 0 and outcomes → all-zero for every Experience, on an instance with 204 trajectories and 68 experiences actively being revised (one at version 18).
  • Experience effectiveness cannot be evaluated at all, so the Agent Evolution API is effectively unavailable to users of the official Claude Code plugin.
  • Silent: no error, no warning — the endpoints return status: "ok" with empty results, which is indistinguishable from "this Experience has not been used yet".

Suggested fixes

  1. Minimal, unblocks the one path that can work. The Claude Code plugin already tells the model to expand URIs with the read tool:
    auto-recall.mjs:255  "Relevant context from OpenViking. Use the read MCP tool to expand URIs."
    
    Widening the matcher so harness-prefixed names are recognised (e.g. match a (^|__)read$ / multi_read suffix after any mcp__…__ prefix, and normalise case) would make that path record lineage. This alone would turn the feature on for Claude Code users.
  2. Have the recall path itself record consumption. Since injection is the documented design, the server could record the Experience URIs it returned for a session's recall and treat those as "consumed", rather than depending on a later tool call that the plugins are designed not to make.
  3. Document the gap. ov grep "agent evolution" -u en/agent-integrations -i returns 0 matches across all 19 integration directories, and the Claude Code profile card and Verify checklist do not mention the feature. If lineage is currently dsh-only by design, saying so in the integration docs would save others this investigation.

OpenViking Version

v0.4.15 (pip wheel), Claude Code memory plugin 0.4.4

Python Version

3.12.12

Operating System

Windows 11 (x86_64), single local server, 1 account / ~940 memory files

devstar-korea avatar Aug 25 '26 19:08 devstar-korea

mcp__openviking__* is a common MCP prefix, not a DeepSeek harness plugin prefix.

mcp__plugin_openviking-memory_openviking__read looks like a new tool_name generated by CC. I will check.

from the solution part, suggest agent to use MCP tool to get experience files should be the right way.

ZaynJarvis avatar Aug 26 '26 06:08 ZaynJarvis

Thanks for the detailed investigation. We’ll update the lineage matcher to support harness-namespaced OpenViking MCP tool names, including mcp__plugin_openviking-memory_openviking__read. This will allow explicit Experience reads made through the official Claude Code plugin to be recognized correctly.

Auto-recall will not be included in this fix or counted as an Experience read for now. The reason is that auto-recall happens in the plugin hook, outside the agent’s tool-call flow:

  1. The plugin retrieves relevant memories and injects them directly into the prompt through an block.

  2. This process does not produce a read ToolPart.

  3. Before the conversation is captured into an OpenViking Session, the plugin deliberately removes the injected block to prevent recalled content from being written back into memory and causing self-referential pollution.

  4. Therefore, the committed Session contains neither a read tool call nor the injected Experience URI. The server-side lineage extractor has no reliable evidence that a specific Experience was consumed.

In addition, auto-recall only proves that an Experience was retrieved or injected; it does not prove that the agent actually read or applied it. Treating every injected Experience as an explicit read would overcount usage and distort trajectories/outcomes.

Supporting auto-recall attribution would require a separate provenance mechanism that records stages such as retrieved, injected, and possibly applied, instead of inferring usage from committed ToolParts. For now, Experience trajectories and outcomes will continue to track explicit read tool calls only.

heaoxiang-ai avatar Aug 26 '26 07:08 heaoxiang-ai

will check other possible tool names for plugins in future

ZaynJarvis avatar Aug 26 '26 08:08 ZaynJarvis

Additional data point for the "will check other possible tool names for plugins in future" follow-up — one harness surface that is not a namespaced MCP tool name, so widening the mcp__…__read pattern would not cover it.

Setup: v0.4.23, pi-based harness (OMP) with device-dispatch tools enabled (tools.xdev: true). In that mode the OpenViking tools are not registered as first-class tools; the model reaches them through a generic dispatch tool whose argument names the target device.

Observed: the agent did perform an explicit Experience read — it called the dispatch tool naming the OpenViking read device with the Experience's uris array, and the call completed. But the committed ToolPart carries tool_name: "write" (the dispatch tool), not read / openviking_read / ov_read, so collect_read_experience_uris (session/memory/experience_lineage.py) never matches it and no experience_source_tag is written.

A second attempt in the same session used the harness's native read with the viking:// URI directly; that one is rejected by the integration's URI guard (it redirects viking:// URIs to the OpenViking tools), so its tool_status is error and it is also excluded by the != "completed" filter.

Reproduction (disposable account, deterministic, low-cost model only):

  1. Session A — small multi-step coding task (failing unit test → locate defect → minimal fix → re-run to green) → commit → Case + Trajectory + Experience produced normally.
  2. Session B (separate disposable peer) — similar but not identical task; the agent reads the experience skill, calls the OpenViking find tool scoped to the experiences root, then reads the exact Experience URI (all completed calls) before making the fix. Task succeeds.
  3. GET /api/v1/agent-evolution/experiences/trajectories?experience_uri=… → total: 0; /outcomes → all-zero, for that Experience.

The reuse is recorded elsewhere — the Experience was revised (v2 → v4) and gained derived_from links to Session B's trajectories — so the gap is specifically in the ToolPart-derived lineage tag, for a different tool-surface shape than the one already diagnosed here.

Why the planned fix does not cover it: the matcher keys on tool_name (plus an optional mcp__…__(read|multi_read) suffix). In this configuration the tool name is a generic dispatch name (write) and the operation is only knowable from the argument payload (device path + uris). Prefix or case widening on the name cannot match it.

Possible directions (keeping the contract agreed in the thread — explicit reads only, no auto-recall attribution):

  • treat a dispatch call whose payload names the OpenViking read device as a read of the uris it carries; or
  • expose a first-class read tool name in device-dispatch configurations; or
  • document that device-dispatch tool surfaces are not lineage-visible, so an empty result is not misread as "never used".

Everything else here matches what I see: explicit tool reads are the only attribution source, and injected/auto-recall content is correctly not counted — the case above is an explicit read that simply never reaches the matcher.

edynasty avatar Oct 04 '26 16:10 edynasty