Skip to main content
AI AUTOMATION

Answers from the vendor's docs, not from memory

A scraper, a hybrid vector and keyword index, and an MCP tool that hands a coding agent cited documentation.

THE PROBLEM

What was in the way

A coding assistant only knows what was in its training data. Vendor APIs move faster than that, so the model answers with parameters that were real a year ago and are not real now. The failure is quiet. The code looks right until it runs.

Pasting the correct doc page into the prompt works once. It stops working when the answer is spread across an API reference, a guide and a release note, and it never scales past the person doing the pasting.

THE APPROACH

How it was built

Pages come from the site's own sitemap, fetched under its robots rules, converted to markdown and split at header boundaries into chunks of about 400 tokens. A code example too long for one chunk is kept whole rather than cut in half. API documentation is half prose and half example, and a chunk that ends mid-example is worse than no chunk at all.

Each chunk is indexed twice, as a dense embedding for meaning and as a BM25 sparse vector for exact parameter names. A query hits both, the two result sets are fused, and a cross-encoder re-scores the top twenty candidates before five are returned.

Docs site to agent answer
Docs site to agent answer
HIGHLIGHTS

How it works

Two indexes, then a re-ranker

Semantic search finds the concept and BM25 finds the exact parameter name. The fused list is re-scored by a cross-encoder before the top five go back to the agent.

Every result names its source

A result carries its heading trail and the URL of the page it came from, so a claim can be checked against the document instead of taken on trust.

Nightly refresh that probes before it fetches

Conditional requests mean only changed pages are re-embedded. Pages that drop out of the sitemap are marked stale and deleted after a week.

RESULTS

What it does now

cites the source documentheading trail and URL on every result
returns nothing when unsureconfidence gate on the reranked top score
re-indexes only what changedconditional requests, then a content hash
STACK

What it is built on

Pythonscrape, index and serve
Qdrantdense and sparse vector store
sentence-transformersembeddings and cross-encoder
MCPtool interface for the agent
Playwrightfallback for JS-rendered pages
FastAPI and APSchedulerscheduled refresh service
pytestunit and integration tests

Got something in your workflow that looks like this?