Skip to content

[Bug]: opencode-plugin ignores peerId from openviking-config.json whenever ovcli.conf or env credentials exist β€” memories land in shared user space instead of the peerΒ #4487

Description

@xdblue-tech

name: πŸ› Bug Report
about: Report a reproducible bug in OpenViking
title: "[Bug]: opencode-plugin ignores peerId from openviking-config.json whenever ovcli.conf or env credentials exist β€” memories land in shared user space instead of the peer"
labels: ''
assignees: ''

Issue Origin

Observed or reproduced in a real environment

Bug Description

@openviking/opencode-plugin (npm, v0.2.4) silently ignores the peerId set in the project's openviking-config.json whenever shared credentials exist (ovcli.conf or environment variables). The effective peer falls back to empty (with workspacePeer: false), so no peer id is sent at all: sessions and memories are written to the shared user space (viking://user/<user>/...) instead of a peer-scoped tree (viking://user/<user>/peers/<peerId>/...).

This is the same defect class as #3649 (Pi extension), which is still unfixed on main; the proposed fix in #3653 only touches examples/pi-coding-agent-extension/ and would not cover the OpenCode plugin.

Steps to Reproduce

  1. Authenticate the plugin via ~/.openviking/ovcli.conf containing url + api_key (no actor_peer_id set).
  2. Create a project config openviking-config.json:
    {
      "enabled": true,
      "peerId": "atomic-city",
      "recallPeerScope": "actor",
      "workspacePeer": false,
      "mcp": { "enabled": true },
      "timeoutMs": 30000,
      "repoContext": { "enabled": true, "cacheTtlMs": 60000 },
      "autoRecall": { "enabled": true, "limit": 6, "scoreThreshold": 0.35, "maxContentChars": 500, "preferAbstract": true, "tokenBudget": 2000, "minQueryLength": 3 },
      "commitTokenThreshold": 20000,
      "commitKeepRecentCount": 10,
      "profileTokenBudget": 10000,
      "resumeContextBudget": 32000
    }
  3. Start opencode in the project, have a conversation, let the session commit.

Expected Behavior

Effective peer id is atomic-city (per README: "Configure peerId … to override the workspace-derived peer"), and session messages / memories are stored under the peer scope (peer_id: atomic-city).

Actual Behavior

The file's peerId is dropped. Sessions and memories land in the shared user space; the server-side peers/ directory stays empty. Verified against OpenViking server v0.4.16 (Docker, ghcr.io/volcengine/openviking:v0.4.16) with opencode 1.18.25:

  • viking://default/user/xdblue/ contains 16 oc-ses_* sessions and all memories at the user root (memories/identity.md, memories/events/2026/08/29/*.md).
  • peers/ contains only .overview.md / .abstract.md scaffolding β€” no peer directories.
  • No peer_id field appears in any messages.jsonl or .meta.json under the user tree.
  • Auto-recall injections reference viking://user/xdblue/... URIs with no peer segment.

Minimal Reproducible Example

Root cause is in lib/config.mjs (v0.2.4, same logic on main):

  1. loadConfig() sets config.peerId = creds.peerId (line ~288), where creds.peerId comes only from OPENVIKING_PEER_ID or ovcli.conf actor_peer_id/peer_id (lib/shared/credentials.mjs lines ~184-197).
  2. The config file's own peerId is applied only inside applyLegacyConnection() (lines ~108-122), gated by:
    const mayUseLegacyCredentials = creds.credentialSource !== "env" &&
      creds.credentialSource !== "ovcli" &&
      !creds.apiKey && !creds.account && !creds.user && !creds.peerId
    With credentialSource === "ovcli" (the normal authenticated setup), the gate is false and the file's peerId is silently discarded.
  3. resolveEffectivePeerId() then skips the workspace fallback because workspacePeer: false, leaving the effective peer empty β€” so requests carry no peer id at all.

Net effect: the documented file-level peerId only works when there are no credentials anywhere, which is backwards; the common authenticated path (ovcli.conf) is exactly where it never works.

Error Logs

No error is logged β€” the drop is silent. The only observable symptom is peer-less storage server-side (see Actual Behavior).

OpenViking Version

0.4.16 (server, Docker image ghcr.io/volcengine/openviking:v0.4.16); plugin @openviking/opencode-plugin 0.2.4 (latest on npm)

Python Version

3.11 (server container)

Operating System

Linux (plugin host: Arch; server host: Debian 12, Docker)

Model Backend

None (issue is independent of model backend)

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions