
The FirstPR backend is a high-performance, asynchronous orchestration layer built on FastAPI that manages a complex multi-agent RAG (Retrieval-Augmented Generation) pipeline. It handles repository ingestion by cloning and processing source code into a persistent ChromaDB vector store, while simultaneously constructing a BM25Okapi index for high-precision keyword recall. This hybrid search strategy ensures that the system can capture both semantic intent and exact code symbol matches. The core technical differentiator is the issue-aware reranking engine, which performs a multi-signal analysis to localize code fixes. It evaluates candidate files through five weighted heuristics: Symbol Matching (comparing extracted issue entities against class/function definitions), Filepath Domain Analysis, Dependency Proximity (calculating hop distances in the import graph), Retrieval Agreement (cross-validating semantic and keyword hits), and Infrastructure Penalties to filter out low-signal files like logs or configs. For the reasoning phase, the backend implements a Grounding Contract that dynamically constrains the Large Language Model—whether running via local Ollama instances or remote vLLM servers—to the retrieved source context. It utilizes importance-decay context assembly, where "anchor" files receive high-density token allocation while supporting files are included as lightweight breadcrumbs. The system also features a specialized Architecture Query Mode that utilizes custom keyword-scoring to identify ML inference pipelines and weight initialization logic. All progress is communicated to the frontend via an NDJSON streaming protocol, providing real-time transparency into the agentic workflow.
10 May 2026