Skip to main content

Class: QueryDispatcher

Defined in: packages/agentos/src/query-router/QueryDispatcher.ts:110

Routes classified queries to the tier-appropriate retrieval pipeline.

Example

const dispatcher = new QueryDispatcher({
vectorSearch: async (q, k) => vectorStore.search(q, k),
graphExpand: async (seeds) => graphRag.expand(seeds),
rerank: async (q, chunks, n) => reranker.rerank(q, chunks, n),
deepResearch: async (q, srcs) => researcher.research(q, srcs),
emit: (e) => eventBus.emit(e),
graphEnabled: true,
deepResearchEnabled: true,
});

const result = await dispatcher.dispatch('How does auth work?', 2);

Constructors

Constructor

new QueryDispatcher(deps): QueryDispatcher

Defined in: packages/agentos/src/query-router/QueryDispatcher.ts:114

Parameters

deps

QueryDispatcherDeps

Returns

QueryDispatcher

Methods

dispatch()

dispatch(query, tier, suggestedSources?): Promise<RetrievalResult>

Defined in: packages/agentos/src/query-router/QueryDispatcher.ts:132

Dispatch a classified query to the tier-appropriate retrieval pipeline.

Parameters

query

string

The user's natural-language query.

tier

QueryTier

Complexity tier assigned by the QueryClassifier.

suggestedSources?

string[]

Optional source hints for deep research (T3). Defaults to ['web'] when not provided.

Returns

Promise<RetrievalResult>

Aggregated retrieval result with chunks, optional synthesis, and timing metadata.