Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

docs(opencode-plugin): update Memory Recall section for chat.message hook (#1977) (#2004)

Evo22e86a7e18a3
diff --git a/examples/opencode-memory-plugin/README.md b/examples/opencode-memory-plugin/README.md
index fec53eb98..6e7e96e82 100644
--- a/examples/opencode-memory-plugin/README.md
+++ b/examples/opencode-memory-plugin/README.md
@@ -190,18 +190,18 @@ const result = await memcommit({})
## Memory Recall
-The plugin can automatically search OpenViking memories and inject relevant context into each user message before it reaches the LLM. This uses OpenCode's `experimental.chat.messages.transform` hook.
+The plugin can automatically search OpenViking memories and inject relevant context into each user message before it reaches the LLM. This uses OpenCode's `chat.message` hook to prepend a synthetic memory part to the outgoing message.
-> **Note**: This feature relies on an experimental OpenCode API. The hook signature or behavior may change in future OpenCode versions.
+> **Note**: This feature relies on OpenCode's `chat.message` hook contract. The hook signature or behavior may change in future OpenCode versions.
### How It Works
-1. On every user message, the plugin extracts the latest user text
+1. On every user message, the plugin extracts text from the message parts
2. Searches OpenViking using semantic search (5-second timeout)
3. Ranks results using multi-factor scoring (base score + leaf boost + temporal boost + preference boost + lexical overlap)
4. Deduplicates results (abstract-based for regular memories, URI-based for events/cases)
5. Formats matching memories as a `<relevant-memories>` XML block
-6. Appends the block to the user message's text part
+6. Prepends the block as a synthetic text part (`synthetic: true`) on the outgoing message so the memory persists across turns without polluting user input
If OpenViking is unavailable or the search times out, the message is passed through unchanged.