fix(openclaw): propagate historyDbPath into historyStore to prevent SQLITE_CANTOPEN crash loop#4160
Closed
nyrosveil wants to merge 2 commits intomem0ai:mainfrom
Closed
fix(openclaw): propagate historyDbPath into historyStore to prevent SQLITE_CANTOPEN crash loop#4160nyrosveil wants to merge 2 commits intomem0ai:mainfrom
nyrosveil wants to merge 2 commits intomem0ai:mainfrom
Conversation
When `oss.historyDbPath` is set in the plugin config, the value was correctly assigned to `config.historyDbPath` but was silently ignored at runtime. The cause: `mem0ai`'s `DEFAULT_MEMORY_CONFIG` always initialises `historyStore.config.historyDbPath` to `"memory.db"` (a relative path), and the Memory constructor always prefers `historyStore` over the top-level `historyDbPath` field when `historyStore` is present. Since `historyStore` is always truthy (merged from defaults), the explicit path set by the user was never used. When the gateway runs as a LaunchAgent with no `WorkingDirectory`, `process.cwd()` is `/` and `"memory.db"` resolves to `/memory.db` — unwritable on macOS due to SIP — causing `SQLITE_CANTOPEN` on every `before_agent_start` hook, crashing the gateway in a restart loop. Fix: when `historyDbPath` is set, also set `historyStore` explicitly so the Memory constructor uses the correct absolute path.
… fix Extracts the OSS Memory config-building logic from OSSProvider._init() into an exported buildOSSMemoryConfig() helper, making the fix directly unit-testable without requiring mem0ai/oss to be instantiated. Adds 13 tests in openclaw/tests/oss-history-db.test.ts (vitest) covering: - Base config shape with no/empty ossConfig - Passthrough of embedder, vectorStore, and llm provider configs - historyDbPath absent → historyStore not set - historyDbPath present → both historyDbPath and historyStore set - historyStore.config.historyDbPath matches the configured path (regression) - resolvePath applied to both historyDbPath and historyStore
|
Please prioritize this. 👍 |
utkarsh240799
approved these changes
Mar 9, 2026
7 tasks
deshraj
approved these changes
Mar 9, 2026
Contributor
|
Thanks for the thorough contribution and testing! This is no longer needed — PR #4307 (merged) fixes the root cause upstream in the |
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.
Description
Fixes a bug in the OpenClaw plugin where setting
oss.historyDbPathin the config had no effect, causing aSQLITE_CANTOPENcrash loop when running as a macOS LaunchAgent (service).Root cause
mem0ai'sDEFAULT_MEMORY_CONFIGalways initialiseshistoryStore.config.historyDbPathto"memory.db"(a relative path). TheMemoryconstructor always prefershistoryStoreover the top-levelhistoryDbPathfield whenhistoryStoreis present — and it is always present because it is merged from defaults. So the user-configuredhistoryDbPathwas never actually used.When the OpenClaw gateway runs as a LaunchAgent with no
WorkingDirectoryset (the default install),process.cwd()resolves to/. The relative"memory.db"then becomes/memory.db, which is unwritable on macOS (System Integrity Protection), causing:on every
before_agent_starthook — crashing the gateway in a continuous restart loop on each incoming message.Fix
OSSProvider._init()into an exportedbuildOSSMemoryConfig()helperhistoryDbPathis explicitly set, also setshistoryStoreto override the default, ensuring theMemoryconstructor uses the correct absolute pathFixes # (no existing issue — discovered and fixed in production)
Type of change
How Has This Been Tested?
Unit tests (
openclaw/tests/oss-history-db.test.ts, 13 tests via vitest):historyDbPathabsent →historyStorenot sethistoryDbPathpresent → bothhistoryDbPathandhistoryStoreset correctlyhistoryStore.config.historyDbPathmatches the configured path (regression test)resolvePathapplied to bothhistoryDbPathandhistoryStoreManual (production verification on macOS with gateway running as LaunchAgent):
Without fix: gateway crashed with
SQLITE_CANTOPENon every messageWith fix:
history.dbcreated at the specified absolute path, gateway runs stablyUnit Test
Test Script (manual — described above)
Checklist