Skip to main content

Interface: IQueryRewriter

Defined in: internal/query-rewriter/types.ts:26

Prompt + thread facts → one search query.

Implemented by QueryRewriter; the type of IAIGatewayDeps.queryRewriter, so a host may pass its own in overrides.

Methods​

rewrite()​

rewrite(__namedParameters): Promise<string>

Defined in: internal/query-rewriter/types.ts:48

rewrite -- the query to embed for one prompt

About​

One standalone line, or the prompt itself.

Renders the KB_QUERY_REWRITE template with the thread's summary and facts (or "(nothing yet)"), sends the prompt as the user message to the cheap model and returns the first line of the answer, unquoted, cut at 500 characters. Returns the prompt itself, without a model call, when the rewriting is switched off or the thread has no memory yet; and when the model call fails or answers with nothing.

Who needs it​

KbRetriever.retrieve, before it embeds.

Pitfalls​

The output limit is 1000 tokens although a query is one line: a reasoning model spends tokens on thinking first, and with a small limit returns nothing.

Parameters​

__namedParameters​
cheapModelId​

string

facts​

Record<string, string>

From WorkingMemory; resolves "it", "that one".

meta​

ILLMClientCallMeta

For the usage adapter and the trace; kind = QUERY_REWRITE.

prompt​

string

summary​

string

Returns​

Promise<string>