Building a search relevance factory Search consultant Doug Turnbull built a custom coding-agent harness for search relevance tuning after finding that naive autoresearch overfits, citing a patch that hard-coded a special ranking path for queries containing "shoe" and lifted NDCG@10 from 0.62 to 0.89 on "running shoes" while dropping "wireless headphones" from 0.81 to 0.70. Turnbull's harness, demonstrated on Turbopuffer with Amazon's ESCI e-commerce dataset, exposes a check_patch tool that applies an agent-proposed patch and returns per-query NDCG@10 before and after scores so overfitting is visible. The approach matters because it gives teams a way to let fleets of coding agents improve ranking algorithms without letting them memorize the evaluation set. Search engines / vector databases come with many knobs and dials. Ways to combine retrieval steps, lexical + embedding search, rerankers, etc to pull back the most relevant results. I’ve seen multi-page queries that could make you cry. Tuning search relevance takes work. But now we have Autoresearch. Given good evals https://softwaredoug.com/blog/2021/02/21/what-is-a-judgment-list , your coding agent can generate better ranking algorithms, right? Let’s walk through how I’ve unleashed /goal on Turbopuffer. I’ve built what I feel is a relevance factory a way to unleash fleets of coding agents on your search problem. I’ll start with methodological details: how to unleash models on relevance without overfitting. Then I’ll go through some fun findings on Amazon’s ESCI e-commerce dataset https://github.com/amazon-science/esci-data . In this article Broke: my own autoresearch coding harness Unfortunately, naive autoresearch can overfit. If you prompt a coding agent to “improve relevance”, it can litter code with if "shoe" in query, search-this-very-specific-way . Sure that works on the “shoe” queries in the training set, but doesn’t create general ranking algorithm. So instead of Claude Code, etc, I built my own coding harness for autoresearch https://archive.haystackconf.com/us2026/talk-6/ notebook here https://colab.research.google.com/drive/1g2b21HjL24cobnaFCypGuxp4cCQP4dMg to control eval visibility and double check we’re not overfit. Let’s briefly walk my original way of approach this problem, as shown in the diagram below. In my harness, we might start with a code snippet searching Turbopuffer like python def search query: str, top k: int = 10 : normalized query = query.strip .lower results = ns.query rank by= "description", "BM25", normalized query , top k=top k, An agent sees this, and proposes search relevance code patches by calling my custom tools. Like check patch : python def check patch ...patch... """Patch code search code, measure its impact to some search evals.""" patch code search before = eval search code search code patched = eval patch search code, ...patch... get evals evals = for query in queries: ndcg before = eval search before query ndcg after = eval search code patched query evals.append {"query": "query, "ndcg before": ndcg before, "ndcg after": ndcg after} return evals For example this patch suggests weirdly specific ranking for “shoe” searches. php def search query: str, top k: int = 10 - SearchResults: normalized query = query.strip .lower + Shoe queries benefit from stronger description matching. + Weights tuned against the relevance evaluation set. + if "shoe" in normalized query: + results = ns.query + rank by= "Sum", + "Product", 4.5, "description", "BM25", normalized query , + "Product", 1.25, "title", "BM25", normalized query , + , + top k=top k, + include attributes= "title", "description" , + + return results.rows + return run search SearchRequest query=normalized query , top k=top k My harness’s ‘check patch …patch… ’ tool creates new search ... function from the patch. It runs the new function against some evals. The tool calls search "running shoes" then search "wireless headphones" repeating for every training query. For each, search generates top K results, labels results as relevant or not. Eventually check patch generates per-query evals: | Query | NDCG@10 Before | NDCG@10 After | Δ | |---|---|---|---| | running shoes | 0.62 | 0.89 | +0.27 | | wireless headphones | 0.81 | 0.70 | -0.11 | | men’s dress shoes | 0.71 | 0.93 | +0.22 | | laptop stand | 0.79 | 0.67 | -0.12 | | hiking shoes | 0.58 | 0.86 | +0.28 | | coffee maker | 0.83 | 0.75 | -0.08 | | women’s walking shoes | 0.69 | 0.91 | +0.22 | | bluetooth speaker | 0.77 | 0.64 | -0.13 | | kids school shoes | 0.65 | 0.88 | +0.23 | | winter jacket | 0.74 | 0.65 | -0.09 | | Average | 0.719 | 0.788 | +0.069 | That goes back to the agent, letting it see how the patch hurt / helped. I call these queries training queries because I’m treating autoresearch like any other training process. The agent can see the training set. It can inspect every observation completely. It can see how its proposed solutions impact the goals of the process. They’re the observations being actively fitted. Contrast that with a holdout. The training process an agent here would NOT have visibility into these observations. It does not fit to those observations. We haven’t talked about a holdout set yet. In my home-grown autoresearch loop, the harness checks final solutions against the holdout set. So, back to our coding agent. Eventually the agent seems satisfied with its tinkering. It attempts to save the change with commit patch ...patch... tool. That will save it to disk. Now and this is the important part , hidden from the agent, commit patch confirms the new search function against holdout queries. Behind the scenes, without the agent seeing each query’s results, the harness analyzes the new function on a holdout query set. python def commit patch ...patch... """Patch code search code, measure its impact to some search evals.""" patch code as above ... get evals same as above, but on a holdout set evals = for query in holdout queries: ... Compute mean NDCG before and after holdout before = mean e "ndcg before" for e in evals holdout after = mean e "ndcg after" for e in evals Only commit if relevance improves if holdout after holdout before: commit patch save to disk return "SUCCESS" else: reject patch return "FAIL" In our case, we compute the following changes on a different query set from above. | Query | NDCG@10 Before | NDCG@10 After | Δ | |---|---|---|---| | trail running shoes | 0.64 | 0.82 | +0.18 | | wireless headphones | 0.81 | 0.70 | -0.11 | | laptop stand | 0.79 | 0.67 | -0.12 | | coffee maker | 0.83 | 0.75 | -0.08 | | … | … | … | … | | winter jacket | 0.74 | 0.65 | -0.09 | | yoga mat | 0.75 | 0.64 | -0.11 | | Average | 0.769 | 0.704 | -0.065 | We note on the final line, the negative results on the holdout set. So we reject this change. We tell the agent it failed and to keep trying. But we never tell the agent why / how it failed . Otherwise, it’d just overfit to those too. Since I control the harness, tools, and agent, I can limit visibility. Models see training queries. They never see holdout queries. That lets holdout act as a final check on overfitting, preventing a primordial soup of if