Skip to content

feat: surface edge counts in graph_search and graph_get#1459

Merged
Evanfeenstra merged 1 commit into
mainfrom
feature/jarvis-edge-counts
Jul 10, 2026
Merged

feat: surface edge counts in graph_search and graph_get#1459
Evanfeenstra merged 1 commit into
mainfrom
feature/jarvis-edge-counts

Conversation

@Evanfeenstra

Copy link
Copy Markdown
Collaborator

What

graph_search and graph_get (the Jarvis knowledge-graph tools agents use to traverse the graph) now include an edges map per node showing edge type → count:

{
  "ref_id": "abc-123",
  "node_type": "File",
  "name": "main.rs",
  "edges": { "CONTAINS": 5, "PART_OF": 4 }
}

Why

Lets an agent see how connected a node is and which relationship types it can hop along next (via graph_neighbors) directly from search/get results — no separate exploratory call needed to gauge connectivity.

How

  • graph_search: sends include_edge_counts=true so Jarvis attaches the edges map inline. One call, no per-node round trips.
    • Depends on stakwork/jarvis-backend#2976 (adds that param). Until it deploys, graph_search results simply carry edges: {}.
  • graph_get: calls the existing /v2/nodes/{ref_id}/connection-counts endpoint and collapses its (edge_type, target_type, count) rows into {EDGE_TYPE: count} via the new exported collapseConnectionCounts helper. Works today (endpoint already exists). Adds an optional namespace param so the count is scoped to the right partition. Best effort — never fails the call if the lookup errors.

Tests

  • New unit tests for collapseConnectionCounts (summing across target types, missing/non-numeric counts, empty input).
  • Updated graph_search URL-construction tests to assert include_edge_counts=true.
  • All 25 tests in toolsJarvis.test.ts pass; tsc --noEmit clean.

Both Jarvis knowledge-graph tools now return an "edges" map
({EDGE_TYPE: count}) per node so an agent can see how connected a node is
and which relationship types it can traverse next with graph_neighbors.

- graph_search: sends include_edge_counts=true so Jarvis attaches the
  edges map inline (one call, no per-node round trips).
- graph_get: fetches the existing /connection-counts endpoint and
  collapses its (edge_type, target_type, count) rows into {EDGE_TYPE:
  count} via the new exported collapseConnectionCounts helper. Adds an
  optional namespace param so the count is scoped correctly. Best effort:
  never fails the call if the lookup errors.

Adds unit tests for collapseConnectionCounts and the updated search URL.
@Evanfeenstra Evanfeenstra merged commit 75bbed5 into main Jul 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant