For users who have installed the plugin and want to dive deeper
- Retrieval Settings
- Memory Injection Control
- Deduplication Settings
- OpenAI Embedding
- Cross-Project Memory Sharing
- Environment Variable Overrides
- Memory Tools Reference
This project uses Reciprocal Rank Fusion (RRF) to combine vector search and BM25 keyword search:
{
"retrieval": {
"mode": "hybrid",
"vectorWeight": 0.7,
"bm25Weight": 0.3,
"minScore": 0.2,
"rrfK": 60,
"recencyBoost": true,
"recencyHalfLifeHours": 72,
"importanceWeight": 0.4
}
}| Parameter | Default | Description |
|---|---|---|
mode |
"hybrid" |
Search mode: hybrid, vector-only, bm25-only |
rrfK |
60 |
RRF ranking constant, smaller values emphasize highly-ranked items |
minScore |
0.2 |
Minimum score threshold; results below this are filtered out |
recencyBoost |
true |
Enable recency boost |
recencyHalfLifeHours |
72 |
Half-life for recency boost (hours) |
importanceWeight |
0.4 |
Weight multiplier for importance |
score_final = score_base * (1 + importance_weight) * recency_multiplier
recency_multiplier = 2^(-hours_since_creation / half_life)
Scenario 1: Emphasize Latest Information
{
"retrieval": {
"recencyBoost": true,
"recencyHalfLifeHours": 24
}
}Scenario 2: Emphasize Importance
{
"retrieval": {
"importanceWeight": 0.6,
"recencyBoost": false
}
}Scenario 3: Strict Quality Filtering
{
"retrieval": {
"minScore": 0.4,
"rrfK": 30
}
}{
"injection": {
"mode": "adaptive",
"maxMemories": 5,
"minMemories": 2,
"budgetTokens": 4096,
"maxCharsPerMemory": 1200,
"summarization": "auto",
"summaryTargetChars": 400,
"scoreDropTolerance": 0.15,
"injectionFloor": 0.2,
"codeSummarization": {
"enabled": true,
"pureCodeThreshold": 500,
"maxCodeLines": 15,
"codeTruncationMode": "smart",
"preserveComments": true,
"preserveImports": false
}
}
}Always injects a fixed number of memories, regardless of content size.
{
"injection": {
"mode": "fixed",
"maxMemories": 3
}
}Best for: Backward compatibility, simple setups
Limits total injected tokens, accumulating memories until the budget is depleted.
{
"injection": {
"mode": "budget",
"budgetTokens": 1500,
"summarization": "truncate",
"summaryTargetChars": 400
}
}Best for: Token-sensitive deployments, context length limitations
Dynamically adjusts the number of injected memories based on the score drop-off.
{
"injection": {
"mode": "adaptive",
"maxMemories": 5,
"minMemories": 2,
"scoreDropTolerance": 0.15,
"injectionFloor": 0.2
}
}Best for: Quality-sensitive scenarios, avoiding low-relevance memories
| Mode | Description | Used For |
|---|---|---|
none |
No summarization, full text injected | Default, backward compatibility |
truncate |
Simple truncation with ellipsis | Fast, generic |
extract |
Key sentence extraction (text) / Structure-aware truncation (code) | High-quality summaries |
auto |
Content-aware (auto-selects truncate or extract) |
Recommended |
{
"codeSummarization": {
"enabled": true,
"pureCodeThreshold": 500,
"maxCodeLines": 15,
"codeTruncationMode": "smart",
"preserveComments": true,
"preserveImports": false
}
}| Parameter | Options | Description |
|---|---|---|
enabled |
true, false |
Whether to enable code summarization |
pureCodeThreshold |
500 |
Minimum characters to trigger pure code mode |
maxCodeLines |
15 |
Maximum number of code lines to preserve |
codeTruncationMode |
smart, signature, preserve |
smart: Smart truncation, signature: Keep signatures only, preserve: Keep full |
preserveComments |
true, false |
Whether to keep comments when truncating |
preserveImports |
true, false |
Whether to keep import blocks when truncating |
The system uses the following multipliers to estimate tokens:
- Chinese: 1 character ≈ 0.6 tokens
- English: 1 character ≈ 0.75 tokens
- Code: 1 character ≈ 1.0 token
{
"dedup": {
"enabled": true,
"writeThreshold": 0.92,
"consolidateThreshold": 0.95
}
}| Parameter | Default | Description |
|---|---|---|
enabled |
true |
Enable/disable deduplication |
writeThreshold |
0.92 |
Similarity threshold for marking as potential duplicate at write |
consolidateThreshold |
0.95 |
Similarity threshold for background auto-consolidation |
- Marking (at Write): New memories are compared with existing ones. If similarity ≥
writeThreshold, it is markedisPotentialDuplicate: true. - Consolidation (Background): Triggered by
session.compactedevents, automatically merges memory pairs with similarity ≥consolidateThreshold.
{
"retention": {
"effectivenessEventsDays": 90
}
}| Parameter | Default | Description |
|---|---|---|
effectivenessEventsDays |
90 |
Number of days to retain effectiveness events. Set to 0 to disable automatic cleanup. |
You can also configure this via environment variable:
export LANCEDB_OPENCODE_PRO_RETENTION_EVENTS_DAYS=90- Automatic Cleanup: When the plugin initializes, events older than the retention period are automatically deleted
- Manual Cleanup: Use the
memory_event_cleanuptool to manually trigger cleanup or export events before deletion - Scope Support: Cleanup can be scoped to project or global events
- Dry Run: Use
dryRun: trueto preview events that would be deleted without actually deleting them
The memory_stats tool now includes TTL information:
{
"eventTtl": {
"enabled": true,
"retentionDays": 90,
"expiredCount": 150,
"scopeBreakdown": {
"project:my-project": 100,
"global": 50
}
}
}Clean up expired events manually:
| Parameter | Type | Default | Description |
|---|---|---|---|
scope |
string | - | Optional scope filter |
dryRun |
boolean | false | Preview without deleting |
archivePath |
string | - | Optional path to export JSON before deletion |
Example:
{
"scope": "project:my-project",
"dryRun": true
}{
"embedding": {
"provider": "openai",
"model": "text-embedding-3-small",
"baseUrl": "https://api.openai.com/v1",
"apiKey": "sk-your-openai-key"
}
}export LANCEDB_OPENCODE_PRO_EMBEDDING_PROVIDER="openai"
export LANCEDB_OPENCODE_PRO_OPENAI_API_KEY="$OPENAI_API_KEY"
export LANCEDB_OPENCODE_PRO_OPENAI_MODEL="text-embedding-3-small"
export LANCEDB_OPENCODE_PRO_OPENAI_BASE_URL="https://api.openai.com/v1"- If
embedding.provider=openaibut missing API key → Initialization error - If
embedding.provider=openaibut missing model → Initialization error - If
embedding.provideris not set → Reverts to Ollama by default
Full migration process and gotchas: embedding-migration.md
For text-embedding-3-small:
- Price: $0.02 / 1M tokens
- 1000 characters ≈ 750 tokens
- 1000 memory captures (approx. 200 characters each) ≈ $0.003
The system automatically detects generic knowledge and scopes it globally:
GLOBAL_KEYWORDS = [
// Distribution
'docker', 'kubernetes', 'nginx',
// Databases
'postgresql', 'mongodb', 'redis',
// Cloud
'aws', 'gcp', 'azure',
// Version Control
'git', 'github',
// Protocols
'http', 'grpc', 'websocket'
]{
"includeGlobalScope": true,
"globalDetectionThreshold": 2,
"globalDiscountFactor": 0.7,
"unusedDaysThreshold": 30
}| Parameter | Default | Description |
|---|---|---|
globalDetectionThreshold |
2 |
Global threshold based on occurrences across projects |
globalDiscountFactor |
0.7 |
Global memories have their score discounted to 70% |
unusedDaysThreshold |
30 |
Number of idle days before global memories can be swept |
# Promote to global scope
memory_scope_promote id="abc123" confirm=true
# Demote to project scope
memory_scope_demote id="abc123" confirm=true
# List all global memories
memory_global_list
# List unused global memories
memory_global_list filter="unused"
All settings can be overridden via system environment variables:
| Variable | Config Map | Default |
|---|---|---|
LANCEDB_OPENCODE_PRO_PROVIDER |
provider |
"lancedb-opencode-pro" |
LANCEDB_OPENCODE_PRO_DB_PATH |
dbPath |
"~/.opencode/memory/lancedb" |
LANCEDB_OPENCODE_PRO_EMBEDDING_PROVIDER |
embedding.provider |
"ollama" |
LANCEDB_OPENCODE_PRO_EMBEDDING_MODEL |
embedding.model |
"nomic-embed-text" |
LANCEDB_OPENCODE_PRO_OLLAMA_BASE_URL |
embedding.baseUrl |
"http://127.0.0.1:11434" |
| Variable | Config Map |
|---|---|
LANCEDB_OPENCODE_PRO_OPENAI_API_KEY |
embedding.apiKey |
LANCEDB_OPENCODE_PRO_OPENAI_MODEL |
embedding.model |
LANCEDB_OPENCODE_PRO_OPENAI_BASE_URL |
embedding.baseUrl |
LANCEDB_OPENCODE_PRO_OPENAI_TIMEOUT_MS |
embedding.timeoutMs |
| Variable | Config Map | Default |
|---|---|---|
LANCEDB_OPENCODE_PRO_RETRIEVAL_MODE |
retrieval.mode |
"hybrid" |
LANCEDB_OPENCODE_PRO_VECTOR_WEIGHT |
retrieval.vectorWeight |
0.7 |
LANCEDB_OPENCODE_PRO_BM25_WEIGHT |
retrieval.bm25Weight |
0.3 |
LANCEDB_OPENCODE_PRO_MIN_SCORE |
retrieval.minScore |
0.2 |
LANCEDB_OPENCODE_PRO_RRF_K |
retrieval.rrfK |
60 |
LANCEDB_OPENCODE_PRO_RECENCY_BOOST |
retrieval.recencyBoost |
true |
LANCEDB_OPENCODE_PRO_RECENCY_HALF_LIFE_HOURS |
retrieval.recencyHalfLifeHours |
72 |
LANCEDB_OPENCODE_PRO_IMPORTANCE_WEIGHT |
retrieval.importanceWeight |
0.4 |
| Variable | Config Map | Default |
|---|---|---|
LANCEDB_OPENCODE_PRO_INJECTION_MODE |
injection.mode |
"fixed" |
LANCEDB_OPENCODE_PRO_INJECTION_MAX_MEMORIES |
injection.maxMemories |
3 |
LANCEDB_OPENCODE_PRO_INJECTION_MIN_MEMORIES |
injection.minMemories |
1 |
LANCEDB_OPENCODE_PRO_INJECTION_BUDGET_TOKENS |
injection.budgetTokens |
4096 |
LANCEDB_OPENCODE_PRO_INJECTION_MAX_CHARS |
injection.maxCharsPerMemory |
1200 |
LANCEDB_OPENCODE_PRO_INJECTION_SUMMARIZATION |
injection.summarization |
"none" |
LANCEDB_OPENCODE_PRO_INJECTION_SUMMARY_TARGET_CHARS |
injection.summaryTargetChars |
300 |
LANCEDB_OPENCODE_PRO_INJECTION_SCORE_DROP_TOLERANCE |
injection.scoreDropTolerance |
0.15 |
LANCEDB_OPENCODE_PRO_INJECTION_FLOOR |
injection.injectionFloor |
0.2 |
LANCEDB_OPENCODE_PRO_CODE_SUMMARIZATION_ENABLED |
codeSummarization.enabled |
true |
| Variable | Config Map | Default |
|---|---|---|
LANCEDB_OPENCODE_PRO_DEDUP_ENABLED |
dedup.enabled |
true |
LANCEDB_OPENCODE_PRO_DEDUP_WRITE_THRESHOLD |
dedup.writeThreshold |
0.92 |
LANCEDB_OPENCODE_PRO_DEDUP_CONSOLIDATE_THRESHOLD |
dedup.consolidateThreshold |
0.95 |
| Variable | Config Map | Default |
|---|---|---|
LANCEDB_OPENCODE_PRO_INCLUDE_GLOBAL_SCOPE |
includeGlobalScope |
true |
LANCEDB_OPENCODE_PRO_GLOBAL_DETECTION_THRESHOLD |
globalDetectionThreshold |
2 |
LANCEDB_OPENCODE_PRO_GLOBAL_DISCOUNT_FACTOR |
globalDiscountFactor |
0.7 |
LANCEDB_OPENCODE_PRO_UNUSED_DAYS_THRESHOLD |
unusedDaysThreshold |
30 |
LANCEDB_OPENCODE_PRO_MIN_CAPTURE_CHARS |
minCaptureChars |
80 |
LANCEDB_OPENCODE_PRO_MAX_ENTRIES_PER_SCOPE |
maxEntriesPerScope |
3000 |
Search long-term memory.
memory_search query="Your query" [scope="project:my-project"] [limit=10]
Output: A list of memories along with citation details [source|status]
Delete a single memory.
memory_delete id="abc123" confirm=true
Note: Required param confirm=true to prevent accidental deletion.
Clear all memories in a specific scope.
memory_clear scope="project:my-project" confirm=true
Note: Required param confirm=true to prevent accidental deletion.
Show memory statistics.
memory_stats [scope="project:my-project"]
Output:
{
"scope": "project:my-project",
"totalMemories": 150,
"oldestEntry": "2026-03-01T10:00:00Z",
"newestEntry": "2026-03-29T15:30:00Z"
}Manually store a new memory chunk.
memory_remember text="Memory content here" [scope="project:my-project"]
Remove or disable a specific memory.
memory_forget id="abc123" confirm=true [force=false]
| Parameter | Description |
|---|---|
force=false |
Soft-delete (default), leaves record but marks it deleted |
force=true |
Hard-delete, permanently removes record |
Display a summary of recent learning.
memory_what_did_you_learn [days=7] [scope="project:my-project"]
Report forgotten memories that should have been captured.
memory_feedback_missing text="Content that should be picked up" labels=["deployment", "docker"]
Report incorrect memory assertions.
memory_feedback_wrong id="abc123" reason="Outdated context"
Report whether memory was helpful.
memory_feedback_useful id="abc123" helpful=true
Show system effectiveness metrics.
memory_effectiveness [scope="project:my-project"]
Example output: ../README.md#viewing-metrics
Show weekly learning dashboard with trends and insights.
memory_dashboard [days=7] [scope="project:my-project"]
Parameters:
days(1-90): Time window for dashboard. Default: 7.scope: Filter to a specific scope. Default: current project.
Output includes:
- Current period capture/recall/feedback metrics
- Week-over-week trend indicators (improving/stable/declining/insufficient-data)
- Actionable insights for learning quality
- Recent memory breakdown by category
Show learning KPI metrics (retry-to-success rate and memory lift).
memory_kpi [days=30] [scope="project:my-project"]
Parameters:
days(1-365): Time window for KPI calculation. Default: 30.scope: Filter to a specific scope. Default: current project.
Metrics:
- Retry-to-success rate: (tasks succeeded after retries) / (total failed tasks)
- Memory lift: (success_rate_with_recall - success_rate_without_recall) / success_rate_without_recall
Status values: ok, insufficient-data (< 5 samples), no-failed-tasks, no-recall-data
Promote a memory to global scope.
memory_scope_promote id="abc123" confirm=true
Demote a memory back to project scope.
memory_scope_demote id="abc123" confirm=true
List global scope memories.
memory_global_list [query="keywords"] [filter="unused"]
Consolidate duplicate memories within a single scope.
memory_consolidate scope="project:my-project" confirm=true
Consolidate duplicates cross-scope.
memory_consolidate_all confirm=true
View/Update citation information.
# View
memory_citation id="abc123"
# Update status
memory_citation id="abc123" status="verified"
Validate citation status.
memory_validate_citation id="abc123"
Explain why a specific memory was recalled.
memory_why id="abc123"
Explain factors of the most recent recall operation.
memory_explain_recall
Create a new task episode tracking instance.
task_episode_create description="Task description" [scope="project:my-project"]
Query episode histories.
task_episode_query [scope="project:my-project"] [state="completed"]
Retrieve similar tasks via vector similarity.
similar_task_recall query="Task description" [threshold=0.85] [limit=5]
Suggest retry budgets based on histories.
retry_budget_suggest errorType="build-failed"
Suggest recovery strategies.
recovery_strategy_suggest taskId="task_123"
Plan robust, non-conflicting Docker Ports mappings.
memory_port_plan project="project-alpha" services='[{"name":"web","containerPort":3000}]' rangeStart=23000 rangeEnd=23999 persist=true
Full monitoring guide: operations.md
# General memory system health
memory_stats
# Effectiveness metrics
memory_effectiveness
# Global memories health
memory_global_list
# Potential duplicates identification
memory_consolidate scope="project:my-project" confirm=false
- High Search Latency: Increase
minScorethreshold, lowermaxEntriesPerScope - Low Recall: Lower
minScore, adjustrrfK, enablerecencyBoost - Excessive Token Consumption: Switch to
budgetmode limit, enforcesummarization
Last Updated: 2026-03-29
Supported Version: v0.5.0+