2026-11-26 15:48 UTC

OntoPrune claims large local-coding gains from code-contract context pruning; results remain unverified

state: seedheat: lowuncertainty: mediumrelevance: lowcontext-pruning local-inference agent-harnesses inference-economicsvigmarcarlo

What is this?

OntoPrune is a maintainer-described, MIT-licensed tool that parses source code into an RDF/SPARQL representation and produces compact contract stubs for coding models. It is offered as a Python library, CLI and MCP server, with a checker for generated code. Its Reddit post and GitHub README report a benchmark on one 300+ line sample, using Qwen 2.5 Coder 3B on a 12-core CPU: 2,390 input tokens fell to 406, TTFT from 22.4 to 3.3 seconds, and one invalid API call in the full-context run versus none with pruning. These are maintainer-reported results, not independent validation; the evidence does not establish general accuracy, performance across projects or models, or adoption.

Why it matters

OntoPrune is a potentially useful, open-source approach to reducing code context for local coding models: it extracts typed interface stubs instead of sending a whole file. The maintainer reports substantial token and latency savings, but those results come from one self-benchmark on one sample and model, with no independent replication shown. It is worth watching as an experiment in lightweight context preparation, not yet treating as a proven performance layer or choosing it on the strength of the headline numbers.

Current assessment

OntoPrune’s maintainer describes an MIT-licensed Python tool that parses code into an RDF/SPARQL graph, extracts dependencies for a target function, renders contract stubs, and checks generated code against them; it also offers a CLI and MCP server. The Reddit post and GitHub README report a test on a 300+ line sample using Qwen 2.5 Coder 3B on a 12-core CPU: input fell from 2,390 to 406 tokens, TTFT from 22.4 to 3.3 seconds, and the full-context output had one invalid API call versus none with pruning. The README repeats the maintainer’s figures, so these are not independent corroboration. A claimed cloud-model token reduction is also reported, but no comparable performance or quality evaluation is supplied. Evidence does not establish generalization across repositories, languages, models, or tasks; nor does it show adoption. The key follow-up is reproducible testing on varied codebases and models, measuring output correctness as well as latency and token savings.

Measured heat

now 0 pts/hpeak 0 pts/hcomments 0/hpeers p10momentum: steady3 platformsage 1251h
points/hour across evidence · reading as of 2026-11-27 02:23:58.509736+11:00 · deterministic, not a model opinion

How the heat travelled

10-05 12:26 (minted)⭐ origin echo-reconstructedRepo README: 'Neuro-Symbolic Context Pruning Middleware for Local SLMs' translating source into RDF/SPARQL contract stubs; self-benchmark on
vigmarcarlo on github (echo) · attributed from reddit.post.1wy6qvf, hn.story.49963837 · published time unknown
—
10-05 12:02first on r/LocalLLaMA · published · lag ?[Project] OntoPrune: 6.7x faster TTFT on local CPU with Ollama by neuro-symbolic context pruning (83-86% token savings + 0% hallucinations)
vigmarcarlo
—
10-05 12:15first on hacker news · published · lag ?OntoPrune – Pruning 85% LLM context tokens and 6.7x TTFT on CPU
vigmarcarlo
—
10-05 12:02amplified on r/LocalLLaMA 👑reddit.post.1wy6qvf
vigmarcarlo
peak 1 · 5 comments · 77% of case engagement
10-05 12:15amplified on hacker newshn.story.49963837
vigmarcarlo
peak 1 · 0 comments · 23% of case engagement
10-05 12:20our radar first saw it · lag ?discovery anchor: reddit.post.1wy6qvf—

Evidence (3) — ⭐ canonical anchor

sourceobjectauthorscorecomments
🟠 reddit[Project] OntoPrune: 6.7x faster TTFT on local CPU with Ollama by neuro-symbolic context pruning (83-86% token savings + 0% hallucinations)
LocalLLaMA
vigmarcarlo05
🟧 hnOntoPrune – Pruning 85% LLM context tokens and 6.7x TTFT on CPU
Retrieved article excerpt

Open article · Retrieved 2026-10-05T12:24:49.807649+00:00

# OntoPrune

*Neuro-Symbolic Context Pruning Middleware for Local SLMs*

OntoPrune es un middleware traductor ligero que transforma código fuente en contratos de contexto mínimos utilizando representación ontológica (RDF/SPARQL), reduciendo drásticamente los tokens de entrada y la latencia TTFT (Time to First Token) para modelos de lenguaje pequeños (SLMs) y evitando alucinaciones de API.

---

## Resultados Empíricos (Benchmark en CPU)

Evaluación real con streaming sobre [sample\_service.py](https://github.com/vigmarcarlo/OntoPrune/blob/main/fixtures/sample_service.py) (300+ LOC) en CPU local (12 cores):

| Métrica | Naive (Archivo Completo) | OntoPrune (`stubs`) | Ganancia Real |
| --- | --- | --- | --- |
| **Sobrecarga CPU** | 0.02 ms | **9.9 ms** | $\le 10\text{ ms}$ (Meta: $\le 15\text{ ms}$) |
| **Tokens Entrada** | 2,390 tokens | **406 tokens** | **-83.0%** ($\approx 6\text{x}$ menos) |
| **TTFT (`qwen2.5-coder:3b`)** | 22.4 s | **3.3 s** | **6.7x más rápido** (ahorra 19.1 s) |
| **Tiempo Total (3B)** | 59.9 s | **16.5 s** | **-72.5%** ($3.6\text{x}$ más rápido) |
| **Alucinaciones API** | 1 método inválido | **0 métodos inválidos** | **100% Precisión Contractual** |



---

## Instalación

```
pip install -e .

# Con dependencias para benchmarking:
pip install -e ".[dev,benchmark]"
```

---

## Modos de Uso

### 1. Como Servidor MCP (Model Context Protocol)

OntoPrune incluye un servidor MCP nativo (`ontoprune-mcp`) para integrarse con Cursor, Claude Desktop, Gemini CLI o cualquier agente:

```
# Ejecutar servidor MCP en transporte stdio:
ontoprune-mcp
```

**Configuración en `claude_desktop_config.json` o similar:**

```
{
  "mcpServers": {
    "ontoprune": {
      "command": "ontoprune-mcp"
    }
  }
}
```

**Herramientas MCP expuestas:**

- `prune_context(file_path, target_symbol, format='stubs', include_body=False, project_root=None)`: Extrae el contrato podado mínimo (< 400 tokens) resolviendo dependencias entre múltiples archivos del proyecto.
- `verify_response(response_code, contract_or_file, target_symbol)`: Detecta alucinaciones en código generado comparando contra el contrato o archivo.

---

### 2. Como Librería Python

```
import ontoprune

# 1. Traducir un archivo a contexto compacto podado (formato stubs)
# Resuelve automáticamente imports relativos y absolutos entre módulos del proyecto
context = ontoprune.translate(
    "services/order_service.py",
    target="procesar_orden",
    fmt="stubs",
    multi_module=True,
)
print(context)

# 2. Verificar respuestas del modelo frente al contrato
violations = ontoprune.check(llm_code_response, against=context)
if not violations:
    print("Código 100% válido")
```

---

### 3. Desde la Línea de Comandos (CLI & Pipes)

```
# Traducir función en proyectos multi-módulo:
ontoprune translate services/order_service.py procesar_orden --format stubs

# Pipeline directo con Ollama en proyectos modulares:
ontoprune translate services/order_service.py procesar_orden | ollama run qwen2.5-coder:3b
```

---

### 4. Ejecución del Benchmark Empírico

```
# Correr benchmark comparativo (Naive vs OntoPrune con ablación de formatos):
python -m ontoprune.benchmark --file fixtures/sample_service.py --func procesar_orden --backend ollama --model qwen2.5-coder:3b --compare-formats
```

---

## Modelos de Monetización y Aplicación Comercial

OntoPrune resuelve dos problemas críticos de costo y confiabilidad en ingeniería de IA:

### 1. Token Cost Optimization Gateway (B2B SaaS / Middleware de Ahorro)

- **Problema:** Equipos que operan agentes de código autónomos (Devin, Cursor, Copilot Workspace) gastan miles de dólares mensuales en tokens de entrada donde más del 80% es código irrelevante.
- **Solución:** OntoPrune como proxy o sidecar que poda el contexto antes de enviarlo a APIs comerciales (Gemini, Claude, OpenAI), reduciendo la factura de tokens en un **85%**.
- **Monetización:** Cobro basado en porcentaje de ahorro (*gain-share*: ej. 10% del ahorro mensual generado).

### 2. Local-First Developer Tooling (Edición Profesional / Equipos)

- **Problema:** Desarrolladores y empresas que requieren privacidad estricta ejecutan SLMs en laptops o servidores locales (Ollama/vLLM), sufriendo latencias inaceptables en CPU.
- **Solución:** OntoPrune reduce el TTFT de 22s a 3.3s (6.7x más rápido).
- **Monetización:** Versión open-source para desarrolladores individuales + licencia empresarial para equipos (soporte multi-repositorio, telemetría y reglas de cumplimiento de arquitectura).

### 3. Agent Compliance & CI/CD Security Gate

- **Problema:** Los agentes de código alucinan APIs y rompen contratos de software en producción.
- **Solución:** `ontoprune check` como paso automatizado en GitHub Actions / GitLab CI que bloquea pull requests con llamadas no autorizadas al grafo del sistema.
- **Monetización:** Modelo SaaS de auditoría y seguridad para código generado por agentes.
vigmarcarlo10
🟧 echo.github ⭐Repo README: 'Neuro-Symbolic Context Pruning Middleware for Local SLMs' translating source into RDF/SPARQL contract stubs; self-benchmark onvigmarcarlo——

Interpretation history

Decision trace