Mahal Systems

Overview › 8Retrieval › b.Querying precisely

Querying precisely

2 optimizations.

  1. i.

    Tune the search tool: snippets, enough results, retries, reformulation, filters, source quality

    Make the search tool return what the model needs to choose what to open (a snippet per result, not just titles; five or more results; a full-document reader beside truncated search), retry failed searches, and reformulate when a query returns little (start broad, then narrow; use the corpus's own terms) rather than retrying it verbatim.

    Mixed qualityMixed cost

    Tier 2 · reliability · changes knowledge access · retrieval, web research agents · 8 sources, 3 measured

  2. ii.

    Link large schemas by exploration: start broad, grow the linked set with probing queries, favor recall

    When a schema is too large to load whole, link the tables and columns a question needs by exploration rather than by one up-front retrieval or by loading everything: start from all table names plus the top retrieved columns, give the agent a column-level vector index, metadata probes and trial queries to grow the linked set, favor recall over minimizing noise, and cap the exploration turns low.

    Better qualityLower cost

    Tier 3 · tuning · changes knowledge access, control flow · data analysis agents · 11 sources, 9 measured

See also

  1. 5.b.i

    Give the model the schema it queries, in context: descriptions, keys, codes, sample values

    When the model writes SQL or structured filters, put the schema it is querying in its context: table and column descriptions, key relationships, what enum codes and nulls mean, sample values.

    Context › Filtering input

    Better qualityHigher cost

    Tier 3 · tuning · changes knowledge access, context · data analysis agents · 4 sources, 2 measured

  2. 7.a.i

    Route metric questions through a deterministic semantic layer; fall back to text-to-SQL

    Where a semantic layer exists, have the agent answer metric questions by choosing metrics and dimensions that the layer compiles to SQL, and write SQL only when the layer cannot answer.

    Orchestration › Routing

    Better quality

    Tier 3 · tuning · changes control flow, knowledge access · data analysis agents · 4 sources, 3 measured

  3. 8.a.i

    Choose the retriever by corpus size and question type

    On a bounded corpus (up to about 100K documents), grep and file reads over the raw text beat an embedding retriever: the agent narrows into documents it has found.

    Retrieval › Expanding sources

    Better qualityLower cost

    Tier 3 · tuning · changes knowledge access, control flow · retrieval agents · 25 sources, 22 measured

Before you go...

Build better agents, weekly

Our latest research, performance benchmarks, optimization strategies, and updates around AOT development.

One email a week, nothing else. Unsubscribe anytime.