apply_memento_confidence_decay
Adjust memory confidence scores based on last access time to maintain knowledge freshness. Applies intelligent decay rules with different rates for critical, important, general, and temporary information.
Instructions
Apply automatic confidence decay based on last access time.
Use for:
System maintenance to keep knowledge base fresh
Applying intelligent decay rules
Monthly confidence adjustment routine
Intelligent decay rules:
Critical memories (security, auth, api_key, password, critical, no_decay tags): NO DECAY
High importance memories: Reduced decay based on importance score
General knowledge: Standard 5% monthly decay (decay_factor=0.95)
Temporary context: Higher decay rate
Decay formula: monthly_decay = confidence × decay_factor^(months_since_last_access)
Minimum confidence: 0.1 (won't decay below this)
Returns:
Number of relationships updated
Summary of decay applied
Breakdown by memory type
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| memory_id | No | Optional memory ID. When provided, applies decay only to relationships of that specific memory (and updates their decay_factor based on the memory's importance and tags). When omitted, applies decay to all relationships system-wide. |
Implementation Reference
- The exact handler function for the `apply_memento_confidence_decay` tool, which calculates the scope and invokes the database's confidence decay logic.
async def handle_apply_memento_confidence_decay( memory_db: SQLiteMemoryDatabase, arguments: Dict[str, Any] ) -> CallToolResult: """Handle apply_confidence_decay tool call. Args: memory_db: Database instance for memory operations arguments: Tool arguments from MCP call containing: - memory_id: Optional memory ID to apply decay only to its relationships Returns: CallToolResult with decay results or error message """ memory_id = arguments.get("memory_id") # Count total relationships before decay to compute skipped if memory_id: count_rows = await memory_db._execute_sql( "SELECT COUNT(*) as total FROM relationships WHERE from_id = ? OR to_id = ?", (memory_id, memory_id), ) else: count_rows = await memory_db._execute_sql( "SELECT COUNT(*) as total FROM relationships" ) total_rels = count_rows[0]["total"] if count_rows else 0 updated_count = await memory_db.apply_confidence_decay(memory_id) skipped = total_rels - updated_count # Build breakdown text scope = f"memory {memory_id}" if memory_id else "all memories (system-wide)" lines = [ f"**Confidence decay applied** ({scope})\n", f"| | Count |", f"|---|---|", f"| Relationships updated | {updated_count} |", f"| Skipped (no last_accessed or at min confidence 0.1) | {skipped} |", f"| Total relationships in scope | {total_rels} |", ] if updated_count == 0 and total_rels > 0: lines.append( "\n⚠️ All relationships were skipped — they may already be at minimum " "confidence (0.1) or have no `last_accessed` timestamp." ) return CallToolResult( content=[TextContent(type="text", text="\n".join(lines))] )