Skip to content

feat: recursive graph_sub_agent tool for Jarvis graph exploration#1461

Merged
Evanfeenstra merged 1 commit into
mainfrom
feat/graph-sub-agent
Jul 10, 2026
Merged

feat: recursive graph_sub_agent tool for Jarvis graph exploration#1461
Evanfeenstra merged 1 commit into
mainfrom
feat/graph-sub-agent

Conversation

@Evanfeenstra

Copy link
Copy Markdown
Collaborator

What

Adds a new graph_sub_agent tool to the Jarvis knowledge-graph toolset (mcp/src/repo/toolsJarvis.ts). It spawns an in-process child agent with its own copy of the graph tools (get_ontology, graph_search, graph_get, graph_neighbors) that explores based on a prompt from the parent and returns a synthesized text summary.

This lets a parent agent locate a few key nodes, then fan out one focused sub-agent per node/subtopic and collate their findings.

How

  • registerJarvisTools(allTools, options?) gains an optional options.subAgent config. The 4 read tools register as before; graph_sub_agent registers only when subAgent is present and the current recursion depth is below maxDepth.
  • graph_sub_agent.execute({ prompt }) builds a fresh child tool set by recursively calling registerJarvisTools with depth + 1, then runs a ToolLoopAgent (same LLM/provider via getModelDetails) with a dedicated system prompt, returning extractFinalAnswer(...). Mirrors the existing log_agent_context pattern.
  • Depth capping: maxDepth defaults to 2. Because the tool only registers while depth < maxDepth, leaf children never receive a graph_sub_agent tool, so recursion can't run forever. Also a per-run maxSteps cap (default 20).
  • Wired in mcp/src/repo/tools.ts: added graph_sub_agent to ToolName, TOOL_NAMES, and DEFAULT_DESCRIPTIONS; the registerJarvisTools(...) call passes subAgent config gated on toolsConfig.graph_sub_agent (a string value overrides the description).

Config

{ "toolsConfig": { "graph_sub_agent": true } }
// or override the description:
{ "toolsConfig": { "graph_sub_agent": "Delegate a focused graph lookup..." } }

Note: like the other Jarvis tools, graph_sub_agent only registers when JARVIS_URL is set (the child needs the graph tools).

Testing

  • npx tsc --noEmit clean
  • npm run test:node (tools suite) — 21/21 pass

Spawns an in-process child agent with its own copy of the Jarvis graph
tools (get_ontology, graph_search, graph_get, graph_neighbors) so a parent
agent can locate key nodes then fan out focused sub-agents and collate their
findings. Opt-in via toolsConfig.graph_sub_agent; recursion is depth-capped
(maxDepth, default 2) so children can't spawn forever, plus a per-run step
cap (maxSteps, default 20).
@Evanfeenstra Evanfeenstra merged commit 13b241f 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