Skip to content

chore: allow to choose how we store things in the vector database#417

Merged
mudler merged 1 commit intomainfrom
chore/kb-save-type
Feb 14, 2026
Merged

chore: allow to choose how we store things in the vector database#417
mudler merged 1 commit intomainfrom
chore/kb-save-type

Conversation

@mudler
Copy link
Owner

@mudler mudler commented Feb 14, 2026

No description provided.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Copilot AI review requested due to automatic review settings February 14, 2026 22:06
@mudler mudler merged commit b5dacb0 into main Feb 14, 2026
3 of 4 checks passed
@mudler mudler deleted the chore/kb-save-type branch February 14, 2026 22:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ConversationStorageMode option (with defaults) and wires it into agent startup.
  • Exposes conversation_storage_mode in AgentConfig and 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.

Comment on lines +287 to +297
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
}
}
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +170 to 181
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)
}
}
}
}
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
schedulerPollInterval: 30 * time.Second,
maxEvaluationLoops: 2,
enableEvaluation: false,
kbAutoSearch: true, // Default to true to maintain backward compatibility
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
kbAutoSearch: true, // Default to true to maintain backward compatibility
kbAutoSearch: true, // Default to true to maintain backward compatibility

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants