Skip to content

SearchFileConfig

Configuration for the search.file() middleware.

optional mode?: "tool" | "auto"

Retrieval mode.

  • "tool" (default): registers a search_knowledge tool, model decides when to search.
  • "auto": retrieves every turn using the latest user message.

retrieve: (query) => Promise<Chunk[]>

Retriever function — returns relevant chunks for a query.

string

Promise<Chunk[]>


optional rewriteQuery?: (message, history) => string

Custom query rewrite function (auto mode only).

string

Message[]

string


optional topK?: number

Maximum chunks to inject into context. Default: 5.