Menu
MongoDB Blog·December 2, 2026

Architecting Retrieval Systems for AI Agents: Search, Reranking, and Storage

An architectural deep-dive into how Unblocked built a context retrieval layer for AI coding agents using MongoDB Atlas, Atlas Search, and Voyage AI rerankers. The article explores combining structured database queries with full-text search, handling multi-tenant data schemas from disparate tools, and empowering agents to write their own aggregation pipelines.

Read original on MongoDB Blog

System Architecture Overview

Building a context retrieval engine for AI software development agents requires unifying heterogeneous data sources—such as GitHub, Jira, Slack, and Zendesk—each with its own schema. Unblocked solved this by adopting a document-oriented database model in MongoDB Atlas, maintaining raw tool payloads alongside derived metadata fields within container documents.

The Triad of Retrieval: Search, Filters, and Reranking

Effective agentic retrieval cannot rely on semantic search alone. The system balances three distinct query patterns to ensure high accuracy:

  • Exact Matches: Handling precise error strings, ticket numbers, and function names via inverted indices.
  • Structured Queries: Performing relational-style filters across timestamps, authors, and state tags.
  • Instruction-Steered Reranking: Utilizing Voyage AI rerankers to order hundreds of candidates based on contextual instructions (e.g., favoring code over chat discussions).

Agent-Driven Aggregation Pipelines

A notable architectural pattern in Unblocked's stack is letting AI agents construct their own MongoDB aggregation pipelines. By exposing database schemas and Atlas Search index definitions to the language model, the agent can translate natural language questions directly into optimized data pipelines in a single model turn.

💡

Architectural Trade-off

Allowing agents to write raw aggregation pipelines provides immense query flexibility across diverse third-party schemas, but it demands a robust validation and sandboxing layer before query execution to prevent performance degradation.

mongodbvector-searchrerankingai-agentsdocument-databaseretrieval-augmented-generationsystem-architecture

Comments

Loading comments...

Want the fundamentals behind stories like this? Take the free System Design Academy course with certificate.