Skip to content
Back to work
04/ 2026/ Architect + sole engineer

Deep Research Engine

A six-node research graph — typed critic gate, self-describing knowledge graph, nine artifact schemas.

PythonLangGraphdeepagentsNeo4jpgvectorLangfuse

A context engine for autonomous research — its own pyproject describes it as "minimal context building with deepagents + LangGraph Store." Six LangGraph nodes turn raw material — documents, Telegram exports, audio and video — into drafts that pass a typed quality gate, a queryable knowledge graph, and finished artifacts in nine schema-defined formats. Runs checkpoint to Postgres when the checkpointer is configured — without it, the graph runs stateless.

Six nodes, wired as a graph

   ┌────────────┐
   │ Ingestion  │  Kreuzberg documents, Telegram exports;
   └─────┬──────┘  audio/video/photos route to a multimodal pipeline
         │
   ┌─────▼──────┐   revise (retry cap: 3)
   │   King     │ ◄─────────────────────┐
   │  Drafter   │                       │
   └─────┬──────┘                       │
         │ draft                        │
   ┌─────▼──────┐   score ≥ 0.7         │
   │   Critic   │ ──────────────────────┘
   └─────┬──────┘
         │
   ┌─────▼──────┐
   │  Content   │  thematic clustering into Topic nodes
   │ Clusterer  │
   └─────┬──────┘
         │
   ┌─────▼──────┐
   │   Neo4j    │ (optional) MERGE upserts into a
   │  Builder   │ long-lived knowledge graph
   └─────┬──────┘
         │
   ┌─────▼────────┐
   │  Artifact    │  research reports, Twitter threads,
   │    Maker     │  podcast scripts, llms.txt, code, skills
   └──────────────┘

Every node carries an enabled flag; only the Neo4j builder defaults off. A research workflow is a YAML config, not a code change.

The critic is a type, not a vibe

The gate is a Pydantic CriticEvaluation: a 0–1 score, weighted sub-scores (completeness and accuracy carry 0.4 each, thresholds per-criterion in rag.yaml), citation quality, coherence, structured issues and suggestions, and an explicit recommendation — pass, revise, or terminate. A LangGraph conditional edge compares the score against the 0.7 bar and loops back to the drafter, capped at three retries.

One seam is deliberately visible: the critic writes critique_history into state and the loop-back edge exists, but piping that critique back into the drafter's prompt is still open plumbing. It's recorded, not hidden.

King Drafter knows its VRAM budget

The drafter is a deepagents agent — create_deep_agent with seven registered worker types behind it: web researcher, scraper, multimodal, content classifier, social archive, vibevoice ASR, artifact maker. Its tools are vector_search_datastore and graph_query, so every claim it drafts can be grounded in the store or the graph rather than in the model's mood.

It runs on local llama.cpp through an InfraClient that keeps a per-model VRAM ledger — gemma4 at 6,000MB, qwen3.5 at 14,000MB, vibevoice-asr at 18,500MB — with unload-all-to-fit when a load doesn't clear. The subtle bit: ingestion workflows deliberately route to the cloud model, so a long document batch never evicts the vision model mid-conversation.

A graph that describes itself

The Neo4j builder writes structured data — speakers, entities, media — with no LLM in the loop, clusters as Topic nodes, and only then asks the model for triplets. Before writing any label it calls get_existing_labels() and reuses what's there: no hardcoded ontology, and the graph converges on its own vocabulary across runs. Every write is a Cypher MERGE upsert keyed on name or path — re-running a research pass merges into existing nodes instead of duplicating them.

Resumable by default

Every step checkpoints through LangGraph's AsyncPostgresSaver, so a failed long run doesn't die with its context: deep-research resume <thread_id> picks up where the graph stopped. Storage sits behind one StorageBackend ABC with five backends selected by YAML flags — memory, Postgres (asyncpg + pgvector with a registered vector type and an ANN index), MongoDB, Neo4j, MinIO. Swapping persistence is config, not code.

Out of the box, nine ways

The final node isn't a synthesizer — it's an artifact maker with nine formats: research_report, twitter_thread, substack_article, podcast_script, markdown, llms_txt, structured_json, code, and skill. The same grounded draft can ship as a thread, a newsletter, or an agent skill.

Ops discipline

Langfuse is the prompt source of truth when configured; without keys the engine falls back to built-in templates — and every call carries session, user, and tag metadata either way. The test suite is 19 files of unit, integration, and e2e coverage with hand-rolled fakes; ruff, mypy, and pre-commit gate every change. And docs/known-issues/asr-failures.md pins a llama.cpp crash to a specific build with a confirmed root cause — documented, not hidden.

Quick start

# Research from the live config
deep-research research "your question" --config rag.yaml

# Ingest a single PDF
deep-research pdf ./paper.pdf

# Resume a failed run from its checkpoint
deep-research resume <thread_id>