ContextOS

ContextOS Documentation

Context orchestration for LLM applications. Retrieve candidates, rank them, and build a context payload within a strict token budget.

Overview

What is ContextOS?

ContextOS is an open-source context orchestration layer for LLM applications. It is designed for systems that need to combine dense retrieval, lexical retrieval, reranking, and hard token budget constraints into a single, predictable context payload.

What problem does it solve?

In a typical RAG system, retrieval is treated as identical to context selection. An application queries a vector database, gets the top-K documents, and shoves them into a prompt.

ContextOS solves the problem that retrieval ≠ context selection.

Retrieval's job is simply to find candidates. But the LLM context window is a constrained resource. You need a way to deduplicate, re-score, and strategically select from those candidates to fit inside your token budget while preserving critical system instructions and recent conversation turns.

What ContextOS does

retrieve → fuse (RRF) → rerank → plan → build context

What ContextOS does NOT do

  • It is not an LLM wrapper. You bring your own LLM client (OpenAI, Anthropic, vLLM, etc.).
  • It is not responsible for generation. It only prepares the context.
  • It is not a vector database. It uses PostgreSQL and pgvector under the hood, but acts as a higher-level orchestrator.
  • It is not a chatbot framework like LangChain or LlamaIndex.
  • It is not a hosted SaaS. It is an open-source Python library you deploy in your own stack.