OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[openclaw-plugin] Auto-capture injects "[tool: name]" text placeholder, polluting long-term memory and auto-recall

Open njuboy11 opened this issue 5 months ago • 0 comments

Bug

In examples/openclaw-plugin/text-utils.ts extractNewTurnMessages, when an assistant message contains only tool calls (no text content), the plugin synthesizes a placeholder text part:

text: `[tool: ${toolNamesStr}]`,

This placeholder is then sent to the OpenViking server via the auto-capture (afterTurn) path. The server's VLM extractor treats it as if it were real assistant text and persists it as a long-term memory entry. On the next session, auto-recall injects these poisoned memories into the context, causing downstream models to echo "[tool: exec]" literally and degrade.

Repro

  1. Install @openviking/openclaw-plugin as a context-engine slot plugin
  2. Use the OpenClaw gateway with any agent that calls tools frequently
  3. Send a few turns with tool calls
  4. Inspect viking://user/default/memories/ and search for \[tool:
  5. Hundreds of matches will appear in both session messages.jsonl files and extracted long-term memories

Expected

  • \[tool: ...] should never appear in messages.jsonl assistant rows or in extracted memories
  • The server should not store this kind of metadata as content

Actual

  • 726 matches across 64 session files and 119 matches across 25 long-term memory files in our deployment
  • M3 (MiniMax) visibly echoes the pollution

Suggested fix

Replace the text placeholder with a structured type: "toolCall" part (the canonical format already used in context-engine.ts):

parts: toolNames.map((name) => ({ type: "toolCall", name }))

Plus a defensive regex in sanitizeUserTextForCapture to strip any legacy placeholder that may already exist in old data.

A reference patch is provided in the linked PR.

Environment

  • OpenClaw 2026.6.2-beta.1
  • openviking-server 0.3.24
  • Plugin version 2026.5.8
  • Ubuntu 24.04

njuboy11 avatar Jun 06 '26 15:06 njuboy11