Overview of longctx retrieval and rescue modes
mainlongctx Overview
longctx is an open-source retrieval companion service designed for million-token inference. It is implemented as a single-purpose FastAPI service that provides two primary capabilities:
- Indexing: Chunks and embeds text spans into a FAISS index, which can be scoped per session or per repository.
- Retrieval: Returns top-K spans for a given query, with support for optional reranking.
Operating Modes
longctx can be used in two distinct architectural patterns:
- Standalone Retrieval (RAG Layer): Acts as a code-aware RAG layer wired in front of any OpenAI-compatible inference engine. It handles the indexing and retrieval of context spans independently of the model's KV cache.
- Rescue Layer (TriAttention V3 Integration): Acts as a safety net for engines using query-aware KV-cache eviction (specifically TriAttention V3). When the eviction policy removes necessary information from the KV cache,
longctxretrieves that information and serves it back to the next prefill to prevent recall failure.