kg_consolidation
Knowledge-graph consolidation, pruning, and relationship decay.
Replaces background_agents/memory_consolidation.py. Runs as a
periodic background task to:
Merge near-duplicate entities (same category tier only).
Prune orphan entities with no relationships and low mention counts.
Decay relationship weights over time (tier-aware).
- async kg_consolidation.consolidate_graph(kg_manager, openrouter)[source]
Find and merge duplicate entities, prune orphans.
Only merges entities within the SAME category tier. Core entities are never pruned.
- Return type:
- Parameters:
kg_manager (KnowledgeGraphManager)
openrouter (OpenRouterClient)
- async kg_consolidation.decay_relationships(kg_manager, decay_factor=0.95)[source]
Apply weight decay to all non-core relationships.
Core (priority=100) never decay. Guild (priority=80) decay at half rate. All others decay at the full rate.
- Return type:
- Parameters:
kg_manager (KnowledgeGraphManager)
decay_factor (float)