merge_entities
Merge Entities ·writes · destructive · non-idempotent · closed-world
Merge duplicate entity rows into a canonical target.
Every entity_mentions row belonging to a source entity is
reassigned to target_entity_id; the source rows are deleted and
their canonical names are preserved as entity_aliases so the
upsert path won’t resurrect them on the next NER pass. Extra alias
strings supplied via aliases_to_add (e.g. misspellings the user
noticed in passing) are recorded the same way.
Returns: dict[str, Any]
Source: backend/src/engram/mcp/tools/entities/merge.py
Parameters
Integer
entities.id values to fold into the target. Must be non-empty and must not include the target.Integer
entities.id value of the surviving canonical row.Optional free-form strings to record as aliases pointing at the target. Whitespace-only entries are skipped and duplicates of existing aliases are ignored.Returns a dict shaped like
MergeEntitiesResult: {target_entity_id, merged_source_ids, aliases_added, mentions_reassigned, target_mention_count}.