Agentic RAG context layer
Custom MCP servers and a context layer that halved token use and kept hallucinations below 2%.
- Xylont
- Technical Manager — design and architecture
- 2026
- In production
- Query
- Semantic cache
- Agentic retrieval
- PostgreSQL + pgvector
- LLM
- Grounded response
In brief
Every AI answer costs money, takes time and can be wrong. I designed the layer that decides what context a model sees for clinical and financial questions — and recognises questions it has already answered. Token use halved, slow answers take 42% less time, and hallucination rates stay below 2%.
For engineers
Custom MCP servers and an agentic RAG context-management layer over PostgreSQL with pgvector, fronted by a semantic cache. Token consumption −50%, P95 query latency −42%, hallucination rate under 2% across clinical and financial queries.
Context
Xylont’s AI products answer clinical and financial questions — domains where an answer has to be right, fast and affordable at the same time.
Problem
Without careful context management, every query sends a model more than it needs. Token costs rise, latency grows, and irrelevant or missing context invites hallucination.
Approach
Custom MCP servers expose tools and data to agents through a single protocol.
An agentic retrieval layer decides, per query, what context to assemble from PostgreSQL with pgvector.
A semantic cache sits in front, returning cached responses to questions close to ones already answered.
Architecture
The components in Fig. 03, in the order a request moves through them:
- Query
- Input
- Semantic cache
- Data · Hit → cached response
- Agentic retrieval
- Agents · Custom MCP servers
- PostgreSQL + pgvector
- Data
- LLM
- Model
- Grounded response
- Output
Key decisions
MCP as the integration layer
One protocol between agents and every tool or data source, instead of bespoke glue for each.
Retrieval inside PostgreSQL
pgvector keeps embeddings alongside the rest of the data in PostgreSQL.
Cache by meaning
Semantic caching matches questions by meaning rather than exact wording, so repeat questions skip the expensive path.
Outcome
50%
lower LLM token consumption
42%
lower P95 query latency
<2%
hallucination rate across clinical and financial queries
- 100
- 50
Half the tokens for the same questions