# nvlabs/spatialclaw architecture

> Architecture diagram of the GitHub repository nvlabs/spatialclaw, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nvlabs/spatialclaw
- Repository: https://github.com/nvlabs/spatialclaw

## Overview

SpatialClaw is a training-free spatial-reasoning agent: it evaluates benchmark samples by repeatedly asking a VLM for executable Python, running each cell in a persistent Jupyter kernel, returning observations for further reasoning, and committing an answer. Its runtime also includes perception tools backed by a separate GPU service and a vLLM service; benchmark evaluation and service monitoring are supporting product branches. The workflow and loop are documented in the README and workflow excerpt; some service-to-service wiring and unsampled benchmark internals are not shown, so those links are omitted.

Main entry points: [`spatial_agent/workflow.py`](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/workflow.py) (Workflow graph), [`spatial_agent/gpu_rpc.py`](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/gpu_rpc.py) (GPU RPC), [`spatial_agent/entrypoints/run.py`](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/entrypoints/run.py) (Run entrypoint), [`spatial_agent/nodes/router.py`](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/router.py) (Loop routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent["Agent workflow"]
  node_entry["Run entrypoint<br/>[run.py]"]
  node_config["Agent config<br/>[config.py]"]
  node_workflow["Workflow graph<br/>[workflow.py]"]
  node_initialize["Initialize session<br/>[init_node.py]"]
  node_planner["Plan strategy<br/>[plan_node.py]"]
  node_llmstep["Generate code<br/>[llm_step_node.py]"]
  node_safety["Check and execute<br/>[execute_node.py]"]
  node_kernel["Persistent kernel<br/>[manager.py]"]
  node_feedback["Collect feedback<br/>[feedback_node.py]"]
  node_reflection["Reflect<br/>[reflection_node.py]"]
  node_router["Loop routing<br/>[router.py]"]
  node_answer["Final answer<br/>[return_answer.py]"]
end

subgraph group_perception["Perception tools"]
  node_tools["Tool facade<br/>[__init__.py]"]
  node_reconstruct["3D reconstruction"]
  node_sam3["SAM3 segmentation<br/>[sam3_tool.py]"]
end

subgraph group_evaluation["Benchmark evaluation"]
  node_benchmarks["Benchmark loaders"]
  node_scoring["Evaluation scoring<br/>[scoring.py]"]
end

subgraph group_services["Model services"]
  node_llm["VLM client<br/>[client.py]"]
  node_gpu_rpc["GPU RPC<br/>[gpu_rpc.py]"]
  node_gpu_models["GPU model runtime<br/>[sam3_model.py]"]
  node_vllm["vLLM service<br/>[server_chain.py]"]
  node_gpu_server["GPU tool service<br/>[server_chain.py]"]
end

subgraph group_operations["Monitoring"]
  node_gpu_dashboard["GPU dashboard<br/>[app.py]"]
  node_gpu_db[("GPU sample store<br/>[storage.py]")]
end

node_user(("Experiment runner"))

node_user -->|"starts run"| node_entry
node_entry -.->|"loads settings"| node_config
node_entry -.->|"runs agent"| node_workflow
node_workflow -->|"starts graph"| node_initialize
node_workflow -->|"routes to"| node_planner
node_workflow -->|"routes to"| node_llmstep
node_workflow -->|"routes to"| node_safety
node_workflow -->|"routes to"| node_feedback
node_workflow -->|"routes to"| node_reflection
node_workflow -.->|"checks loop"| node_router
node_initialize -->|"sets up"| node_tools
node_llmstep -->|"requests code"| node_llm
node_safety -.->|"executes cell"| node_kernel
node_kernel -.->|"returns output"| node_feedback
node_router -->|"repeats step"| node_llmstep
node_router -.->|"terminates"| node_answer
node_tools -->|"creates tool"| node_reconstruct
node_tools -->|"creates tool"| node_sam3
node_reconstruct -->|"calls remotely"| node_gpu_rpc
node_sam3 -->|"calls remotely"| node_gpu_rpc
node_gpu_rpc -.->|"dispatches model"| node_gpu_models
node_benchmarks -.->|"scores results"| node_scoring
node_gpu_dashboard -->|"reads and writes"| node_gpu_db
node_user -->|"selects dataset"| node_benchmarks
node_vllm -.->|"serves requests"| node_llm
node_gpu_server -.->|"hosts tools"| node_gpu_rpc

click node_entry "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/entrypoints/run.py"
click node_config "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/config.py"
click node_workflow "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/workflow.py"
click node_initialize "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/init_node.py"
click node_planner "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/plan_node.py"
click node_llmstep "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/llm_step_node.py"
click node_safety "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/execute_node.py"
click node_kernel "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/kernel/manager.py"
click node_feedback "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/feedback_node.py"
click node_reflection "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/reflection_node.py"
click node_router "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/router.py"
click node_answer "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/kernel_types/return_answer.py"
click node_llm "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/llm/client.py"
click node_tools "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/tools/__init__.py"
click node_reconstruct "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/tools/reconstruct_tool.py"
click node_sam3 "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/tools/sam3_tool.py"
click node_gpu_rpc "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/gpu_rpc.py"
click node_gpu_models "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/gpu_models/sam3_model.py"
click node_benchmarks "https://github.com/nvlabs/spatialclaw/tree/main/spatial_agent/evals"
click node_scoring "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/evals/scoring.py"
click node_gpu_dashboard "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/gpu_dashboard/app.py"
click node_gpu_db "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/gpu_dashboard/storage.py"
click node_vllm "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/launch_managers/vllm_manager/server_chain.py"
click node_gpu_server "https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/launch_managers/gpu_server_manager/server_chain.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_config,node_workflow,node_initialize,node_planner,node_llmstep,node_safety,node_kernel,node_feedback,node_reflection,node_router,node_answer toneBlue
class node_tools,node_reconstruct,node_sam3 toneAmber
class node_benchmarks,node_scoring toneMint
class node_llm,node_gpu_rpc,node_gpu_models,node_vllm,node_gpu_server toneRose
class node_gpu_dashboard,node_gpu_db,node_user toneIndigo
```

## Components

### Agent workflow

- [Run entrypoint](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/entrypoints/run.py): `spatial_agent/entrypoints/run.py`
- [Agent config](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/config.py): `spatial_agent/config.py`
- [Workflow graph](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/workflow.py): `spatial_agent/workflow.py`
- [Initialize session](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/init_node.py): `spatial_agent/nodes/init_node.py`
- [Plan strategy](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/plan_node.py): `spatial_agent/nodes/plan_node.py`
- [Generate code](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/llm_step_node.py): `spatial_agent/nodes/llm_step_node.py`
- [Check and execute](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/execute_node.py): `spatial_agent/nodes/execute_node.py`
- [Persistent kernel](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/kernel/manager.py): `spatial_agent/kernel/manager.py`
- [Collect feedback](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/feedback_node.py): `spatial_agent/nodes/feedback_node.py`
- [Reflect](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/reflection_node.py): `spatial_agent/nodes/reflection_node.py`
- [Loop routing](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/nodes/router.py): `spatial_agent/nodes/router.py`
- [Final answer](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/kernel_types/return_answer.py): `spatial_agent/kernel_types/return_answer.py`

### Perception tools

- [Tool facade](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/tools/__init__.py): `spatial_agent/tools/__init__.py`
- [3D reconstruction](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/tools/reconstruct_tool.py): `spatial_agent/tools/reconstruct_tool.py`
- [SAM3 segmentation](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/tools/sam3_tool.py): `spatial_agent/tools/sam3_tool.py`

### Benchmark evaluation

- [Benchmark loaders](https://github.com/nvlabs/spatialclaw/tree/main/spatial_agent/evals): `spatial_agent/evals`
- [Evaluation scoring](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/evals/scoring.py): `spatial_agent/evals/scoring.py`

### Model services

- [VLM client](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/llm/client.py): `spatial_agent/llm/client.py`
- [GPU RPC](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/gpu_rpc.py): `spatial_agent/gpu_rpc.py`
- [GPU model runtime](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/gpu_models/sam3_model.py): `spatial_agent/gpu_models/sam3_model.py`
- [vLLM service](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/launch_managers/vllm_manager/server_chain.py): `spatial_agent/launch_managers/vllm_manager/server_chain.py`
- [GPU tool service](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/launch_managers/gpu_server_manager/server_chain.py): `spatial_agent/launch_managers/gpu_server_manager/server_chain.py`

### Monitoring

- [GPU dashboard](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/gpu_dashboard/app.py): `spatial_agent/gpu_dashboard/app.py`
- [GPU sample store](https://github.com/nvlabs/spatialclaw/blob/main/spatial_agent/gpu_dashboard/storage.py): `spatial_agent/gpu_dashboard/storage.py`

### Other components

- **Experiment runner**

## Connections

- Experiment runner → Run entrypoint: starts run
- Run entrypoint → Agent config: loads settings
- Run entrypoint → Workflow graph: runs agent
- Workflow graph → Initialize session: starts graph (evidence: `spatial_agent/workflow.py`)
- Workflow graph → Plan strategy: routes to (evidence: `spatial_agent/workflow.py`)
- Workflow graph → Generate code: routes to (evidence: `spatial_agent/workflow.py`)
- Workflow graph → Check and execute: routes to (evidence: `spatial_agent/workflow.py`)
- Workflow graph → Collect feedback: routes to (evidence: `spatial_agent/workflow.py`)
- Workflow graph → Reflect: routes to (evidence: `spatial_agent/workflow.py`)
- Workflow graph → Loop routing: checks loop (evidence: `spatial_agent/workflow.py`)
- Initialize session → Tool facade: sets up (evidence: `spatial_agent/nodes/init_node.py`)
- Generate code → VLM client: requests code (evidence: `spatial_agent/nodes/llm_step_node.py`)
- Check and execute → Persistent kernel: executes cell
- Persistent kernel → Collect feedback: returns output
- Loop routing → Generate code: repeats step (evidence: `spatial_agent/nodes/router.py`)
- Loop routing → Final answer: terminates
- Tool facade → 3D reconstruction: creates tool (evidence: `spatial_agent/tools/__init__.py`)
- Tool facade → SAM3 segmentation: creates tool (evidence: `spatial_agent/tools/__init__.py`)
- 3D reconstruction → GPU RPC: calls remotely
- SAM3 segmentation → GPU RPC: calls remotely
- GPU RPC → GPU model runtime: dispatches model
- Benchmark loaders → Evaluation scoring: scores results (evidence: `spatial_agent/evals/erqa.py`)
- GPU dashboard → GPU sample store: reads and writes (evidence: `spatial_agent/gpu_dashboard/app.py`)
- Experiment runner → Benchmark loaders: selects dataset
- vLLM service → VLM client: serves requests
- GPU tool service → GPU RPC: hosts tools
