Your coding agent doesn’t need more tokens. It needs the right context.
AI coding agents start every task half-blind. They search the repository with text tools, read whole files to find one function and know nothing about why the code looks the way it does. SWEGO is a memory and retrieval layer that sits next to an existing agent: it indexes a repository’s code and history, then hands the agent a small, sourced bundle of the context relevant to its task.
Building repository memory
- GitHub metadata
- Git history & files
- Structural chunks
- Embeddings
- Retrieval
- Evidence Pack
SWEGO ingests a repository’s GitHub metadata and synchronises its Git history and files into PostgreSQL. TypeScript and JavaScript files are split at declarations, such as functions, classes, interfaces and types, and every chunk keeps its symbol, parent and line numbers. Files the parser cannot handle fall back to plain text chunks, so a parsing problem never blocks a rebuild.
Embeddings are generated locally with Ollama and stored in pgvector, so no API key is needed. Switching the embedding model is detected, and SWEGO refuses to mix vectors from different models.
Hybrid retrieval
A single search strategy misses things. Vector search understands meaning but struggles with exact names; keyword search is the opposite. SWEGO runs three branches in parallel, dense vectors, lexical search and a structural search over symbols and paths, and combines them with Reciprocal Rank Fusion and path diversification so one file cannot fill the whole result list.
- Time travel. Every search can be limited to what the repository looked like before a date, enforced in the database in all three branches. This matters for honest benchmarks and for questions about past behaviour.
- Query intent. A small deterministic analyser recognises whether a query is about tests, configuration or implementation and gently prefers matching files. It only adjusts ranking, never filters.
- Optional reranking. A local reranker can reorder the top 50 candidates.
Evidence Packs
Search results alone are not good agent context. An Evidence Pack takes the five strongest results, then adds the surrounding symbol, its parent, neighbours and directly imported modules, under a fixed budget of 30,000 characters. Every item carries its repository, revision, path, lines, symbol and the reason it was included, so the agent, and a human reviewing its work, can see where each piece came from.
Agents reach this through a local MCP server that is read-only by design. It can list repositories, inspect them and return context. It cannot ingest, change files or memory, run commands or read arbitrary paths.
Measuring it honestly
I built a separate evaluation package that scores every retrieval strategy against relevance judgments written by reading the source, using precision, recall, MRR and nDCG. It also explains each miss: whether the right file never entered the candidate pool, the wrong chunk of it did, or the reranker pushed it down. Held-out test sets were sealed with checksums before the features they test were built, and are run once.
The bigger question is whether any of this makes an agent better at real work. For that I designed and froze a paired benchmark: 12 realistic tasks on the open-source Formbricks codebase at a pinned commit, each run once by the same Codex agent without SWEGO and once with it. Success is decided by hidden, task-specific verifiers that are encrypted so the agent cannot see them, and each verifier was checked to reject the untouched code and accept a reference fix. The indexed repository has over 23,000 chunks and nearly 15,000 code relationships.
What I learned
- Retrieval quality comes from combining weak signals carefully, not from one clever model.
- Provenance turns context from a guess into evidence.
- Evaluation design is half the project. Without sealed test sets it is too easy to fool yourself.
- Tools given to agents should be as narrow as possible.