Merge two entity memories into one
TIE AI Gateway
When the graph ends up with two entity nodes that represent the same real-world thing — Fauzaan and Mohamed Fauzaan, or Acme and Acme Inc. — you can now collapse them in one call:
POST /memories/{agent_id}/merge
{
"primary_id": "node-uuid-keep",
"duplicate_id": "node-uuid-fold-in"
}What it does
- Every live edge incident to
duplicate_idis repointed atprimary_id. The original edge is soft-deleted so the timeline is preserved for undo. - The duplicate node is marked with
merged_intoand disappears from List Memories, Search, and the Memory Graph response. - An
IS_DUPLICATE_OFaudit edge is written from duplicate → primary for traceability. - The primary’s
summary,attributes, andlabelsare rewritten by the LLM to combine both records into one canonical view. Itsnameis kept as-is, so pick the more specific or canonical node asprimary_id. - LLM enrichment is best-effort — on a model outage the merge falls back to a blind rewire and the response sets
enriched: false.
Caveats
- Edge fact text is not rewritten. If an old edge said “Fauzaan likes tea”, that text persists; only the endpoint pointer changes.
- Duplicate facts are not deduped. If both nodes had similar relationships, you will see two live edges. The next memory-ingestion pass usually collapses them.
- Same-scope only. Both nodes must share the same user and
agent_id.
Why this matters
Before this endpoint, the only way to recover from a misextracted entity was to delete every memory tied to it and let the graph rebuild over time — costly and lossy. Merge gives you a non-destructive fix that preserves history and stays reversible.
See Merge Two Memories for the full reference.