Beyond RAG: Build a Relational Context Engine from Scratch — Peter Werry, Unblocked
Source
youtube.com
Author
AI Engineer
Date
Why it matters
Similarity search fails on temporal or structural questions like 'PRs I merged last week'. Having the model write a validated database query, with allow-listed operators and tenant isolation, fixes this safely.
Key takeaways · AI-distilled
Schema discovery samples 300 documents and merges them into one tree with procedural code rather than a model, giving the query planner reliable field types and enums.
Identity resolution uses simple fuzzy matching to map a name like Peter to a GitHub login, and the query planner receives the schema, a forced name-extraction tool call and the current date, which questions like "last week" depend on.
Validation is deny by default: an operator allow list stops a function clause from running JavaScript on the server, and hidden metadata fields are wiped and reinjected to keep tenants isolated.
A retry loop feeds validation and execution errors back to the model, and those failures exposed the need for full-text search where exact matching missed.
Terms in this piece · Glossary
context window — The maximum amount of text a model can consider at once — its working memory for the current conversation or task.
embedding — A list of numbers representing a piece of text's meaning, so that similar meanings end up numerically close and can be searched.