[Bug]: auto-recall with peer_scope=actor adds the same memories twice

Open Beginner friendly
#7,485 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, node.js
Domain
ai, backend

Research direction

Start with buildRecallBlockDetailed in examples/memory-plugin-shared/lib/recall-core.mjs and trace how the legacy peer result is combined with the actor result. Check the four plugin copies under examples/ for the same logic. Use the supplied repro.mjs steps to verify that the output contains one context block and each memory only once.

Written by the indexing model from the issue text.

Description

Issue Origin

Observed or reproduced in a real environment

Bug Description

With OPENVIKING_RECALL_PEER_SCOPE=actor, every prompt in Claude Code gets two <openviking-context> blocks instead of one. I looked at one prompt: 10 memories in each block, 7 of them the same.

It comes from buildRecallBlockDetailed in recall-core.mjs. When there is a legacy peer id it runs a second recallForPeer and just joins the two blocks. User-scope memories match both queries, so they show up twice. The same code is in all four plugin copies under examples/.

Not the same as #5433: that one is about other peers leaking into recall, this one is about the plugin repeating what both requests return.

Steps to Reproduce

Save as repro.mjs in the repo root and run node repro.mjs:

import { mkdtemp } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { buildRecallBlock } from "./examples/memory-plugin-shared/lib/recall-core.mjs";

// Both peers return the same user-scope memory, as the server does for user memories.
const fetchJSON = async () => ({
  ok: true,
  result: {
    rendered: '<memory uri="viking://user/default/memories/preferences/style.md">prefers short answers</memory>',
    entries: [{ uri: "viking://user/default/memories/preferences/style.md" }],
    stats: {},
  },
});

const block = await buildRecallBlock(fetchJSON, { recallPeerScope: "actor" }, "hello", {
  actorPeerId: "github.com-o-r",
  legacyPeerId: "-Users-x-src-r",
  legacyCachePath: join(await mkdtemp(join(tmpdir(), "ov-")), "context-face.json"),
});
console.log((block.match(/<openviking-context/g) || []).length, "blocks,",
  (block.match(/style\.md/g) || []).length, "copies of style.md");
Expected Behavior

1 blocks, 1 copies of style.md: one block, each memory once.

Actual Behavior

2 blocks, 2 copies of style.md on main (c64e578). In real use it's about 1.4 KB of extra context on every prompt.

OpenViking Version

0.5.0 server, claude-code-memory-plugin 0.7.12; repro on main

Python Version

3.13.12 (the bug is in the Node plugin, Node v26.13.0)

Operating System

macOS

Dominant language
Python
Stars
41.8k
Forks
3.4k
Avg merge
19h 29m
Merged PRs (30d)
500

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from volcengine/OpenViking

All issues in volcengine/OpenViking

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.