traverse_relations
Walk the relation graph outward from an entity and get paths back — with a truncation flag you must check.
traverse_relations(entity_id: str, direction=None, relation_types=None, max_depth=None, max_nodes=None, include_superseded=None) -> TraverseResulttraverse_relations(request: RelationTraverseRequest) -> list[TraversalPathWire]
traverse_relations_frames(request: RelationTraverseRequest) -> list[RelationTraverseResponseFrame]Parameters
entity_idstringrequiredWhere to start. Positional on the HTTP tier; the wire field is startEntity.
directionstringoptionalWhich way to walk. An integer on the wire.
relation_typesstring[]optionalOnly follow these types. The single most effective way to keep a traversal cheap.
max_depthintegeroptionalHop limit.
max_nodesintegeroptionalNode budget.
include_supersededbooleanoptionalWalk through non-head versions too.
Returns
pathsTraversalPath[]alwaysEach a list of steps — relationId, from, to, relationType, depth, and resolved fromName / toName when available.
total_pathsintegeralwaysHow many were found.
truncatedbooleanalwaystrue means a budget stopped the walk and the result is partial.
Example
t = brain.traverse_relations(
priya_id, relation_types=["works_at", "reports_to"], max_depth=3, max_nodes=200
)
if t.truncated:
print("partial neighbourhood — raise max_nodes")
for p in t.paths:
print([f"{s.from_name} -[{s.relation_type}]-> {s.to_name}" for s in p.steps])Reporting a truncated traversal as the complete neighbourhood is the mistake this flag exists to prevent. Either raise the budget or tell the reader the view is partial — do not quietly present it as the whole graph.
The wire request adds timeAtUnixNanos: traverse the graph as it stood at
a moment, rather than as it stands now. It also has a frame-level form,
traverse_relations_frames.
On the wire
Entity ids are UUID bytes, properties is a propertiesBlob, and evidence
is a single reference rather than an array. Every request carries a
requestId plus an optional actAs.
Was this page helpful?