Skip to main content

Background Processing

EngramDB includes a sophisticated background processing system that enables powerful “sleep-time compute” operations. This system allows the database to autonomously perform memory organization, enrichment, and optimization during idle periods.

Core Concepts

Background processing in EngramDB is built around a few key concepts:

Activity Tracking

The ActivityTracker monitors database usage to detect idle periods when background tasks can be run without impacting performance:

Task Management

The BackgroundTaskManager handles scheduling, prioritization, and execution of background tasks:

Trigger Types

Tasks can be triggered in several ways:
  • IdleTrigger: Runs tasks when the system has been idle for a specified period
  • PredictiveTrigger: Anticipates future queries based on past usage patterns

Task Types

EngramDB supports several types of background tasks:

Summarization

Automatically generates summaries of related memory nodes:
The result is a new memory node that contains the summary content.

Connection Inference

Intelligently discovers relationships between memory nodes:
This creates new Connection objects between related nodes.

Node Enrichment

Enhances existing memory nodes with additional context:

Query Prediction

Anticipates likely future queries and pre-computes results:

LLM Integration

The LLMProcessor component integrates with large language models to perform sophisticated processing tasks:

Configuration

Background processing can be configured to match your system’s resources and requirements:

Benefits of Background Processing

Background processing delivers several advantages:
  1. Knowledge Organization: Automatically organize and structure information
  2. Memory Consolidation: Generate higher-level insights from individual memories
  3. Efficiency: Optimize database structure during idle periods
  4. Query Performance: Pre-compute likely query results
  5. Context Enhancement: Enrich memories with additional information

Best Practices

  • Configure idle thresholds based on your application’s usage patterns
  • Set appropriate token and cost limits to control resource usage
  • Use task priorities to ensure the most important processing happens first
  • Consider providing custom prompts for more targeted background processing