All bits

Bit

Agent harness tip: a naive search_codebase tool is the fastest way to burn your context window and your latency budget in production.

In a prototype, the agent greps a small repo and pastes the hits into the model. In an enterprise workflow, the same call returns thousands of hits, fills the context with vendor noise, and forces a multi-second LLM round trip just to work out what the user meant. Retrieval accuracy holds up fine. What breaks is the output: it arrives unbounded, unranked and unfiltered, and the context is finite.

Here is how we architected around it.

Deterministic pre-filtering runs before any model does: Every query is clamped before execution, with hard caps on result count and hits per file, exclusions for build artifacts and dependencies, extension filters, and pagination instead of truncation. One noisy file can’t dominate the results, and the agent knows when output was paged rather than silently cut.

Query interpretation is tiered: A small, cached model call turns natural-language questions into structured search parameters. When that layer is unavailable, a deterministic term extractor takes over. When the caller already supplied structured criteria, the LLM round trip is skipped entirely. The model only runs on queries that need it.

Semantic reranking sits behind a seam: It either re-orders the top results in one fast pass or drives a guided hierarchical traversal that finds files that never contain the literal search terms. If it’s unavailable or disabled, the deterministic pipeline still returns correct, ranked results, with a warning. Nothing between the agent and its answers is a single point of failure.

The result is search that stays fast, bounded and deterministic even when the semantic layer is down. Retrieval is a contract with your context window.