-
Notifications
You must be signed in to change notification settings - Fork 1
Troubleshooting
Common issues and solutions for OpenCode Memory.
Problem: Web server fails to start because port 4747 is in use.
Solution: Change port in configuration:
Verify: Check if port is available:
lsof -i :4747Problem: Cannot create database or configuration files.
Solution: Fix permissions:
sudo chown -R $USER:$USER ~/.opencode-mem
sudo chown -R $USER:$USER ~/.config/opencodeProblem: TypeScript compilation fails.
Solution:
With Bun:
rm -rf node_modules
bun pm cache rm
bun install
bun run buildOr with npm:
rm -rf node_modules
npm cache clean --force
npm install
npm run buildProblem: Plugin fails to load with error:
Error: This build of sqlite3 does not support dynamic extension loading
at loadExtension (unknown)
at load (/Users/xxx/.cache/opencode/node_modules/sqlite-vec/index.mjs:55:6)
Root Cause:
Apple's SQLite build on macOS disables extension loading for security reasons. Bun uses Apple's SQLite by default for ~50% better performance, but this prevents sqlite-vec from loading.
Solution:
1. Install Homebrew SQLite
brew install sqlite2. Find the library path
brew --prefix sqliteThis will output something like:
- Apple Silicon:
/opt/homebrew/opt/sqlite - Intel Mac:
/usr/local/opt/sqlite
3. Configure custom SQLite path
Edit ~/.config/opencode/opencode-mem.jsonc:
{
"customSqlitePath": "/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib"
}Common paths:
-
Apple Silicon (M1/M2/M3):
/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib -
Intel Mac:
/usr/local/opt/sqlite/lib/libsqlite3.dylib
4. Restart OpenCode
The plugin will now use Homebrew's SQLite which supports extension loading.
Auto-Detection: If you don't configure customSqlitePath, the plugin will attempt to auto-detect Homebrew SQLite at common paths. However, manual configuration is recommended for reliability.
Verification: After configuration, check the logs for:
Using custom SQLite library { path: "/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib" }
Or if auto-detected:
Auto-detected and using Homebrew SQLite { path: "/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib" }
Still Not Working?
Verify Homebrew SQLite installation:
ls -la $(brew --prefix sqlite)/lib/libsqlite3.dylibCheck if the file exists:
file /opt/homebrew/opt/sqlite/lib/libsqlite3.dylibVerify it's a valid library:
otool -L /opt/homebrew/opt/sqlite/lib/libsqlite3.dylibAlternative Path: If your Homebrew installation is in a non-standard location:
find /usr/local /opt -name "libsqlite3.dylib" 2>/dev/null | grep homebrewThen use the full path in your config.
Performance Note: Using Homebrew SQLite on macOS may result in ~50% slower SQLite performance compared to Apple's optimized build. However, this is necessary for extension loading support.
Related Issues:
Problem: Database cannot be created or opened.
Solution:
- Check disk space:
df -h - Check permissions:
ls -la ~/.opencode-mem - Remove corrupted database:
rm ~/.opencode-mem/data/*.db - Restart OpenCode
Problem: Cannot access web interface at configured URL.
Solution:
- Verify server is running:
curl http://127.0.0.1:4747/api/stats- Check configuration:
{
"webServerEnabled": true,
"webServerPort": 4747,
"webServerHost": "127.0.0.1"
}- Check firewall settings
- Restart OpenCode
Problem: Web interface loads slowly or times out.
Solution:
- Reduce result limit in settings
- Run cleanup to reduce database size
- Run deduplication
- Increase similarity threshold
- Use smaller embedding model
Problem: Search returns no results or errors.
Solution:
- Verify embedding model is loaded
- Check database exists:
ls ~/.opencode-mem/data/ - Lower similarity threshold
- Restart OpenCode
Problem: Memory tool returns error when adding memory.
Solution:
- Verify required parameters:
memory({
mode: "add",
content: "Your content here",
scope: "user"
})- Check content is not empty
- Verify scope is "user" or "project"
- Check database is writable
Problem: Search query returns empty results.
Solution:
- Lower similarity threshold:
{
"similarityThreshold": 0.5
}- Verify memories exist:
memory({ mode: "list", scope: "user" })- Check embedding model is working
- Try different search query
Problem: Cannot find memory by ID.
Solution:
- Verify memory ID is correct
- List memories to get valid IDs:
memory({ mode: "list", scope: "user" })- Check memory wasn't deleted
- Verify database integrity
Problem: Automatic memory capture is not triggering.
Solution:
- Verify configuration:
{
"autoCaptureEnabled": true,
"memoryModel": "gpt-4",
"memoryApiUrl": "https://api.openai.com/v1",
"memoryApiKey": "sk-..."
}- Check API key is valid:
curl https://api.openai.com/v1/models \
-H "Authorization: Bearer sk-your-api-key"- Verify token threshold is reached:
memory({ mode: "auto-capture-stats" })- Check OpenCode logs for errors
Problem: Auto-capture runs but extracts no memories.
Solution:
- Increase context window:
{
"autoCaptureContextWindow": 5
}- Lower token threshold:
{
"autoCaptureTokenThreshold": 5000
}- Ensure conversation has extractable content
- Try different AI model
Problem: Auto-capture is expensive.
Solution:
- Switch to cheaper model:
{
"memoryModel": "gpt-3.5-turbo"
}- Increase threshold:
{
"autoCaptureTokenThreshold": 20000
}- Reduce context window:
{
"autoCaptureContextWindow": 2
}- Limit max memories:
{
"autoCaptureMaxMemories": 5
}Problem: Search takes too long to complete.
Solution:
- Reduce max memories:
{
"maxMemories": 3,
"maxProjectMemories": 5
}- Increase similarity threshold:
{
"similarityThreshold": 0.7
}- Run deduplication
- Use smaller embedding model:
{
"embeddingModel": "Xenova/all-MiniLM-L6-v2"
}Problem: OpenCode Memory uses too much RAM.
Solution:
- Enable auto-cleanup:
{
"autoCleanupEnabled": true,
"autoCleanupRetentionDays": 14
}- Reduce shard size:
{
"maxVectorsPerShard": 25000
}- Use smaller embedding model
- Run manual cleanup
Problem: Database files are very large.
Solution:
- Run cleanup:
POST /api/cleanup
{ "retentionDays": 30, "dryRun": false }- Run deduplication:
POST /api/deduplicate
{ "similarityThreshold": 0.9, "dryRun": false }- Vacuum database:
sqlite3 ~/.opencode-mem/data/memories_shard_0.db "VACUUM;"Problem: Embedding model fails to load.
Solution:
- Verify model name is correct:
{
"embeddingModel": "Xenova/nomic-embed-text-v1"
}- Check internet connection (first download)
- Clear model cache:
rm -rf ~/.cache/huggingface - Try different model
Problem: External embedding API returns errors.
Solution:
- Verify API credentials:
{
"embeddingApiUrl": "https://api.openai.com/v1",
"embeddingApiKey": "sk-..."
}- Check API endpoint is correct
- Verify API key has permissions
- Check rate limits
- Test API manually:
curl https://api.openai.com/v1/embeddings \
-H "Authorization: Bearer sk-..." \
-H "Content-Type: application/json" \
-d '{"input": "test", "model": "text-embedding-3-small"}'Problem: Vector dimension mismatch errors.
Solution:
Run migration to new dimensions:
POST /api/migrate
{
"newModel": "Xenova/all-MiniLM-L6-v2",
"newDimensions": 384
}Problem: SQLite database is locked.
Solution:
- Close all connections
- Restart OpenCode
- Check for zombie processes:
ps aux | grep opencode- Remove lock file:
rm ~/.opencode-mem/data/*.db-shm
rm ~/.opencode-mem/data/*.db-walProblem: Database file is corrupted.
Solution:
- Backup database:
cp -r ~/.opencode-mem/data ~/.opencode-mem/data.backup- Try recovery:
sqlite3 ~/.opencode-mem/data/memories_shard_0.db ".recover" | \
sqlite3 ~/.opencode-mem/data/memories_shard_0_recovered.db- If recovery fails, delete and start fresh:
rm ~/.opencode-mem/data/*.dbProblem: Cannot create new shard.
Solution:
- Check disk space:
df -h - Check permissions:
ls -la ~/.opencode-mem/data - Verify shard size setting:
{
"maxVectorsPerShard": 50000
}Problem: Configuration changes not taking effect.
Solution:
- Verify config file location:
cat ~/.config/opencode/opencode-mem.jsonc- Check JSON syntax (JSONC allows comments)
- Restart OpenCode
- Check logs for validation errors
Problem: Configuration validation errors.
Solution:
- Check required fields are present
- Verify value types (string, number, boolean)
- Ensure thresholds are 0.0-1.0
- Validate port numbers (1024-65535)
- Check file paths exist
Problem: Environment variables not recognized.
Solution:
- Export variables before starting OpenCode:
export OPENAI_API_KEY=sk-...
opencode- Add to shell profile:
echo 'export OPENAI_API_KEY=sk-...' >> ~/.bashrc
source ~/.bashrc- Verify variable is set:
echo $OPENAI_API_KEYProblem: Cleanup operation fails or does nothing.
Solution:
- Run in dry run mode first:
POST /api/cleanup
{ "retentionDays": 30, "dryRun": true }- Check retention days setting
- Verify memories are old enough
- Check pinned memories (excluded from cleanup)
Problem: Deduplication fails or removes wrong memories.
Solution:
- Use dry run mode:
POST /api/deduplicate
{ "similarityThreshold": 0.9, "dryRun": true }- Adjust similarity threshold
- Review duplicate groups before deleting
- Backup database first
Problem: Migration process hangs or fails.
Solution:
- Check logs for errors
- Verify new model is valid
- Ensure sufficient disk space
- Restart migration with smaller batch size
- If stuck, restart OpenCode
Add to configuration:
{
"logLevel": "debug"
}OpenCode logs location varies by platform:
Linux:
tail -f ~/.opencode/logs/opencode.logmacOS:
tail -f ~/Library/Logs/OpenCode/opencode.logWindows:
%APPDATA%\OpenCode\logs\opencode.log
Test REST API manually:
curl http://127.0.0.1:4747/api/stats
curl http://127.0.0.1:4747/api/memories?scope=userIf issues persist:
- Check GitHub Issues
- Search for similar problems
- Open new issue with:
- OpenCode version
- OpenCode Memory version
- Operating system
- Configuration (redact API keys)
- Error messages
- Steps to reproduce
- Configuration Guide - Detailed configuration
- Performance Tuning - Optimization strategies
- API Reference - REST API documentation
{ "webServerPort": 4748 }