A context engine connects code with the PRs, documents, Slack conversations, and incident history that explain it, then supplies task-specific context to an agent.
2
Structured questions such as which PRs someone merged last week require database queries rather than vector search.
3
A safe document query engine needs schema discovery, identity resolution, query validation, retries, and full-text search around the language model.
Summary
Peter Werry presents a context engine as a way to give coding agents the institutional knowledge around a codebase. In his examples, Claude receives code, Notion documents, pull requests, and Slack conversations related to a task. One session costs about $1.29 with the context engine, compared with up to $2.60 without it. Another session traces a drop in code review findings to a switch between Opus versions and creates a fix. Werry then builds Unblocked's open-source document query engine. He explains why vector search handles semantic questions but cannot answer structural questions about ownership, dates, counts, or rankings. The engine discovers document schemas, maps identities across systems, turns natural-language requests into queries, blocks unsafe operators, retries after errors, and adds full-text search. He closes with a local simulator that compares agent performance with and without pre-gathered context.
A context engine turns scattered institutional knowledge into task-specific context
Werry describes context as more than source code. It also includes documentation, pull requests, reviews, issues, tickets, conversations, and the history of incidents. The engine pulls these sources together into grounded context. That context is interrelated, specific to the task, personalized, and aware of permissions. In his Claude example, the resulting bundle links source code with Notion architecture documents, pull requests, and Slack conversations about optimizing a component. Claude can use those links to fetch more information if needed.
Pre-gathered context can reduce the amount of agent exploration
Without a context engine, Claude starts by exploring the codebase to understand the task. Werry compares that with a session where the engine provides a comprehensive context bundle at the start. The example with context costs $1.29 and takes about a minute and 30 seconds. The comparable session without context costs up to $2.60 and takes three minutes. Werry describes this as a 50% reduction in cost.
Context helped trace a code review regression to a model switch
A colleague noticed that Unblocked's code review product was finding fewer issues. The colleague asked Unblocked about the change, and it narrowed the likely cause to a switch between Opus versions. The agent then created a pull request to address the problem. Werry says the generated description understood which pull request caused the regression and used a related Slack conversation and its data to inform the fix.
Vector search handles content questions, while relational queries handle structure
Werry says retrieval has a semantic half and a structured half. RAG can help find code, the pull request that changed it, or a Slack thread discussing it. It does not directly answer questions such as which pull requests someone merged last week, who reviewed payments most often, or how many pull requests are open. A request for a weekly chart since a particular date also needs information encoded in a queryable data store rather than only in a vector store.
The surrounding query system is harder than generating a query
Werry calls query generation the easy part. The system first needs to understand the document schema so the model can produce a tightly bound query. It must resolve names across systems, because a person's identity in GitHub may differ from the name used in a question. It also has to treat model-generated queries as untrusted, since they may contain dangerous operations or cross tenant boundaries. Database errors still need a recovery path after validation.
Schema and identity resolution can use procedural methods before an LLM
The document query engine discovers a schema dynamically by sampling documents in the store and deriving fields from them. Werry discusses inferring enums as one difficult part of the process. He argues that this work is often deterministic enough for traditional procedural code, rather than requiring an LLM. Identity resolution follows the same pattern. The system can use fuzzy matching across usernames and identities, then pass a list of candidates to an LLM as a tiebreaker when necessary.
Validation blocks dangerous queries and protects hidden tenant fields
After the model synthesizes a query from the schema, current time, and user information, the engine validates it. Werry gives the function operator as an example of a dangerous feature because it could execute raw JavaScript on the database server. Hidden metadata fields can also expose tenant IDs or other information that the model should not access. The system can keep those fields outside the model's reach and inject the needed constraints behind the scenes.
Retries turn validation errors into feedback for the model
When validation rejects a query, the engine can send the error back to the language model and ask it to correct the query. Werry describes the implementation as a loop with a maximum retry count. In the demo, the model takes more than one attempt and eventually produces an allowed query. That query still uses exact title matching, which returns no results, so the engine needs full-text search to answer the request properly.
A local simulator tests whether gathered context helps an agent
The context engine simulator is an open-source option for teams that cannot immediately connect Unblocked to their environment. It creates a context bundle for each task, then runs an A/B test against the same task. The comparison shows what changes when an agent has the gathered context available. This lets a team test the effect of pre-gathered context locally before wiring up a production context engine.
"What a context engine does is it takes all of that institutional knowledge and it pulls it in and what you get the scattered context that goes into the context engine and out the other end you get grounded context."01:37
Who should watch
You are building coding agents that spend too much time exploring a repository before they can act.
Your agent needs to answer ownership, time-range, filtering, aggregation, or cross-system identity questions that vector search cannot answer directly.
You want to test structured context locally before connecting an agent to an organization's internal systems.