Frontmatter
| id | 8346 |
| title | Refactor DatabaseService to Config-based Opt-Out Auto-Sync |
| state | Closed |
| labels | enhancementai |
| assignees | tobiu |
| createdAt | Jan 6, 2026, 1:45 AM |
| updatedAt | Jan 6, 2026, 2:10 AM |
| githubUrl | https://github.com/neomjs/neo/issues/8346 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Jan 6, 2026, 2:10 AM |
Refactor DatabaseService to Config-based Opt-Out Auto-Sync
tobiu assigned to @tobiu on Jan 6, 2026, 1:47 AM
tobiu changed title from Suppress DatabaseService Auto-Sync for External Scripts to Refactor DatabaseService to Opt-In Auto-Sync on Jan 6, 2026, 1:52 AM
tobiu changed title from Refactor DatabaseService to Opt-In Auto-Sync to Refactor DatabaseService to Config-based Opt-In Auto-Sync on Jan 6, 2026, 1:56 AM
tobiu changed title from Refactor DatabaseService to Config-based Opt-In Auto-Sync to Refactor DatabaseService to Config-based Opt-Out Auto-Sync on Jan 6, 2026, 1:58 AM

tobiu
Jan 6, 2026, 2:09 AM
Input from Gemini 3 Pro:
✦ I have successfully refactored
DatabaseServiceto use a Config-based "Opt-Out" strategy for Auto-Sync.Changes Implemented:
ai/mcp/server/knowledge-base/config.mjs:
- Added
autoSync: trueto thedefaultConfig.- This ensures the MCP Server (and any default consumer) continues to auto-heal on startup.
ai/mcp/server/knowledge-base/services/DatabaseService.mjs:
- Updated
initAsyncto checkaiConfig.data.autoSync.- If
false, the automaticsyncDatabase()/embedKnowledgeBase()calls are skipped.
ai/services.mjs(SDK Entry Point):
- Added
KB_Config.data.autoSync = falseat the top level.- This ensures that any script importing the AI SDK (e.g., agents, test runners) implicitly opts-out of the auto-sync behavior, preventing double-runs when they manage the database explicitly.
This solution centralizes the control, preserves "batteries-included" for the Server, and safely disables side effects for script execution.
tobiu closed this issue on Jan 6, 2026, 2:10 AM
tobiu cross-referenced by #8347 on Jan 6, 2026, 11:34 AM
DatabaseServicecurrently triggers an auto-sync/embed on startup. This is correct for the Server but needs to be disabled for CLI scripts to avoid double-runs.Goal: Use
KB_Configto allow scripts to Opt-Out of Auto-Sync.Plan:
config.mjs: AddautoSync: trueto the default configuration.DatabaseService.mjs: ModifyinitAsyncto checkaiConfig.data.autoSync. If false, skip the sync logic.ai/examples/sync_knowledge_base.mjs: Importconfig.mjsand setaiConfig.data.autoSync = falseat the top level.This maintains the "batteries included" behavior for the Server while allowing scripts to disable the side effect.