HUSK

Graph Tools

Tools for linking memories with typed edges and traversing the knowledge graph.

Graph tools let you build a knowledge graph on top of your memories. Connect memories with typed relationships, find neighbors, and walk causal chains.

Graph tools are available when the graph backend is enabled (sqlite or neo4j). See Configuration for setup.

Create a typed edge between two memories.

Cost: DB write only (no LLM)

Parameters

ParameterTypeRequiredDescription
source_idstringYesSource memory ID
target_idstringYesTarget memory ID
edge_type"caused_by" | "contradicts" | "supersedes" | "related_to"YesRelationship type
metadataobjectNoOptional metadata (max 4KB serialized JSON)

Edge types

TypeMeaning
caused_byA was caused by B
contradictsA conflicts with B
supersedesA replaces B
related_toGeneral relation

Example

{
  "source_id": "550e8400-e29b-41d4-a716-446655440000",
  "target_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
  "edge_type": "caused_by"
}

Remove an edge by its ID.

Cost: DB write only (no LLM)

Parameters

ParameterTypeRequiredDescription
edge_idstringYesThe edge ID to remove

Example

{
  "edge_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

Find direct neighbors of a memory in the knowledge graph.

Cost: DB read only (no LLM)

Parameters

ParameterTypeRequiredDescription
memory_idstringYesThe memory to find neighbors for
edge_type"caused_by" | "contradicts" | "supersedes" | "related_to"NoFilter by edge type
direction"outgoing" | "incoming" | "both"NoFilter by direction. Default: "both"
limitinteger (1–100)NoMax results. Default: 20

Example

{
  "memory_id": "550e8400-e29b-41d4-a716-446655440000",
  "edge_type": "caused_by",
  "direction": "incoming"
}

traverse

Walk the knowledge graph using breadth-first search. Finds causal chains, contradiction clusters, and related memory groups.

Cost: Multiple DB reads (no LLM)

Parameters

ParameterTypeRequiredDescription
memory_idstringYesStarting memory ID
edge_typesarray of edge typesNoOnly follow these edge types. Default: all
max_depthinteger (1–5)NoHow many hops to traverse. Default: 3
limitinteger (1–100)NoMax results. Default: 20

Example

{
  "memory_id": "550e8400-e29b-41d4-a716-446655440000",
  "edge_types": ["caused_by", "supersedes"],
  "max_depth": 2
}

Returns each memory with its depth and the path taken to reach it.

On this page