Walkthrough: Crawling PDFs & Querying Knowledge Graphs (Local & Remote)
This walkthrough shows how a developer actually goes from a folder of PDFs (text-native, scanned, or mixed) to a searchable, verifiable Knowledge Graph (.kgraph) using the Kompile harness — without hand-writing JSON payloads or REST requests.
You talk to the harness in plain English (or run a couple of short CLI commands), and the agent handles capability discovery, dry-run previews, PDF OCR routing, asynchronous job tracking, and graph queries behind the scenes — in both modes:
- Local Mode (Offline, Zero Server) — runs directly inside your repository using the
local-runtimeoverlay (<project>/data/crawls/+<project>/.kompile/graph.kgraph). - Remote Runtime Mode (
kompile-app) — connects your harness (--url) to a remotekompile-appserver for shared team indices, Neo4j/pgvector persistence, scheduled crawls, or remote GPU OCR/embeddings.
flowchart LR
PDF["Your PDFs\n(Text, Scanned, Mixed)"] --> CHAT["You Ask in Kompile Chat\n(Terminal or Web Harness)"]
CHAT --> ROUTE{"Where It Runs"}
ROUTE -->|"Local Mode\n(cli-harness + local-runtime)"| LOC["Project-Local Pipeline\nPDFBox+Tabula / VLM OCR\n<project>/data/crawls/\n<project>/.kompile/graph.kgraph"]
ROUTE -->|"Remote Runtime\n(--url http://host:8080)"| REM["kompile-app Stack\nCrawl Manager (:8082)\nGraph Engine (:8094) / Staging (:8090)"]
LOC --> ASK["Ask & Verify in Plain English\n• Hybrid passage + graph search\n• Claim verification & evidence\n• Multi-hop paths & portable .kgraph"]
REM --> ASKStep 0: Check your tier & how PDF routing works
Kompile keeps the default cli-harness lightweight (zero ND4J, DL4J, PDF/Office loaders, or Spring dependencies):
| Installed Tier | Local Offline PDF Crawling & .kgraph | Remote Server (kompile chat --url / kompile crawl --url) | Remote MCP Stdio (kompile mcp-stdio --url) |
|---|---|---|---|
Slim cli-harness only (default install.sh) | Install local-runtime first (kompile install local-runtime) | Works out of the box over pure-JDK HTTP & MCP SSE | Works out of the box (30 remote crawl, RAG & graph tools; local-only graph_psl, graph_reasoning_query, model_runtime, pipeline need local-runtime) |
cli-harness + local-runtime | All 33 crawl, RAG, pipeline & graph tools active out of the box | Works out of the box | Works out of the box |
Full platform (full / GPU variants) | All 33 crawl, RAG, pipeline & graph tools active out of the box | Works out of the box | Works out of the box |
If you want to crawl PDFs and query .kgraph files locally with no server, overlay local-runtime once:
kompile install local-runtime # Auto-detects CPU/GPU backend and installs ~/.kompile/lib/kompile-local-runtime.jar
kompile doctor # Verify installationWhat the harness handles automatically
- Progressive tool loading: Crawl and graph tools live in deferred groups (
crawl,graph_query,graph_analysis,graph_write) so they don't bloat normal coding turns. As soon as you ask to crawl a PDF or inspect a graph, the agent activates the right group on its own. - Automatic PDF classification (
AUTOrouting): Both local and remote runtimes inspect each PDF page before extraction (using a 50 chars/page scanned-page threshold):
| PDF Type | Detected As | Pipeline Selected | How Text & Tables Are Extracted |
|---|---|---|---|
| Text-native PDF | Extractable text, no full-page scan images | standard-text | PDFBox + Tabula (text + structured tables) |
| Scanned / image PDF | Raster page images with <50 chars/page | vlm-ocr-pdf (or multimodal chat model) | Local VLM (smoldocling-256m) or your configured multimodal chat model |
| Mixed PDF | Some text pages, some scanned pages | vlm-ocr-pdf (AUTO) | Per-page split: VLM OCR on scanned pages, PDFBox+Tabula on text pages |
Part 1: Project-Local PDF Crawl & Knowledge Graph (No Server)
Use this when working inside a local repository or private document folder with local-runtime installed.
1. Put your PDFs in the project & open Kompile
mkdir -p ./papers
cp ~/Downloads/architecture-spec.pdf ~/Downloads/scanned-appendix.pdf ./papers/
# Optional: generate kompile.project.json + AUTO PDF/VLM routing config in one command
kompile project init --pdf-routing AUTO
# Launch the harness (terminal or browser)
kompile chat
# or
kompile chat --web2. Preview the crawl in plain English (dry run first)
Before writing anything to disk, ask the agent to inspect your local crawl capabilities and preview how each PDF will be routed:
"Check what crawl pipelines are available here and run a dry-run preview on the PDFs in
./papersso I can see which files will use text extraction vs. VLM OCR before indexing anything."
What you see:
- The agent activates the
crawltool group, inspects local loaders/pipelines (crawl_discover), and runs a zero-persistence preview (dryRun). - It reports back each discovered PDF, whether it is text-native, scanned, or mixed, and which pipeline (
standard-textvs.vlm-ocr-pdf/ multimodal chat) will process it.
3. Run the crawl & watch live progress
Once the preview looks right, tell the agent to run the real crawl:
"Crawl
./papersinto this project's local knowledge base with full graph extraction and learning. If no local extraction LLM is staged, use my active chat provider for entity extraction."
What happens behind the scenes:
- The harness submits an asynchronous crawl job (
crawl_documentsfor a folder, orcrawl_sourcefor one file) covering loading, markdown/table extraction, chunking, lexical + vector indexing, entity/relation extraction, entity resolution, enrichment, and graph learning. - You don't need to wait passively: the job runs asynchronously while you can keep chatting, inspect progress in the Activity Pane (
↓in terminal) or Web/processestab, or run/dashboard-crawlto see live throughput and stage status. - When the job finishes, the agent pulls the structured result handle (
crawl_result) and gives you a concise summary of indexed documents, chunks, entities, and relationships.
(Prefer a non-interactive shell run without opening chat? Run kompile crawl --offline --local-agent crawl-worker.)
Where your local artifacts live
<project>/data/crawls/— extracted markdown, chunks, lexical/dense search index, and job history.<project>/.kompile/graph.kgraph— self-contained project knowledge graph (COMPACT_V3) holding entities, relationships, source provenance, subjective-logic opinions, and learned weights.
Part 2: Remote Runtime PDF Crawl (kompile-app)
Use remote runtime mode when you want a shared team knowledge base, Neo4j/pgvector storage, scheduled crawls, or a dedicated GPU box running VLM OCR and embeddings.
1. Connect the harness to your remote server
Even a bare slim cli-harness (without local-runtime) connects directly over pure-JDK HTTP:
# Option A — Interactive terminal chat against the remote runtime
kompile chat --url http://<server-host>:8080
# Option B — Dedicated crawl-and-reason REPL
kompile crawl --url http://<server-host>:8080 --mode supervised
# Option C — MCP stdio bridge for external agents (Claude Code, Codex, Antigravity)
kompile mcp-stdio --url http://<server-host>:8080(By default --url auto-discovers the three server personas: admin :8080, crawl manager :8082, and graph engine :8094. You can override them explicitly with --crawl-url and --graph-url. Quick readiness check from any shell: curl -sf http://<server-host>:8082/api/setup/status.)
2. Preflight & launch the remote crawl in plain English
Inside chat, ask the agent using the exact same workflow as local mode:
"Preflight the remote crawl server, show me the existing fact sheets and registered OCR pipelines, then crawl
/data/input_documents/pdfsinto thearchitecturefact sheet with lenient graph extraction."
What you see:
- The harness runs a preflight check against
kompile-app-crawl-manager(:8082), discovers remote source types and fact sheets, and submits the remote crawl job. - Track progress live with
/dashboard-crawland/dashboard-graphin chat (or open the Project, Fact Sheets, and Graph tabs inkompile chat --web). - If your remote server sits behind a reverse proxy with a strict read timeout, the harness's default asynchronous job mode avoids long blocking HTTP connections automatically.
Part 3: Query, Verify & Reason Over Your Graph (Both Modes)
Once the crawl finishes, the workflow is identical whether your graph lives in local <project>/.kompile/graph.kgraph or on a remote kompile-app server. Just ask in plain English:
1. Inspect what was extracted before querying
"Show me the entity types, node/edge counts, and predicate names extracted from these PDFs."
The harness inspects the live graph schema (knowledge_graph, graph_reasoning_query) so neither you nor the agent ever guesses predicate names.
2. Hybrid document + graph search
"What do these specs say about failover timeout budgets, and which services are linked to them?"
The agent runs hybrid passage retrieval (rag_search) alongside graph-neighborhood lookup (graph_search), returning grounded answers with exact source-document attribution.
3. Verify claims & inspect evidence
"Verify whether
ServiceAdepends onQueueBbased on the crawled PDFs, and show me the supporting evidence, any counter-evidence, and the reasoning trace."
The harness checks the claim (ask_graph_verify, graph_reason, ask_graph_explain) and reports a plain-English verdict — SUPPORTED, REFUTED, or UNKNOWN — along with confidence, uncertainty, evidence bullets, and the rule-derivation chain.
4. Multi-hop paths, pattern queries & structural analysis
"List every service that depends on
QueueB, trace the shortest dependency path fromServiceAtoDatabaseC, and highlight the highest-centrality components in the graph."
Under the hood, the agent translates your question into pattern queries (ask_graph_query), shortest-path / WHY / WHY_NOT reasoning (graph_reasoning_query), and structural or probabilistic analysis (graph_centrality, graph_bayes, graph_embeddings, graph_psl, ask_graph_mebn).
5. Move a graph between machines (.kgraph portability)
Crawl heavy PDFs once on a GPU workstation or remote server, then bring the graph to your laptop for offline work:
- On the GPU host / remote session:
"Export this knowledge graph as a portable
.kgraphto./exports/architecture-pdfs.kgraph." - On your laptop (with
local-runtime):"Import
./exports/architecture-pdfs.kgraphinto my local graph so I can query and verify claims offline."
Troubleshooting
| Symptom | Likely Cause | What to Do |
|---|---|---|
| "Tool requires the local embeddings/graph/crawl runtime" | Running bare cli-harness with no --url and no local-runtime | Run kompile install local-runtime for offline local crawling, or connect to a server with kompile chat --url http://<host>:8080 |
| Scanned PDF yields little or no text | Pages are raster images and text-only extraction ran | Run kompile project init --pdf-routing AUTO or ask the agent to re-crawl that file using the vlm-ocr-pdf (or multimodal chat) pipeline |
| Crawl job appears to run twice | Starting a second crawl while the first job is still in progress | Check /dashboard-crawl or ask "What is the status of the active crawl job?" instead of re-submitting |
| Graph query returns empty results | Predicate or entity name didn't match extracted vocabulary | Ask "List the predicates and top entities in this graph" first, then re-query using the discovered names |
Remote crawl endpoints return 404 on :8080 | Crawl APIs live on kompile-app-crawl-manager (:8082) | Pass --url http://<host>:8080 (auto-routes crawl calls) or explicitly pass --crawl-url http://<host>:8082 |
Related guides
- How a Kompile Session Works — How a standard agent turn uses memories, reminders, exploration, edits, and cost tracking
- Knowledge Graphs & Grounded Reasoning — Deep dive into OWL-RL, Datalog, PSL, MEBN, KGE, Subjective Logic, and
.kgraphlayout - Crawl Jobs — All 25+ source types, loaders, and distributed crawl architecture
- Local Models &
local-runtime— Installinglocal-runtimeand selecting CPU/GPU backends - Graph CLI Commands — Direct
kompile graph ...terminal commands - Projects — Per-project
.kompile/anddata/layout