chore: allow to choose how we store things in the vector database#417
chore: allow to choose how we store things in the vector database#417
Conversation
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
There was a problem hiding this comment.
Pull request overview
Adds a configurable “conversation storage mode” to control what parts of a conversation get persisted to the vector/knowledge base.
Changes:
- Introduces a
ConversationStorageModeoption (with defaults) and wires it into agent startup. - Exposes
conversation_storage_modeinAgentConfigand config metadata as a selectable field. - Updates KB persistence logic to store user-only, user+assistant, or whole-conversation blocks based on the chosen mode.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| core/state/pool.go | Passes conversation_storage_mode from config into agent options. |
| core/state/config.go | Adds conversation_storage_mode to config + UI metadata options. |
| core/agent/options.go | Defines ConversationStorageMode, default value, and option setter. |
| core/agent/knowledgebase.go | Implements storage behavior based on the configured mode. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func WithConversationStorageMode(mode ConversationStorageMode) Option { | ||
| return func(o *options) error { | ||
| switch mode { | ||
| case StoreUserOnly, StoreUserAndAssistant, StoreWholeConversation: | ||
| o.conversationStorageMode = mode | ||
| default: | ||
| o.conversationStorageMode = StoreUserOnly | ||
| } | ||
| return nil | ||
| } | ||
| } |
There was a problem hiding this comment.
This option silently defaults to StoreUserOnly for invalid input, but the Option contract supports returning an error. Consider returning a non-nil error in the default branch (e.g., fmt.Errorf(\"invalid conversation storage mode: %q\", mode)) so misconfiguration is surfaced immediately instead of failing open to a default.
| case StoreUserOnly: | ||
| fallthrough | ||
| default: | ||
| // Store only user messages (default behavior) | ||
| for _, message := range conv { | ||
| if message.Role == "user" { | ||
| if err := a.options.ragdb.Store(message.Content); err != nil { | ||
| xlog.Error("Error storing into memory", "error", err) | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Using fallthrough into default makes the control flow a bit harder to scan and is easy to mis-edit later. Consider replacing this with a multi-value case (e.g., case StoreUserOnly, \"\":) and keeping default strictly for invalid/unknown modes, or removing fallthrough and handling StoreUserOnly explicitly.
| schedulerPollInterval: 30 * time.Second, | ||
| maxEvaluationLoops: 2, | ||
| enableEvaluation: false, | ||
| kbAutoSearch: true, // Default to true to maintain backward compatibility |
There was a problem hiding this comment.
The inline spacing/alignment here is inconsistent (true, // vs the next line). Consider normalizing formatting (or letting gofmt handle it) to keep the default options block uniformly readable.
| kbAutoSearch: true, // Default to true to maintain backward compatibility | |
| kbAutoSearch: true, // Default to true to maintain backward compatibility |
No description provided.