Skip to content

Configuration

All parameters are set via CognitiveMemoryConfig:

from cognitive_memory import CognitiveMemoryConfig
config = CognitiveMemoryConfig(
# ... parameters
)
mem = CognitiveMemory(config=config)
ParameterTypeDefaultDescription
faint_thresholdfloat0.15Retention below which a memory is “faint”
decay_modelstr"exponential"Decay curve: "exponential" or "power"
power_decay_gammafloat1.4427Gamma exponent for power-law decay (only used when decay_model="power")

The base decay rates and floors are defined as module-level constants:

ConstantValueDescription
BASE_DECAY_RATES[EPISODIC]45.0Episodic decay rate (days)
BASE_DECAY_RATES[SEMANTIC]120.0Semantic decay rate (days)
BASE_DECAY_RATES[PROCEDURAL]infinityProcedural never decays
BASE_DECAY_RATES[CORE]120.0Core decay rate (days)
DECAY_FLOORS["core"]0.60Core retention floor
DECAY_FLOORS["regular"]0.02Regular retention floor
ParameterTypeDefaultDescription
hybrid_searchboolFalseEnable hybrid (semantic + lexical) search
k_sparseint30Number of lexical candidates for hybrid search
ParameterTypeDefaultDescription
filter_expired_transientsboolTrueFilter out transient memories past their expiry
include_expired_in_deep_recallboolTrueInclude expired transients when deep recall is enabled
ParameterTypeDefaultDescription
graph_expansion_hopsint1Number of association hops for graph-based retrieval expansion
bridge_discoveryboolFalseEnable discovery of bridge paths between memories
max_bridge_pathsint3Maximum number of bridge paths to return
min_bridge_edge_weightfloat0.3Minimum edge weight for bridge path traversal
ParameterTypeDefaultDescription
retrieval_score_exponentfloat0.3Alpha in score = sim * R^alpha. Lower values ignore decay more.
ParameterTypeDefaultDescription
direct_boostfloat0.1Stability increase for direct retrieval
associative_boostfloat0.03Stability increase for associative retrieval
max_spaced_rep_multiplierfloat2.0Cap on spaced repetition factor
spaced_rep_interval_daysfloat7.0Days for 1x spaced rep factor
ParameterTypeDefaultDescription
core_access_thresholdint10Min retrievals for promotion
core_stability_thresholdfloat0.85Min stability for promotion
core_session_thresholdint3Min distinct sessions for promotion
ParameterTypeDefaultDescription
association_strengthen_amountfloat0.1Weight increase per co-retrieval
association_retrieval_thresholdfloat0.3Min weight to activate association
association_decay_constant_daysfloat90.0Exponential decay time constant
ParameterTypeDefaultDescription
consolidation_retention_thresholdfloat0.20Retention below which memories are consolidation candidates
consolidation_group_sizeint5Min group size for consolidation
consolidation_similarity_thresholdfloat0.70Min similarity for grouping
ParameterTypeDefaultDescription
cold_migration_daysint7Days at floor before cold migration
cold_storage_ttl_daysint180Days in cold before stub conversion
ParameterTypeDefaultDescription
deep_recall_penaltyfloat0.5Score multiplier for superseded memories
ParameterTypeDefaultDescription
run_maintenance_during_ingestionboolTrueRun tick() every 5 ingestions
ParameterTypeDefaultDescription
rerank_enabledboolFalseEnable LLM reranking of top candidates
k_rerankint10Number of top candidates to send to LLM for reranking
rerank_modelstr | NoneNoneModel for reranking; defaults to extraction model if not set
ParameterTypeDefaultDescription
extraction_modestr"semantic""raw" (verbatim turns), "semantic" (LLM facts), or "hybrid" (both)
extraction_modelstr"gpt-4o-mini"LLM for memory extraction
custom_extraction_instructionsstr | NoneNonePrepend to extraction prompt
ParameterTypeDefaultDescription
embedding_modelstr"text-embedding-3-small"Embedding model
embedding_dimensionsint1536Embedding vector dimensions

const mem = new CognitiveMemory({
adapter: new InMemoryAdapter(),
embeddingProvider: myEmbedder,
userId: "user-123",
config: {
// ... parameters
},
});

The TypeScript SDK exposes the same parameters as Python, using camelCase naming. Key parameters:

ParameterTypeDefaultDescription
defaultImportancenumber0.5Default importance for new memories
defaultStabilitynumber0.3Default stability for new memories
minRetentionnumber0.2Minimum retention for retrieval results
faintThresholdnumber0.15Retention below which memories are “faint”
decayRates.episodicnumber45Episodic decay rate (days)
decayRates.semanticnumber120Semantic decay rate (days)
decayRates.proceduralnumberInfinityProcedural decay rate (days)
decayRates.corenumber120Core decay rate (days)
retrievalScoreExponentnumber0.3Alpha in score = sim * R^alpha
directBoostnumber0.1Stability increase for direct retrieval
associativeBoostnumber0.03Stability increase for associative retrieval
coreAccessThresholdnumber10Min retrievals for core promotion
coreStabilityThresholdnumber0.85Min stability for core promotion
coreSessionThresholdnumber3Min distinct sessions for core promotion
consolidationRetentionThresholdnumber0.20Retention below which memories are consolidation candidates
consolidationGroupSizenumber5Min group size for consolidation
coldMigrationDaysnumber7Days at floor before cold migration
coldStorageTtlDaysnumber180Days in cold before stub conversion
deepRecallPenaltynumber0.5Score multiplier for superseded memories
decayModelstring"exponential"Decay curve: "exponential" or "power"
powerDecayGammanumber1.4427Gamma exponent for power-law decay
hybridSearchbooleanfalseEnable hybrid (semantic + lexical) search
kSparsenumber30Number of lexical candidates for hybrid search
filterExpiredTransientsbooleantrueFilter out transient memories past their expiry
includeExpiredInDeepRecallbooleantrueInclude expired transients when deep recall is enabled
graphExpansionHopsnumber1Number of association hops for graph-based retrieval expansion
bridgeDiscoverybooleanfalseEnable discovery of bridge paths between memories
maxBridgePathsnumber3Maximum number of bridge paths to return
minBridgeEdgeWeightnumber0.3Minimum edge weight for bridge path traversal
rerankEnabledbooleanfalseEnable LLM reranking of top candidates
kReranknumber10Number of top candidates to send to LLM for reranking
rerankModelstring | nullnullModel for reranking; defaults to extraction model if not set
extractionModestring"semantic""raw", "semantic", or "hybrid"
extractionModelstring"gpt-4o-mini"LLM for extraction
customExtractionInstructionsstring | nullnullPrepend to extraction prompt

config = CognitiveMemoryConfig(
# Decay
faint_threshold=0.15,
decay_model="exponential",
power_decay_gamma=1.4427,
# Hybrid search
hybrid_search=False,
k_sparse=30,
# Validity
filter_expired_transients=True,
include_expired_in_deep_recall=True,
# Graph
graph_expansion_hops=1,
bridge_discovery=False,
max_bridge_paths=3,
min_bridge_edge_weight=0.3,
# Retrieval scoring
retrieval_score_exponent=0.3,
# Retrieval boosting
direct_boost=0.1,
associative_boost=0.03,
max_spaced_rep_multiplier=2.0,
spaced_rep_interval_days=7.0,
# Core promotion
core_access_threshold=10,
core_stability_threshold=0.85,
core_session_threshold=3,
# Associations
association_strengthen_amount=0.1,
association_retrieval_threshold=0.3,
association_decay_constant_days=90.0,
# Consolidation
consolidation_retention_threshold=0.20,
consolidation_group_size=5,
consolidation_similarity_threshold=0.70,
# Tiered storage
cold_migration_days=7,
cold_storage_ttl_days=180,
# Deep recall
deep_recall_penalty=0.5,
# Ingestion
run_maintenance_during_ingestion=True,
# Extraction
extraction_mode="semantic",
extraction_model="gpt-4o-mini",
custom_extraction_instructions=None,
# Reranking
rerank_enabled=False,
k_rerank=10,
rerank_model=None,
# Models
embedding_model="text-embedding-3-small",
embedding_dimensions=1536,
)

See the Tuning guide for detailed advice on adjusting these parameters for your workload.

Key interactions to be aware of:

  • retrieval_score_exponent and direct_boost interact: higher alpha makes boosting more impactful
  • consolidation_retention_threshold and cold_migration_days together control when memories leave hot storage
  • core_access_threshold and core_stability_threshold create a compound requirement: lowering one doesn’t help if the other is too high