Skip to main content
POST
https://api.memoclaw.com
/
v1
/
memories
/
consolidate
Consolidate Memories
curl --request POST \
  --url https://api.memoclaw.com/v1/memories/consolidate \
  --header 'Content-Type: application/json' \
  --data '
{
  "min_similarity": 123,
  "mode": "<string>",
  "namespace": "<string>",
  "dry_run": true
}
'
{
  "clusters_found": 123,
  "memories_merged": 123,
  "memories_created": 123,
  "clusters": [
    {
      "clusters[].memory_ids": [
        "<string>"
      ],
      "clusters[].similarity": 123,
      "clusters[].merged_into": "<string>"
    }
  ]
}
Price: $0.01 USDC Consolidate automatically finds and merges semantically similar memories. It uses vector similarity to identify clusters of redundant memories and merges them via rule-based or LLM-powered strategies.

Request Body

All fields are optional. The API auto-discovers similar memory pairs.
min_similarity
number
Minimum cosine similarity threshold for clustering (0.5–1.0). Default: 0.85. Higher = stricter matching.
mode
string
Merge strategy:
  • rule (default): Keep highest-importance memory, merge tags, soft-delete rest. Creates supersedes relationships.
  • llm: Synthesize a new memory from the cluster via LLM. Creates derived_from relationships.
namespace
string
Only consolidate memories in this namespace.
dry_run
boolean
If true, return clusters that would be merged without actually merging. Default: false.

Response (200 OK)

clusters_found
number
Number of similar memory clusters found.
memories_merged
number
Number of memories that were soft-deleted (merged into others).
memories_created
number
Number of new synthesized memories (LLM mode only).
clusters
array
Details of each cluster.

Example

curl -X POST https://api.memoclaw.com/v1/memories/consolidate \
  -H "Content-Type: application/json" \
  -d '{
    "min_similarity": 0.85,
    "mode": "rule",
    "dry_run": true
  }'
Response
{
  "clusters_found": 2,
  "memories_merged": 3,
  "memories_created": 0,
  "clusters": [
    {
      "memory_ids": ["uuid-1", "uuid-2"],
      "similarity": 0.92,
      "merged_into": "uuid-1"
    },
    {
      "memory_ids": ["uuid-3", "uuid-4", "uuid-5"],
      "similarity": 0.87,
      "merged_into": "uuid-3"
    }
  ]
}
In rule mode, the highest-importance memory survives and inherits tags from all merged memories. In llm mode, a new memory is synthesized that combines all unique information from the cluster.