tools.kg_anchoring_tools module

tools/kg_anchoring_tools.py — Agent-facing tools for the Limbic Anchoring pipeline (Phase 5.2).

Exposes:
kg_anchor_messages — Create SYNTHESIZED_FROM edges between messages and

existing graph entities.

async tools.kg_anchoring_tools.kg_anchor_messages(graph_query, message_uuids, entity_uuids, relation='SYNTHESIZED_FROM')[source]

Create typed edges between Message nodes and existing graph entities.

This is an idempotent MERGE operation — calling it multiple times with the same arguments produces exactly one edge per pair.

Parameters:
  • graph_query (Any) – Async callable (cypher, params) -> result.

  • message_uuids (list[str]) – List of redis_key values identifying Message nodes.

  • entity_uuids (list[str]) – List of entity uuid values.

  • relation (str) – Relationship type (default "SYNTHESIZED_FROM").

Return type:

dict[str, Any]

Returns:

Dict with {"edges_created": int, "skipped": bool}

Edge cases:
  • Empty message_uuids or entity_uuids: returns immediately with {"edges_created": 0, "skipped": True} — no Cypher emitted.