GitHub
Memory System

Pruning Engine

Intelligent lifecycle management for memory, handling forgetting and garbage collection.

Storage: Deletes from all DBs

Purpose

The Pruning Engine acts as the system's "janitor". Just like human memory, the system must forget irrelevant details to maintain efficiency and relevance. It manages the deletion of low-utility or expired data.

Key Features

  • Graph Centrality: Prunes isolated nodes that have no strong connections to the rest of the knowledge graph.
  • Relevance Scoring: Before deleting questionable items, it can ask an LLM "Is this still important?" to ensure safety.

Functional Deep Dive

Pruning Logic

It deletes noise by analyzing graph topology (isolated nodes) and metadata (TTL expiration). It combines deterministic rules (Time-to-Live) with semantic checks (LLM Review) to prevent accidental data loss.

Pruning Logic Flow

API Reference

Pruning Engine provides endpoints for memory lifecycle management.

MethodEndpointDescription
POST/api/memory/v1/pruning/analyzeAnalyze pruning candidates
POST/api/memory/v1/pruning/executeExecute pruning operation
POST/api/memory/v1/pruning/ttlSet TTL for item
GET/api/memory/v1/pruning/ttl/item_idGet TTL information
GET/api/memory/v1/pruning/statsGet pruning statistics
GET/api/memory/v1/pruning/scheduleGet pruning schedule

SDK Reference

The Functor SDK provides a Python interface for pruning operations.

Analyzing and Executing Pruning

from functor_sdk import FunctorClient
client = FunctorClient(api_key="your-api-key")
# Analyze pruning candidates (dry run)
analysis = client.memory.pruning.analyze(
kg_name="user_knowledge",
criteria={
"max_age_days": 90,
"min_utility_score": 0.3
},
dry_run=True
)
print(f"Candidates for pruning: {analysis['candidate_count']}")
# Execute pruning
result = client.memory.pruning.execute(
kg_name="user_knowledge",
criteria={"max_age_days": 90},
dry_run=False
)
# Set TTL for specific item
client.memory.pruning.set_ttl(
item_id="item_123",
item_type="episode",
ttl_seconds=2592000, # 30 days
priority=5
)
# Get pruning statistics
stats = client.memory.pruning.get_stats()