Skip to main content

Context-Engineer for local AI Agents. Zero-config RAG for Ollama with automatic chunking, token-budget awareness, and source citation.

Project description

ConText

Context-Engineer for local AI Agents. Zero-config RAG for Ollama with automatic chunking, token-budget awareness, and source citation.

pip install context-engineer
ollama pull nomic-embed-text
ollama pull llama3.2

context build ./docs
context query "What is the main topic?"

Why ConText?

Most RAG pipelines force you to choose between LangChain's complexity, ChromaDB's infrastructure, and naive vector search's poor results. ConText is the third option: opinionated, local-first, zero-config.

Feature ConText LangChain LlamaIndex Naive RAG
Setup time 30 seconds 30 minutes 20 minutes 5 minutes
Auto chunking ✅ 5 strategies ⚠️ DIY ❌ Fixed only
Token-budget aware ⚠️ DIY ⚠️ DIY
Source citation ✅ Built-in ⚠️ DIY ⚠️ DIY
Runs offline ✅ Ollama only
Dependencies 5 packages 30+ 20+ varies
Storage SQLite optional optional in-memory

Features

  • 🎯 5 Chunking Strategies — Auto-selected per file type (markdown, code, semantic, fixed, sliding)
  • 💰 Token-Budget Manager — Fits retrieved chunks to your model's context window
  • 📚 Source Citation — Every answer includes [1], [2], [3] references
  • 🚀 Zero Dependencies — Just pip install context-engineer + Ollama running locally
  • 💾 SQLite Storage — No external vector database needed
  • 🔌 HTTP API — MCP-compatible server for IDE integration
  • 📊 Built-in Benchmarks — Compare against naive RAG baseline

Quick Start

1. Install

pip install context-engineer

2. Install Ollama models

# Embedding model (required)
ollama pull nomic-embed-text

# LLM model (pick one)
ollama pull llama3.2          # 2GB, fast
ollama pull qwen2.5-coder    # 4GB, code-specialized
ollama pull mistral          # 4GB, general

3. Index your docs

Option A: Local files

context build ./docs

This recursively finds all .md, .txt, .py, .js, .ts, .go, .rs, .java, .c, .cpp, .h, .hpp, .json, .yaml, .yml files and indexes them with the right chunker.

Option B: Crawl a website

context crawl https://docs.example.com --max-pages 20

Respects robots.txt, BFS-crawls same-domain pages, removes script/style/nav/footer.

4. Ask questions

context query "What guarantees memory safety in Rust?"

Output:

╭─ Answer (27295ms, 714+97 tokens) ─────────────────╮
│ Rust's ownership system guarantees memory safety   │
│ at compile time. Every value has an owner, and     │
│ there can only be one owner at a time. When the    │
│ owner goes out of scope, the value is dropped [1]. │
╰────────────────────────────────────────────────────╯
Sources
┏━━━┳━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┓
┃ # ┃ Source               ┃ Strategy ┃ Score ┃
┡━━━╇━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━┩
│ 1 │ rust-intro.md        │ markdown │ 0.855 │
│ 2 │ rust-intro.md        │ markdown │ 0.765 │
└───┴──────────────────────┴──────────┴───────┘

Python API

from context_engineer import ConText

# Initialize
ctx = ConText(
    db_path=".context/store.db",
    llm_model="llama3.2",
    embed_model="nomic-embed-text",
    context_window=8192,
)

# Index files
ctx.build("./docs")

# Add raw text
ctx.add_text("Some important info", source="notes.md")

# Query
answer = ctx.query("What is X?")
print(answer.text)        # "X is ... [1]"
print(answer.sources)     # [Source(...), ...]
print(answer.latency_ms)  # 1234

# Stats
ctx.stats()
# {'documents': 5, 'chunks': 27, 'embeddings': 27, ...}

HTTP API

context serve --port 8765
# Query
curl -X POST http://localhost:8765/query \
  -H "Content-Type: application/json" \
  -d '{"question": "What is X?"}'

# Build
curl -X POST http://localhost:8765/build \
  -H "Content-Type: application/json" \
  -d '{"path": "./docs"}'

# Stats
curl http://localhost:8765/stats

Architecture

ConText Pipeline
    │
    ├─ Document Loader (.md, .py, .js, ...)
    │       │
    │       ▼
    ├─ Auto-Selected Chunker
    │       │
    │       ├─ Markdown   (headers, code blocks)
    │       ├─ Code       (functions, classes)
    │       ├─ Semantic   (sentence boundaries)
    │       ├─ Fixed      (N chars, M overlap)
    │       └─ Sliding    (larger overlap)
    │       │
    │       ▼
    ├─ Embedder (Ollama nomic-embed-text + LRU cache)
    │       │
    │       ▼
    ├─ SQLite Store (chunks + vectors as BLOB)
    │
    └─ Query
        │
        ├─ Cosine-Similarity (top-20)
        │
        ├─ Token-Budget Greedy-Fit
        │
        └─ LLM Generation (Ollama llama3.2)
            │
            └─ Cited Response [1][2][3]

CLI Reference

context build <path>          Index documents
context query "question"      Ask a question (with sources)
context stats                  Show database stats
context list                   List indexed documents
context remove <source>        Remove a document
context serve                  Start HTTP API server

Global options:

  • --db PATH — SQLite database location (default: .context/store.db)
  • --llm MODEL — Ollama LLM model (default: llama3.2)
  • --embed MODEL — Ollama embed model (default: nomic-embed-text)
  • --ollama-url URL — Ollama API (default: http://localhost:11434)
  • --context-window N — LLM context window (default: 8192)

Roadmap

  • v0.1.0 — Core RAG + 5 chunkers + CLI + HTTP API
  • v0.2.0 — Hybrid search (BM25 + vector)
  • v0.3.0 — Cross-encoder reranking
  • v0.4.0 — Multi-modal (image + text)
  • v0.5.0 — Cloud sync + team features (Pro)
  • v1.0.0 — Stable API

License

MIT © 2026 Torben

See Also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

context_engineer_tabtii-0.1.0.tar.gz (32.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

context_engineer_tabtii-0.1.0-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

File details

Details for the file context_engineer_tabtii-0.1.0.tar.gz.

File metadata

  • Download URL: context_engineer_tabtii-0.1.0.tar.gz
  • Upload date:
  • Size: 32.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for context_engineer_tabtii-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6dbf5509566c4d44e2ea04922b4d9939e62102d0b31cbe27643e790ac9f7dc18
MD5 5efbe4b211cc0c06f64fc6e2028e3079
BLAKE2b-256 55961da24f0564819fe8992b9b3f66ba727bde5f92d79b6e2ab5435a150bdecc

See more details on using hashes here.

Provenance

The following attestation bundles were made for context_engineer_tabtii-0.1.0.tar.gz:

Publisher: publish.yml on Tabtii/context-engineer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file context_engineer_tabtii-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for context_engineer_tabtii-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a0916dc58ecff129715581e4c2361ee8bdad02aa9aec8323e442f626df3b525
MD5 a6b71a0ac76b54c8295922eb56b4eab0
BLAKE2b-256 55eb1a1cb1073dc3e768deba81bf3b7c367d3c710b73f1a5509f3d34bcb62476

See more details on using hashes here.

Provenance

The following attestation bundles were made for context_engineer_tabtii-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Tabtii/context-engineer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page