Skip to content

feat(vika): treat peers as counterparts and give each instance its own OV user - #7092

Merged
krsish merged 1 commit into
volcengine:feat/vikafrom
krsish:feat/vika-ov-peer-identity
Nov 6, 2026
Merged

krsish merged 1 commit into
volcengine:feat/vikafrom
krsish:feat/vika-ov-peer-identity

Conversation

@krsish

@krsish krsish commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Description

OpenViking defines a peer as someone the user deals with: a person or another agent. Its docs separate the message-level peer_id (who said it) from actor_peer_id (which peer a request may see). Vika set actor_peer_id to the instance id. That is the legacy agent_id meaning of an agent's own identity, and it caused three problems:

  • Plugin capture: the runtime plugins stamped every captured message with peer_id = <instance id>. Whatever anyone in a chat said was filed as memory about a peer named after the bot. On a local instance, peers/asd/memories/preferences/ held the owner's own preferences, twice, under two spellings of the owner's name.
  • Daemon sync: the daemon's session sync sent every inbound line as a user message without a peer, so extraction filed what other people said as the owner's own memory. It also sent control lines that way.
  • Isolation: instances of one owner shared one OV user, and the peer filter does not cover user-level data. On one machine, a WeChat-only instance could recall another instance's mail archive and meeting notes.

This PR makes a peer mean the counterpart and makes each instance a user of its own. Decisions made with the requester:

  • The owner speaks as the OV user, with no peer. Other people and other bots are peers.
  • Instances are isolated by being different users.
  • The daemon is the only writer of the conversation. The plugins stop writing, but only in instances Vika launches.
  • Recall uses peer_scope=all with the sender as actor peer. Instances facing outsiders can use actor.
  • A mail sender is a peer by address. Addresses are unverified, so they are never merged with people.
  • No migration of existing memories or archives. Changing an instance's OV identity replays only the current epoch's journal into a fresh session.

What changes

Instances launched by Vika (deployment-config.cjs)

The runtime plugins no longer auto-capture, commit on compact, take over Pi compaction, derive a workspace peer or auto-recall. Pi's takeover is listed on its own because it syncs and commits the whole branch even with capture off.

Plugin session state, pending writes and the recall ledger move to <dataDir>/openviking/. These directories were shared through the home directory, so a Vika-launched Codex's session-start sweep committed and replayed the owner's own sessions through the instance's identity.

All of this is process environment, which the plugins rank above their config files, so the owner's own Codex, Claude Code and Pi keep their settings. Session-start injection and the plugins' MCP tools stay.

Setup: one OV user per instance (ov.mjs, ov-setup.mjs, setup.mjs)

  • Instance configs carry no actor_peer_id, peer_id or agent_id.
  • dev and Trusted servers take the user from the request, so the instance becomes <connection user>.<instance id>, for example weihan.liu.asd. The menu shows this with <instance name> until a new instance is named.
  • Under an API key, the key is the identity. A key that another instance or the owner's OpenViking CLI already uses is shared only if the owner chooses that ("memories are not kept apart"); otherwise the owner picks another key.
  • With an administrator's key the owner can create a user for the instance through register_user, including when editing the instance's current connection. Setup writes a new private config with the user's key; the existing config stays intact until the manifest is saved.
  • Setup reads the authenticated role and account from /health to offer registration.
  • Registration reuse is scoped to server, account and user, so switching between accounts with same-named administrators never reuses the other account’s key. The saved instance’s user key determines which registration is kept.
  • Going back reuses a registration; cancellation or failure deletes unused users and polls their background deletion tasks. Unfinished deletions and failures are reported separately.

Session sync attributes each line (ov-peer.mjs, harness.mjs, store.mjs, ov-session-context.mjs)

  • The harness decides each line's peer at ingest, when the connector's owner is known, and stores it with the journal row.
  • An owner line is a user message with no peer.
  • Anyone else's line is a user message with a message-level peer_id named after their channel identity: lark-<open_id>, slack-<team>-<user>, email-<address> or <source>-<id>. Names OV would reject are cleaned and get a digest.
  • Outbound lines, control lines and reminders (events without a sender) are assistant messages.
  • Rows recorded before this change are mirrored as before.
  • Sync cursors are bound to the server and authenticated account/user. Switching identity replays the current epoch in a fresh session; rotating a key for the same identity keeps its cursor. Recall and archive reads both use ovSessionFor(epoch), which exposes only a session verified for the current namespace.
  • After /new, the idle checkpoint syncs and fully commits retired epochs, including short conversations below the normal token threshold. Finalization retries survive restart and uncertain commit responses, and failures are logged with their cause.
  • A failure of the current epoch does not hold up retired ones, and the reverse. When OV cannot be reached at all, the retired epochs wait for the next check.
  • Legacy row verification happens once during identity binding. Rows that do not belong to the current namespace are logged together (ov_epochs_left_behind) and excluded from subsequent finalization; session() only handles the current namespace.

Recall by the daemon (ov-recall.mjs, agents[].ovRecallScope)

With ovAutoRecall, every runtime gets the same recall.

  • When: one context search (/api/v1/search/search, mode context) per direct message, mention of the agent, document comment or non-chat event such as mail. Bots and card clicks get none.
  • Scope: the sender is the actor peer, and the default scope is all. ovRecallScope: "actor" keeps other people's memories out.
  • Profile: the sender's peer profile goes first, because search never returns profiles.
  • Labels: every entry says whose it is with who= (owner, sender, or another person's name or id).
  • Dedup: once OV has the mirrored session, the search names it, and OV's ledger skips entries already served. The ledger is a separate file, not a session message.
  • Bound: 3 s. On timeout or failure the line goes on without recall.

core.md explains the block and adds one boundary rule: memory that is not the current person's own came from other conversations and is not passed on.

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

A maintainer pointed out that the peer usage was wrong. The requester made the design decisions listed above: peer as counterpart, user per instance, daemon as only writer, scope all, the naming rule, unverified mail senders and no migration. They also deployed the branch locally and reviewed the setup menu, which led to the instance-name placeholder. Implementation and tests are AI-assisted.

Related Issue

No linked issue. Based on feat/vika at cfcc7b3b6, with the PR changes squashed into one commit. Conflict resolution preserves the upstream explicitSilence default and adds ovRecallScope. Related: #6917 (MCP remember ignores the actor peer) and #7079 (Core OpenViking tools).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • deployment-config.cjs:
    • openVikingAgentEnv: plugin writes and auto-recall off, per-instance plugin state.
    • agents[].ovRecallScope.
    • VIKA_OV_AUTO_RECALL and VIKA_OV_RECALL_SCOPE.
  • packages/cli/src/ov.mjs:
    • detectOpenViking reports role and account.
    • instanceOvConfig derives or creates the instance identity.
    • writeInstanceOvConfig only writes.
    • OVRegistrations reuses registrations per account, keeps the saved user by key, and polls deletion tasks for unused users.
    • A single PEER_FIELDS definition is shared with setup.
  • packages/cli/src/ov-setup.mjs:
    • takenIdentities, the identity choice and the menu hint use a shared holder lookup.
    • saveOVConnection keeps no peer and no administrator key.
    • prepareInstanceOpenViking no longer carries the old actor over and honors registration even on the current config path.
  • packages/cli/src/setup.mjs: passes who else holds an identity; the success line names the instance's user.
  • packages/daemon/src/ov-peer.mjs (new): the peer id for a sender.
  • packages/daemon/src/harness.mjs: the peer at ingest, and recall on the ingress path.
  • packages/daemon/src/store.mjs: ingest(..., { peer }) stores the peer with the journal row.
  • packages/daemon/src/ov-session-context.mjs: ovAttribution sets each line’s role and peer_id; authenticated namespace binding protects sync cursors; retired epochs have durable finalization watermarks and a separate queue. Recall and archive reads share ovSessionFor, replacing separate link caches and raw-query fallbacks.
  • packages/daemon/src/ov-recall.mjs (new): the context search, sender profile and rendering.
  • packages/daemon/src/config.mjs, daemon.mjs: the recall switch and scope; the harness gets an OVRecall.
  • packages/daemon/agent/core.md: the recall block and the boundary rule.
  • Docs: README.md, install.md, docs/ov-session-context.md, config.example.json.
  • Tests:
    • Plugin env per instance.
    • Trusted, dev, API-key, shared-key and administrator-key identities.
    • The setup menu as a new instance and when editing one.
    • Peer naming, including ids OV would reject.
    • Owner and peer lines at ingest.
    • Roles and peer_id reaching OV.
    • Recall request headers and body, profile caching, the timeout, the dedup session, and which lines get recall.
    • Short-epoch finalization, pending deliveries, ambiguous commit responses, restart recovery, namespace changes, key rotation, legacy cursor verification, and registration from the current administrator connection.
    • A retired legacy epoch left under another connection: marked once, then quiet. The same epoch under the same connection is adopted and finalized.
    • A failing current epoch still lets retired epochs finalize. An unreachable OV leaves them for the next check, and failures say why.
    • A slow retired epoch does not delay fresh-session history or starve later retired epochs.
    • Same-named administrators in different accounts get distinct registered users and keys.
    • Cancellation waits for asynchronous deletion; completed, missing, failed and still-running deletions are handled separately.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

npm run check and git diff --check pass on the squashed commit 4cdb61e3e. With dependencies installed from the branch’s lockfile, npm test: 1150 tests, 1149 pass, 0 failures and 1 skipped. The complete suite was rerun after the rebase and review.

Against a local OpenViking 0.4.21 (Trusted, no key):

  • The installed Pi extension, resolving its config under the instance env, has capture and takeover off. Without OPENVIKING_WORKSPACE_PEER=0, dropping actor_peer_id would have made the peer github.1485827954.workers.dev-volcengine-openviking.
  • A message-level peer_id is stored. The session was deleted afterwards, and nothing was committed.
  • A context search returns origin, which maps to who=, in 0.4–0.9 s.
  • Deployed to two local instances:
    • The existing one (asd, unchanged config) records the owner's lines without a peer and adds a recall block to its Codex input.
    • A newly set up one (manbo) is weihan.liu.manbo and mirrors into viking://user/weihan.liu.manbo/sessions/….
  • Finalization was simulated on copies of both instances' databases, with reads against the real OV and writes recorded but not sent:
    • A simulated /new gives exactly one full commit of the retired epoch, and a second check adds none.
    • asd's two pre-upgrade epochs, left under its previous user, are marked once and then stay quiet.

Not run against a real server: register_user with an administrator key, and the hosted service's support for message-level peer_id.

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Additional Notes

  • Existing instances: they keep their config, shared user and actor_peer_id until the owner picks a connection again in setup. Their data is not moved.
    • Changing the server, account or user binds the mirror to a fresh session and replays the current epoch's journal. The old remote session and archives remain under the old identity. Pre-upgrade cursors are adopted only after checking their session URI; unlinked historical epochs of an unknown identity are not imported.
    • Old peers/<instance id> memories may be recalled labelled as that id.
  • Upgrading earlier test installs: a pre-upgrade retired epoch under the same connection is finalized on the first idle check after upgrade. Its lines were recorded before peers existed, so extraction files them under the owner. This is left to testers to handle by hand, because the release is still in internal testing.
  • Setup, administrator key — partially addressed: normal backtracking reuses the registered key within its account. Cancellation and handled failures delete unused users and poll deletion tasks with a 15-second waiting budget; pending cleanup tells the owner to retry later, and failures request administrator cleanup. The 409 message also explains that deletion may still be running. The registration ledger remains in memory, so a process crash or forced termination can leave a registered user requiring manual cleanup.
  • Memory latency: active epochs still use the 24k-token pending threshold and raw retention window. /new retires the epoch, and the next idle checkpoint commits its remaining conversation in full, including short conversations. OV performs memory extraction asynchronously after archiving.
  • Agent wording: an agent with no OV write tool (Codex without the plugin, Durable) may tell people it cannot remember. openviking.md still points to the skill and MCP tools and is left to feat(vika): expose the OpenViking tool surface to every runtime #7079. That PR will also conflict with this one in deployment-config.cjs, setup.mjs, config.mjs, README.md and install.md.
  • Peer server setting: peer memory needs memory_policy.peer on, which is the default on main. With it off, OV skips a peer's lines rather than filing them under the owner.
  • Trust on one machine: Codex runs with danger-full-access, so an agent can read other instances' OV configs on the same machine. A separate user keeps instances apart in normal operation, not against a hijacked agent.

🤖 Generated with Claude Code

…n OV user

OpenViking defines a peer as someone the user deals with. Vika used the
instance id as actor_peer_id (the legacy agent_id meaning), so every sender's
words were filed under one peer named after the bot, and the daemon's own
session sync filed them under the owner.

- Instances launched by Vika: the runtime plugins write nothing on their own
  and do not recall; their state lives under <dataDir>/openviking/. Only
  process env changes, so the owner's own Codex, Claude Code and Pi are
  unaffected.
- Setup makes each instance an OV user of its own: dev/Trusted derive
  <connection user>.<instance id>; under an API key a key another instance or
  the OV CLI uses is shared only when the owner says so, and an administrator
  key can create the instance's user (reused within a run per account, and
  deleted again, waiting for OV's background deletion, when unused).
- Session sync attributes each line: the owner as the user, others as a
  message-level peer_id named after their channel identity, the agent and
  daemon as assistant. Sync rows are bound to the authenticated namespace.
- After /new, retired epochs are committed in full in a queue of their own,
  so short conversations reach memory extraction without delaying the next
  session's history.
- The daemon recalls per line where the agent is likely to answer, with the
  sender as actor peer and who= on every memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@krsish
krsish force-pushed the feat/vika-ov-peer-identity branch from 4ebae4a to 4cdb61e Compare November 6, 2026 06:02
@krsish
krsish merged commit 0a596e0 into volcengine:feat/vika Nov 6, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Nov 6, 2026
nexw added a commit to nexw/OpenViking that referenced this pull request Nov 9, 2026
The branch had drifted 25 commits behind volcengine/openviking's feat/vika
since volcengine#7012: the OpenViking tool surface work (volcengine#7079), per-instance OV users
and peers (volcengine#7092), timers in OV (volcengine#7016), explicitSilence defaults (volcengine#7110),
image-heavy turns (volcengine#7113), stale implicit turns (volcengine#7021), the email connector
(volcengine#7144/volcengine#7145/volcengine#7148), Feishu chat scoping (volcengine#7149) and the Windows preview
chain (volcengine#7218-volcengine#7245).

Conflicts were all in files the superseded local commit a709961 touched;
resolution takes the upstream side, because volcengine#7079 replaced that design:
OpenViking tools now reach every runtime through the Core ActionService
(ov-tools.mjs), so the durable host keeps registering durableCodingTools()
and no longer wires its own MCP catalogue. The local-only
durable-ov-tools.mjs, its test, the @earendil-works/pi-mcp dependency and
DURABLE_OV are dropped with it; README.md, install.md and
docs/pi-durable-runtime.md take the upstream (English) rewrites.

vika/ is now byte-identical to origin-https/feat/vika; the merge keeps
origin/main already merged in.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant