Ask

Ask and search

This page covers how a question becomes an answer: the three answer paths, automatic routing, the options you can set, and what comes back.

Answer paths

Three answer paths share one setting, query.path. Each returns the same evidence budget (query.topK, 20 by default), the canonical fields of the entities it touched, and a written answer when an answer model is set. The code is in src/query/paths.ts.

Path How it works Best for
search Hybrid keyword and vector search over every chunk, optional reranking, then an answer Questions answered by passages in documents
agent A tool per source: SQL over tables, search over text, entity lookup. With a model, it plans its own calls for up to five steps. Without one, it runs SQL at every address the question names, then a search per source Mixed sources, numbers from tables, multi-step questions
entities Links the question to canonical entities, follows the graph one hop, and searches only the records that mention them Questions about a specific business, address or person

On the demo, a search-path question that counts or ranks, such as "How many paintings by Claude Monet are in the set?", also runs one query over the dataset's tables, since search sees only the closest twenty passages. Uploads and the art set work this way. From the command line, --tables does the same, so the art eval matches the demo:

sh
deno task sf eval --data tmp/art-demo --golden evals/art/golden.json --path search --model claude/inline --tables

With query.prefetch set to context (the default), the agent path starts with a hybrid search and a lookup of the entities the question names, both loaded into its first prompt, so many questions need no tool call.

Automatic routing

--path auto lets a router pick the path per question. The router is a route adapter, cascade/[email protected] by default: an embedding centroid classifier answers when its confidence is at least 0.3, and Qwen3 4B on MLX decides the rest. If the router fails or names an unknown path, the question falls back to search. The routing decision and its reason are added to the trace.

On a held-out set of 60 questions across four domains, the local cascade picks the labeled best path 93% of the time. cascade/[email protected] does slightly better when a model call off the machine is acceptable. See Pipeline and adapters for every router id.

Asking from the command line

sh
deno task sf ask "Which businesses on Valencia Street had permit trouble?" --path auto --answer
Option Effect
--path search|agent|entities|auto The answer path, or auto to let the router pick. Default search
--answer Write an answer with claude/inline
--model <id> Answer model by id, such as claude/inline or mlx/qwen3-8b
--router <id> Route adapter for --path auto. Default cascade/[email protected]
--rerank <id> Rerank adapter. Default none
--embed <id> Embed adapter. Default local/bge-small
--store <id> Where chunk search lives: builtin, store/sqlite-vec, store/sqlite-brute or store/pgvector
--keyword-only BM25 alone, no vectors
--k <n> Evidence budget per answer. Default 20
--prefetch none|context Whether the agent path loads search hits and entities before its first turn
--format md|xml|json Terminal rendering (default), the XML answer, or the full answer object
--data <dir> Data folder. Default tmp/sf

Ingest and ask with the same --embed, --store and --keyword-only values. Without --answer or --model, the answer model is none: Groundwork returns evidence and canonical fields with no generated text.

What comes back

Every path returns an AnswerData object (src/query/types.ts):

ts
type AnswerData = {
  path: "search" | "agent" | "entities";
  question: string;
  evidence: Evidence[];    // retrieved chunks and rows, each with id, source, title, text, page or time, score, and how it was found
  entities: EntityCard[];  // canonical entities: key, type, fields, the record each field came from, mention count
  answer?: string;         // present when an answer model is set
  trace: Step[];           // each tool call: tool, input, output, milliseconds
  modelCalls: number;
  ms: number;
};

The command line adds the audit run id. With --format xml the answer becomes an answer document with numbered sources and a citation check (see Answer format). With --format json you get the object above plus runId.

The via field on each piece of evidence says how it was found, such as keyword, sql, search permits, prefetch or entity address.150-hayes-st. Together with the trace, it shows why a source was in the context.

Tracing an answer

sh
deno task gw audit <run-id>

This prints every audited adapter call behind the answer, in order. See the Quickstart.

Search on its own

The search path without an answer model is the closest thing to a search endpoint in the prototype: run it without --answer and read the evidence list.

sh
deno task sf ask "outdoor dining on Valencia" --path search --format json

On the demo today

Files uploaded to the demo can be asked over POST /v1/ask and searched over POST /v1/search with a key from get started, and the same two tools are served over MCP at /mcp. Try your own files has the requests.

The planned hosted API

The hosted API is in design and its shapes may change. It separates asking from searching:

sh
curl https://api.groundwork.dev/v1/projects/acme/ask \
  -H "Authorization: Bearer $GW_KEY" \
  -d '{ "question": "Which carriers raised dental premiums in 2025?" }'

curl https://api.groundwork.dev/v1/projects/acme/search \
  -H "Authorization: Bearer $GW_KEY" \
  -d '{ "query": "termination clause", "topK": 10, "filter": { "tags": "contracts" } }'
ts
const { answer, citations } = await gw.ask("Which carriers raised dental premiums in 2025?");
const hits = await gw.search("termination clause", { topK: 10, filter: { tags: "contracts" } });

In the hosted product, which path runs is a project setting chosen per use case by evals, and the router can pick per question. See Ask, Search and Entities in the API reference.