AI Engineer World's Fair 2026

Beyond RAG: A Relational Context Engine That Cuts Token Burn — Unblocked

Read the talk

Beyond RAG: A Relational Context Engine That Cuts Token Burn

Peter Werry explains how Unblocked connects code with organizational history, then builds a document query engine that turns natural-language questions into validated, time-scoped database queries.

From a talk by Peter Werry

At a glance

Ideas worth remembering

  • Task-specific context connects code with architecture documents, PRs and conversations, reducing the discovery work an agent must perform.

  • Identity, time, state and aggregation questions require structured queries alongside semantic retrieval.

  • Schema discovery and identity matching can use procedural methods, reserving the model for query synthesis or ambiguous matches.

  • Validate model-generated operations and inject tenant constraints outside the model’s control.

  • Retries can produce an allowed query that misses the intended meaning. The authentication example needed full-text search as well as error feedback.

  • The local context engine simulator tests task-specific bundles through A/B comparisons on the same task.

The new employee problem follows agents into the codebase

A new employee can read the code and still miss why it works that way. Architecture documents explain some decisions; pull requests and conversations explain others. Incident history carries the “battle scars” that make an apparently straightforward change risky. Peter Werry, founding engineer at Unblocked, starts with this familiar discovery problem: before coding agents, people assembled that context themselves.

A context engine pulls that scattered institutional knowledge together. In Werry’s definition, the output is grounded context: information connected across sources, selected for the task, personalized to the user and aware of permissions. The useful unit is therefore more than a relevant document. It is a set of related evidence that helps explain the work in front of the agent.

0:120:54
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

0:12 · section reference included

Give Claude the architecture and the discussion behind the code

The first comparison asks Claude to plan an optimization of an internal component. Without a context engine, Claude starts by searching the codebase and assembling its own understanding. It eventually produces a recommendation, although Werry adds the familiar qualification: it at least “confidently projects” that it has figured things out.

With Unblocked attached, Claude calls the context engine and receives a task-specific bundle. The bundle connects source code with Notion architecture documents, pull requests and Slack conversations about optimizing the component. Those links also give Claude places to investigate further. Instead of discovering every relationship through successive searches, the agent starts with related material already assembled.

Werry reports $1.29 and about a minute and thirty seconds for the session with context, compared with up to $2.60 and three minutes without it—approximately a 50% cost reduction. These are results from the displayed sessions, rather than a general benchmark. They illustrate the proposed economy: useful context can reduce the exploration an agent performs before it can produce a plan.

2:212:51
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

2:12 · section reference included

A regression needs history as well as code

The next example starts with a change in product behavior. Richie, a colleague working on Unblocked’s code review product, notices that it is surfacing fewer issues. Unblocked narrows the investigation to a likely cause: a model switch changed the review behavior. That remains a diagnosis presented in the demonstration; the recording does not establish a controlled causal test.

Richie then asks Unblocked to fix it. The system creates a pull request whose description connects the earlier PR associated with the regression, a Slack discussion and relevant data. The important relationship runs across systems: a code change records what changed, a conversation supplies the surrounding interpretation, and product data helps explain the symptom. Together, those sources inform the proposed fix.

A pull request description is open in the code review interface.Open full source frame
A pull request description is open in the code review interface.
4:214:51
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

4:21 · section reference included

“My PRs last week” requires a query

The build portion begins with a distinction inside the same organizational data. PRs, reviews, comments, tickets, documents and conversations contain searchable content, but they also have structure. RAG can find code, the PR that changed it and the thread debating it. An agent loop with additional file-search tools can carry that investigation further.

Other questions require selecting and computing over records:

  • Identity and time: Which PRs did I merge last week?
  • Counts and rankings: Who reviewed payments the most?
  • State: Which PRs are open?
  • Time series: Show a weekly ratio chart since January 1st.

The time-series request was how Richie’s investigation began. Retrieving semantically similar text does not itself compute a weekly series over the underlying records. That requires a query engine. Werry describes retrieval as having two halves: semantic retrieval for relevant content, and structured retrieval for filters, temporal conditions and aggregations.

Generating the query is the easy part of this design. The surrounding system must tell the model which fields exist, resolve a person’s name to the identifier used by the source system, validate the proposed operations and recover from errors. A fluent query can still be dangerous or cross tenant boundaries. Natural language makes the interface convenient; it does not make the resulting database operation trustworthy.

The slide contrasts structured queries with vector search, listing time reasoning, relationship traversal, and filtering, counting and aggregation.Open full source frame
The slide contrasts structured queries with vector search, listing time reasoning, relationship traversal, and filtering, counting and aggregation.
6:176:45
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

6:17 · section reference included

Discover the schema, resolve the person, then synthesize

The open-source Document Query Engine starts as an unwired demo: a question produces nothing. Werry adds the surrounding capabilities in stages. The first is automatic schema discovery. For the Mongo document store, the engine samples documents and derives a schema at runtime, giving the model a description of the data it can query.

Inferring enums—fields with a limited set of possible values—is one tricky part of that discovery. An LLM can help, but Werry’s preference is to get as far as possible with procedural methods. Work that looks uncertain at first can still admit a deterministic solution. The resulting demo exposes the schema of a GitHub pull-request collection along with indexes that can help query performance. Because discovery uses samples, it describes the sampled documents rather than guaranteeing that every possible document shape has been seen.

Identity resolution follows the same preference for simple machinery. A human name in a question may differ from a GitHub username or an identity in another system. Procedural matching, including fuzzy matching, connects those identities. If several candidates remain, the model can act as a tiebreaker over a supplied list rather than inventing an identifier.

Query synthesis then receives the discovered schema, the current date and time, and potentially information about the requesting user. Each input removes an ambiguity: the schema constrains field choices, the clock grounds relative periods, and user information lets “my PRs” refer to the right person. With these pieces connected, the demo generates a query and pulls documents.

Synthesis supplies the schema and forces a QueryPlan tool call. The model proposes structured query arguments; validation still decides whether they may run.Open full source frame
Synthesis supplies the schema and forces a QueryPlan tool call. The model proposes structured query arguments; validation still decides whether they may run.
9:4810:19
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

9:48 · section reference included

Keep database permissions outside the model’s proposal

Validation is the most important stage in Werry’s account. The proposed query is untrusted even when synthesis has the right schema. Two kinds of control matter:

  • Operator restrictions: Reject dangerous operations, such as a function operator that executes raw JavaScript on the database server.
  • Protected fields and tenant constraints: Keep hidden metadata out of the model’s choices. If a tenant ID must constrain every query, inject that constraint behind the scenes rather than asking the model to manage it.

The next question makes validation observable: find PRs with authentication in the title. The model produces a regular-expression approach, and the demo’s validator rejects it because regular expressions are disallowed. This is an application policy demonstrated by this engine. Rejection preserves the restriction, but it also leaves the user’s useful question unanswered.

A slide titled “Step 4: Validation” describes checking untrusted model output before it runs.Open full source frame
A slide titled “Step 4: Validation” describes checking untrusted model output before it runs.
8:5013:45
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

13:45 · section reference included

Turn retrieved records into an answer—and test context locally

The final agent demonstration combines the capabilities in a broader question: “What authentication-related things have we been working on last week?” The engine supports filters, aggregations and time-scoped queries; the chat interface shows the queries it creates, then reasons over the retrieved data. Structured retrieval supplies the records that the answer needs, while the agent turns those records into an explanation.

The ending returns to the practical question raised by the first cost comparison: does pre-gathered context help your agent on your tasks? Werry introduces an open-source context engine simulator for environments where connecting Unblocked immediately is impractical. It runs locally, creates a context bundle for each task, and uses that bundle in an A/B test against the same task. That offers a way to investigate the value of context in a particular workflow before wiring in the full product.

The context engine simulator screen shows several comparison metrics and a QR code.Open full source frame
The context engine simulator screen shows several comparison metrics and a QR code.
17:2918:00
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

17:29 · section reference included

Resources

From the talk

Transcript download
Read the transcript and explore slides

Loading transcript and slides…