feat(kg): bidirectional multi-hop traversal

Add reverse-edge UNION ALL to recursive CTE so traversal follows both
source→target and target→source edges. Reverse edges prefixed with ~
in via field (e.g. ~manages). Tool output shows directional arrows.
This commit is contained in:
viettranx committed 2026-03-31 17:55:27 +07:00
1 parent 9ad4a879d5
commit b99f119e37
2 files changed
+37 -1

No files matched your search

+5 -1
View File
@@ -110,7 +110,11 @@ func (t *KnowledgeGraphSearchTool) executeTraversal(ctx context.Context, agentID
for _, r := range results {
sb.WriteString(fmt.Sprintf("- [depth %d] %s (%s)", r.Depth, r.Entity.Name, r.Entity.EntityType))
if r.Via != "" {
sb.WriteString(fmt.Sprintf(" via %q", r.Via))
if strings.HasPrefix(r.Via, "~") {
sb.WriteString(fmt.Sprintf(" ←[%s]—", r.Via[1:]))
} else {
sb.WriteString(fmt.Sprintf(" —[%s]→", r.Via))
}
}
if r.Entity.Description != "" {
sb.WriteString(fmt.Sprintf("\n %s", r.Entity.Description))