Skip to content

feat:Add OpenCode memory plugin example#569

Merged
yangxinxin-7 merged 3 commits intovolcengine:mainfrom
LittleLory:feat/opencode-memory-plugin-example
Mar 13, 2026
Merged

feat:Add OpenCode memory plugin example#569
yangxinxin-7 merged 3 commits intovolcengine:mainfrom
LittleLory:feat/opencode-memory-plugin-example

Conversation

@LittleLory
Copy link
Copy Markdown
Contributor

Summary

This PR adds an OpenCode memory plugin example for OpenViking.

The example exposes OpenViking as explicit OpenCode tools:

  • memsearch
  • memread
  • membrowse
  • memcommit

It also keeps the OpenCode conversation synchronized with an OpenViking session and uses background commit tasks for memory extraction.

Why this example

This example demonstrates a tool-based integration pattern for OpenCode.

Instead of relying on implicit prompt-time context injection, it lets the agent call OpenViking capabilities explicitly for memory search, content reading, filesystem-style browsing, and session commit.

That makes it a useful example for users who want direct memory operations and session-to-memory synchronization inside OpenCode.

Changes

  • add examples/opencode-memory-plugin/
  • add English and Chinese installation docs
  • document the tool-based integration mechanism
  • align installation with OpenCode's first-level local plugin auto-discovery
  • add links from the main README and Chinese README

Notes

The example is intentionally distributed as a single first-level plugin file under ~/.config/opencode/plugins, which matches OpenCode's local plugin discovery behavior.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@LittleLory LittleLory changed the title Add OpenCode memory plugin example feat:Add OpenCode memory plugin example Mar 13, 2026
@yangxinxin-7 yangxinxin-7 self-requested a review March 13, 2026 06:02
Copy link
Copy Markdown
Collaborator

@yangxinxin-7 yangxinxin-7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Dead code: extractMessageContent is never called

extractMessageContent is defined but never used anywhere — message.part.updated reads part.text directly. Please remove
it.


  1. AbortSignal listener is never removed in makeRequest

options.abortSignal.addEventListener("abort", () => controller.abort())

This listener leaks when the request completes normally. Use AbortSignal.any([options.abortSignal, controller.signal])
instead.


  1. sessionMessageBuffer is unbounded

If session.created never fires (e.g. OpenViking is down at startup), the buffer for that session grows forever with no
size limit or TTL. Consider capping it or periodically evicting stale entries.


  1. flushPendingMessages is called on every streaming token

In message.part.updated, flushPendingMessages is called for every partial update. During assistant streaming, all these
calls are no-ops (role isn't set until finish=stop), but they still iterate pendingMessages on every token. Consider only
flushing from message.updated.


  1. autoCommit.intervalMinutes is not validated

If set to 0 or a negative value, every scheduled check triggers a commit. Add Math.max(1, intervalMinutes) as a guard.

These issues were identified via AI-assisted code review. Please verify each one before acting on it.

@LittleLory
Copy link
Copy Markdown
Contributor Author

Thanks for the review. I’ve pushed updates to address the issues you pointed out.

Changes included:

  • removed the unused extractMessageContent
  • replaced the abort listener chaining in makeRequest with AbortSignal.any(...)
  • added bounds and TTL handling for sessionMessageBuffer, and also cleanup for stale buffered sessions
  • stopped calling flushPendingMessages from every message.part.updated event
  • clamped autoCommit.intervalMinutes to avoid invalid values triggering overly frequent commits

I also made two follow-up cleanups to reduce likely follow-up concerns:

  • avoided mutating the nested DEFAULT_CONFIG.autoCommit object when normalizing config
  • throttled global buffered-session cleanup so it does not scan on every buffered chunk

Let me know if you’d like me to split any of these changes further.

@yangxinxin-7 yangxinxin-7 merged commit cae2c37 into volcengine:main Mar 13, 2026
4 of 5 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 13, 2026
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.

3 participants