Skip to content

Consolidation Operations

This page documents the HTTP API endpoints for triggering and monitoring memory consolidation tasks. Consolidation is AutoMem’s background maintenance system that mimics biological memory processes — decay, creative association, clustering, and forgetting.

For information about the consolidation engine’s internal architecture and algorithms, see Consolidation Engine.


AutoMem provides two REST endpoints for consolidation operations:

EndpointMethodPurposeAuth
/consolidatePOSTManually trigger consolidation tasksAPI token
/consolidate/statusGETQuery scheduler state and last run timesAPI token

The consolidation system runs automatically on scheduled intervals (configurable via environment variables), but these endpoints allow manual triggers for testing, debugging, or forcing immediate execution.


graph TB
    subgraph "API Layer"
        PostConsolidate["/consolidate<br/>POST endpoint"]
        GetStatus["/consolidate/status<br/>GET endpoint"]
    end

    subgraph "Consolidation Module"
        Scheduler["ConsolidationScheduler<br/>(Background thread)"]
        Consolidator["MemoryConsolidator<br/>(Task executor)"]
    end

    subgraph "Data Stores"
        FalkorGraph[("FalkorDB Graph<br/>GRAPH_NAME")]
        QdrantVectors[("Qdrant Vectors<br/>COLLECTION_NAME")]
        ControlNode["ConsolidationControl node<br/>(Graph metadata)"]
        RunHistory["ConsolidationRun nodes<br/>(Execution logs)"]
    end

    PostConsolidate -->|"Trigger task"| Consolidator
    GetStatus -->|"Query state"| Scheduler
    GetStatus -->|"Read history"| ControlNode
    GetStatus -->|"Read history"| RunHistory

    Scheduler -->|"Periodic check"| Consolidator
    Consolidator -->|"Read memories"| FalkorGraph
    Consolidator -->|"Semantic search"| QdrantVectors
    Consolidator -->|"Update relevance"| FalkorGraph
    Consolidator -->|"Create edges"| FalkorGraph
    Consolidator -->|"Archive/delete"| FalkorGraph
    Consolidator -->|"Record runs"| ControlNode
    Consolidator -->|"Record runs"| RunHistory

Manually trigger one or more consolidation tasks.

ParameterTypeRequiredDefaultDescription
taskstringNo"full"Task type to execute: decay, creative, cluster, forget, or full
forcebooleanNofalseBypass interval checks and execute immediately
TaskDefault IntervalDescriptionConfiguration Variable
decay3600s (1 hour)Apply exponential relevance decay to memoriesCONSOLIDATION_DECAY_INTERVAL_SECONDS
creative3600s (1 hour)Discover hidden associations (REM-like)CONSOLIDATION_CREATIVE_INTERVAL_SECONDS
cluster21600s (6 hours)Group semantically similar memoriesCONSOLIDATION_CLUSTER_INTERVAL_SECONDS
forget86400s (24 hours)Archive/delete low-relevance memoriesCONSOLIDATION_FORGET_INTERVAL_SECONDS
fullN/AExecute all four tasks in sequenceN/A
sequenceDiagram
    participant Client
    participant API as "POST /consolidate"
    participant Scheduler as ConsolidationScheduler
    participant Consolidator as MemoryConsolidator
    participant FalkorDB
    participant Qdrant

    Client->>API: "POST /consolidate<br/>{task: 'decay', force: false}"
    API->>API: "Validate API token"
    API->>API: "Normalize task parameter"

    alt task = "full"
        API->>Consolidator: "run_decay(force)"
        API->>Consolidator: "run_creative(force)"
        API->>Consolidator: "run_cluster(force)"
        API->>Consolidator: "run_forget(force)"
    else specific task
        API->>Consolidator: "run_<task>(force)"
    end

    Consolidator->>FalkorDB: "Query ConsolidationControl node"
    FalkorDB-->>Consolidator: "Last run timestamp"

    alt force=false and interval not elapsed
        Consolidator-->>API: "Skipped (too soon)"
        API-->>Client: "200 {status: 'skipped'}"
    else proceed
        Consolidator->>FalkorDB: "Read Memory nodes"
        Consolidator->>Qdrant: "Search vectors (if needed)"
        Consolidator->>FalkorDB: "Update nodes/edges"
        Consolidator->>FalkorDB: "Create ConsolidationRun node"
        Consolidator-->>API: "Results + metrics"
        API->>Scheduler: "Update next_run times"
        API-->>Client: "200 {status: 'success', results: {...}}"
    end
{
"status": "success",
"task": "decay",
"results": {
"updates": 42,
"duration_seconds": 1.23
}
}

For task="full", the results object contains combined metrics from all four tasks:

{
"status": "success",
"task": "full",
"results": {
"decay": { "updates": 42, "duration_seconds": 1.23 },
"creative": { "associations": 8, "duration_seconds": 2.45 },
"cluster": { "clusters": 3, "duration_seconds": 5.67 },
"forget": { "forgotten": 2, "duration_seconds": 0.89 }
}
}

When force=false and the interval hasn’t elapsed:

{
"status": "skipped",
"task": "decay",
"reason": "Last run was 300 seconds ago. Next run in 3300 seconds."
}
{
"error": "Consolidation task 'decay' failed: Connection refused"
}

Trigger full consolidation (forced):

Terminal window
curl -X POST https://your-automem-instance/consolidate \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"task": "full", "force": true}'

Trigger single task (decay):

Terminal window
curl -X POST https://your-automem-instance/consolidate \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"task": "decay", "force": false}'

Query the current state of the consolidation scheduler and retrieve execution history.

ParameterTypeRequiredDefaultDescription
history_limitintegerNo20Number of recent execution records to return (0–100)
{
"scheduler": {
"running": true,
"tick_seconds": 60
},
"last_run": {
"decay": "2025-01-15T08:00:00Z",
"creative": "2025-01-15T08:00:00Z",
"cluster": "2025-01-15T06:00:00Z",
"forget": "2025-01-15T00:00:00Z"
},
"next_run": {
"decay": "2025-01-15T09:00:00Z",
"creative": "2025-01-15T09:00:00Z",
"cluster": "2025-01-15T12:00:00Z",
"forget": "2025-01-16T00:00:00Z"
},
"intervals": {
"decay": 3600,
"creative": 3600,
"cluster": 21600,
"forget": 86400
},
"history": [
{
"task": "decay",
"timestamp": "2025-01-15T08:00:00Z",
"duration_seconds": 1.23,
"updates": 42
},
{
"task": "creative",
"timestamp": "2025-01-15T08:00:00Z",
"duration_seconds": 2.45,
"associations": 8
}
]
}
FieldTypeDescription
scheduler.runningbooleanWhether the background scheduler thread is active
scheduler.tick_secondsintegerPolling interval for the scheduler loop
last_run.<task>string (ISO 8601)Timestamp of most recent execution
next_run.<task>string (ISO 8601)Calculated next execution time
intervals.<task>integerConfigured interval in seconds
history[].taskstringTask type that was executed
history[].timestampstring (ISO 8601)Execution start time
history[].duration_secondsfloatTime taken to complete
history[].updatesintegerNodes updated (decay task)
history[].associationsintegerEdges created (creative task)
history[].clustersintegerMetaMemory nodes created (cluster task)
history[].forgottenintegerMemories archived/deleted (forget task)

Check last run times:

Terminal window
curl "https://your-automem-instance/consolidate/status" \
-H "Authorization: Bearer YOUR_TOKEN"

Query recent execution history:

Terminal window
curl "https://your-automem-instance/consolidate/status?history_limit=50" \
-H "Authorization: Bearer YOUR_TOKEN"

Consolidation state is persisted in FalkorDB using two node types:

Properties correspond to the CONSOLIDATION_TASK_FIELDS mapping in app.py. A single ConsolidationControl node (with ID controlled by CONSOLIDATION_CONTROL_NODE_ID, defaulting to "global") stores the last run timestamps for all four tasks.

Each execution creates a timestamped record stored as a ConsolidationRun node in FalkorDB. The /consolidate/status endpoint reads the most recent ConsolidationRun nodes ordered by timestamp descending, respecting the history_limit parameter (default 20, max 100).


Consolidation behavior is controlled via environment variables:

VariableDefaultDescription
CONSOLIDATION_TICK_SECONDS60Scheduler loop polling interval
CONSOLIDATION_DECAY_INTERVAL_SECONDS3600Minimum time between decay runs
CONSOLIDATION_CREATIVE_INTERVAL_SECONDS3600Minimum time between creative runs
CONSOLIDATION_CLUSTER_INTERVAL_SECONDS21600Minimum time between cluster runs
CONSOLIDATION_FORGET_INTERVAL_SECONDS86400Minimum time between forget runs
CONSOLIDATION_DECAY_IMPORTANCE_THRESHOLD0.3Skip decay for memories above this importance
CONSOLIDATION_HISTORY_LIMIT20Default number of history records to return
CONSOLIDATION_CONTROL_NODE_ID"global"ID of the ConsolidationControl node

Example configuration:

Terminal window
CONSOLIDATION_TICK_SECONDS=30
CONSOLIDATION_DECAY_INTERVAL_SECONDS=1800
CONSOLIDATION_CREATIVE_INTERVAL_SECONDS=3600
CONSOLIDATION_CLUSTER_INTERVAL_SECONDS=14400
CONSOLIDATION_FORGET_INTERVAL_SECONDS=43200
CONSOLIDATION_DECAY_IMPORTANCE_THRESHOLD=0.4

Both endpoints require authentication using the AUTOMEM_API_TOKEN. Three authentication methods are supported:

  1. Bearer Token (recommended): Authorization: Bearer <token>
  2. Custom Header: X-API-Key: <token>
  3. Query Parameter (discouraged in production): ?api_key=<token>

Requests without valid authentication receive a 401 Unauthorized response.


StatusConditionResponse
400 Bad RequestInvalid task parameter{"error": "Invalid task type: xyz"}
400 Bad Requesthistory_limit out of range{"error": "history_limit must be between 0 and 100"}
401 UnauthorizedMissing or invalid token{"error": "Unauthorized"}
StatusConditionResponse
500 Internal Server ErrorDatabase connection failure{"error": "Consolidation task 'decay' failed: ..."}
500 Internal Server ErrorTask execution exception{"error": "Failed to query consolidation status: ..."}

All errors are logged with full stack traces to facilitate debugging.


The ConsolidationScheduler runs in a background thread started at application initialization. It periodically checks whether each task’s interval has elapsed and executes tasks automatically without manual triggers.

The /consolidate endpoint bypasses this automatic scheduling when force=true is provided, allowing immediate execution regardless of the last run time.