feat: add store memory builtin tool#2233
Open
nkanf-dev wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new built-in store_memory tool intended to persist “durable” store-scoped memories as vectors (with a Store memory: prefix) so they can be retrieved via the existing RAG knowledge path.
Changes:
- Introduces
object/store_memory.goto create and save “store memory” vectors and expose them as a builtin tool (store_memory). - Registers
store_memoryinto the merged builtin registry for stores. - Extends the per-store prompt to instruct the model to call
store_memorywhen the user shares durable preferences/standing instructions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| object/store_memory.go | Implements vector-backed “store memory” persistence + builtin tool surface. |
| object/merge_agent_tools.go | Registers the new builtin in the merged registry. |
| controllers/message_answer.go | Nudges the model via prompt to use store_memory for durable preferences/instructions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+30
to
+31
| if bt := NewStoreMemoryBuiltin(store, lang); bt != nil { | ||
| reg.RegisterTool(bt) |
|
|
||
| func AddStoreMemory(store *Store, content string, lang string) (*Vector, error) { | ||
| if store == nil { | ||
| return nil, fmt.Errorf(i18n.Translate(lang, "object:The store should not be empty")) |
|
|
||
| text := normalizeStoreMemoryText(content) | ||
| if text == "" { | ||
| return nil, fmt.Errorf(i18n.Translate(lang, "object:The memory content should not be empty")) |
Comment on lines
+92
to
+96
| Store: store.Name, | ||
| Provider: embeddingProvider.Name, | ||
| File: "__store_memory__", | ||
| Index: 0, | ||
| Text: text, |
Comment on lines
+51
to
+60
| embeddingProviderName := store.EmbeddingProvider | ||
| if embeddingProviderName == "" { | ||
| embeddingProvider, _, err := GetEmbeddingProviderFromContext(store.Owner, "", lang) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if embeddingProvider == nil { | ||
| return nil, fmt.Errorf(i18n.Translate(lang, "object:Please add an embedding provider first")) | ||
| } | ||
| embeddingProviderName = embeddingProvider.Name |
Comment on lines
+30
to
+33
| if bt := NewStoreMemoryBuiltin(store, lang); bt != nil { | ||
| reg.RegisterTool(bt) | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a built-in store_memory tool that lets the model save durable store-scoped memories as vectors with a Store memory: prefix. Retrieval stays on the existing RAG path via GetNearestKnowledge(...), and the prompt now nudges the model to use the tool for long-term user preferences and standing instructions.