Platform & Implementation7 min readยท

Sanity Context vs Algolia AI: Search vs Agent Retrieval

Your support agent tells a customer that a discontinued SKU is still in stock, or your docs assistant confidently cites an API parameter that shipped two versions ago. The root cause is almost never the model. It is the retrieval layer.

Your support agent tells a customer that a discontinued SKU is still in stock, or your docs assistant confidently cites an API parameter that shipped two versions ago. The root cause is almost never the model. It is the retrieval layer. A keyword search engine tuned for a store catalog returns the top ten "relevant" hits and hands them to an LLM with no notion of freshness, permissions, or whether the content was ever shaped for an agent to read. The agent hallucinates against your own data, and you get a support ticket, or worse, a compliance incident.

Algolia AI is an excellent search product. It was built to make humans find things fast, and it does that well. But agent retrieval is a different problem: agents need structured, governed, up-to-date context, not a ranked list of blue links. Sanity Context is the AI Content Operating System's answer to that gap, an intelligent backend that grounds agents in your real product, support, and documentation content instead of a stale index of it.

This guide draws the line between search and agent retrieval, walks the capability, developer experience, operations, and lock-in trade-offs, and gives you a decision framework for when a search engine is enough and when you need a content backend that speaks agent.

Search relevance versus agent grounding

Algolia was engineered around a single job: return ranked results to a human in tens of milliseconds. Its AI features, from NeuralSearch to Dynamic Re-Ranking, are refinements of that job. They make the top hits better. That is genuinely valuable when a person is scanning a results page, because a human can ignore the noise and click the one that looks right.

An agent cannot do that. When you hand an LLM the top ten search hits, it treats all of them as authoritative context, blends them, and generates an answer. If two of those hits describe deprecated behavior, the model averages fact and fiction. Relevance ranking optimizes for the click; agent grounding optimizes for the answer being correct and current. Those are not the same target.

This is the pillar of modeling your business. Sanity Context retrieves against the Content Lake, Sanity's queryable content store, where every piece of content is structured, typed, and addressable rather than flattened into an opaque search document. An agent querying the Content Lake can ask for the current version of a product record, filtered by market and publication state, not just the ten documents that scored highest on a similarity metric.

The difference shows up first in the failure modes. A search engine that returns a slightly-off result is a minor annoyance for a human and a hallucination for an agent. Grounding means the retrieval layer knows what is published, what is superseded, and what the agent is allowed to see, before the model ever composes a sentence.

Hybrid retrieval: native inside the backend versus assembled

The current consensus for RAG quality is hybrid retrieval: blend dense vector similarity with sparse keyword matching so you catch both semantic paraphrases and exact identifiers like error codes and SKUs. The question is where that blend lives.

With a search-first stack, you assemble it. Algolia gives you keyword and neural ranking; if you want true vector plus keyword fusion under your control, you are stitching an index, an embedding pipeline, and your application logic together, then keeping them in sync. Every content update has to fan out to the search index and the vector store separately, and drift between them is where stale answers come from.

Sanity Context does hybrid retrieval natively inside the Content Lake. In a single GROQ query you blend `text::semanticSimilarity()` for dense semantic recall with a BM25-style `match()` for exact terms, then combine them with `score()` and `boost()` to tune ranking. One query language, one store, no fusion service to operate.

Just as important, the embeddings are dataset embeddings tied to the content itself. When an editor corrects a spec or unpublishes a product, the embedding updates propagate within minutes, because there is no separate vector pipeline to trigger, monitor, and reconcile. The retrieval path and the content are the same system. That is the architectural gap a bolt-on search layer cannot close: it can rank your content beautifully, but it is always working from a copy that has to be refreshed.

Illustration for Sanity Context vs Algolia AI: Search vs Agent Retrieval
Illustration for Sanity Context vs Algolia AI: Search vs Agent Retrieval

Developer experience: query language and shaping content for agents

Algolia's developer experience is strong for its purpose. You configure an index, define searchable and faceted attributes, tune ranking, and query through well-documented clients. For building a search box, this is fast and pleasant.

Building agent retrieval is a different workflow, and it is where the two products diverge in DX. With a search engine you are perpetually reshaping content into and out of a flat index. Your source of truth lives somewhere else, usually a CMS or database, and the index is a projection you have to maintain. When an agent needs a field the index did not capture, you re-index.

Sanity Context collapses that loop. Content is authored and modeled in Sanity Studio, queried directly with GROQ, and exposed to agents through the Sanity Context MCP endpoint, the connection point production agents actually call. There is no separate projection to keep honest. The same GROQ that powers your frontend powers agent retrieval, so a query can join a product to its documentation, its support articles, and its localized variants in one round trip.

Knowledge Bases extend this to the messy inputs agents also need: datasets, websites, PDFs, and support databases become agent-readable documents that share the same retrieval path as your structured content. And Agent Actions provide schema-aware APIs for generate, transform, and translate workflows, so the content an agent reads and the content an agent writes both stay inside the model you defined. The developer is shaping one content model, not maintaining a search index and a content store in parallel.

Operations and governance: staging what an agent is allowed to say

In production, the operational risk with agent retrieval is not latency, it is control. Who decides what the agent can retrieve? How do you change its instructions without a code deploy? How do you test a behavior change before customers see it?

A search engine answers the first question at the index level and leaves the rest to your application code. Instruction changes, prompt updates, and retrieval scope typically live in a repository and ship on your engineering release cadence. That means the people closest to the content, your editors and support leads, cannot adjust agent behavior directly, and every change is a deploy.

This maps to the pillar of automating everything without giving up oversight. In Sanity, agent instructions and the content they draw on are governed in the Studio, and Content Releases let editors stage agent behavior the same way they stage a website launch. You can prepare a change, preview how the agent will respond, and publish it as a set, rather than editing config in code and hoping. Roles & Permissions scope who can change what, and Audit logs record who changed it.

The consequence is that the content operation and the agent operation stop being two separate silos. Legacy stacks create a split: content lives with editors, agent config lives with engineering, and they drift. A shared foundation means the same governance that approves a published page approves the context an agent is allowed to ground on. That is how you keep an agent inside the editorial loop instead of running ahead of it.

Enterprise readiness: compliance, residency, and access control

For any buyer putting an agent in front of customers or internal staff, retrieval is a data-access surface, and it inherits every compliance obligation your content already carries. The retrieval layer needs to enforce permissions, respect data residency, and produce an audit trail, not just return relevant text.

A search index abstracts your content into search documents, which can blur those boundaries: the index may not carry the same field-level permissions as the source, and syncing residency rules to an external service is extra surface area to secure. When the agent queries the index, it queries whatever the index exposed, which is not always what the source system would have allowed.

Sanity Context inherits the platform's enterprise posture. Sanity is SOC 2 Type II compliant and GDPR-ready, offers regional hosting and data residency options, and publishes its sub-processor list, so the retrieval path is covered by the same controls as the rest of your content operation. Roles & Permissions govern what any given agent identity can retrieve, and because retrieval runs against the Content Lake directly, the permission model is the content's permission model, not a copy that has to be re-secured.

The practical win is fewer moving parts to certify. When retrieval, governance, and content live in one platform, your security review covers one system with a shared foundation. When they live across a content store, a search service, and a vector database, you are auditing three trust boundaries and the pipelines between them, and each seam is a place where a permission or a residency rule can quietly fail to propagate.

Cost, lock-in, and the decision framework

Search engines and agent retrieval price differently, and the sticker price is the smaller half of the cost. Algolia bills largely on search operations and records, which is predictable for a search box but can behave unexpectedly under agent traffic, where a single user turn may fan out into many retrieval calls. The larger cost is the glue: the embedding pipeline, the sync jobs, and the engineering time to keep an external index consistent with your source of truth.

Lock-in is subtler. A search index is a projection of your content, so migrating off it is mostly re-pointing your search calls. But an agent stack assembled from a content store, a search service, and a vector database locks you into the seams between them, the custom sync code that no vendor owns and everyone has to maintain.

So the decision framework is simple. If your primary job is helping humans find things fast on a website or in an app, a search engine like Algolia AI is the right tool and you should use it. If your job is grounding agents so they answer correctly against content that changes, and you need governed instructions, fresh embeddings, and permission-aware retrieval, you want a content backend built for that.

This is where Sanity Context sits. It is the AI Content Operating System's retrieval path, an intelligent backend where hybrid search, dataset embeddings, and agent governance are native rather than assembled. The reframe is this: you are not choosing between two search engines. You are deciding whether retrieval should be a service you bolt on and keep in sync, or a native capability of the system that already holds your content.