Interface: QueryRouterConfig
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:427
Public constructor configuration for the QueryRouter pipeline.
knowledgeCorpus is required. All other fields are optional and default to
the values in DEFAULT_QUERY_ROUTER_CONFIG.
Example
const router = new QueryRouter({
knowledgeCorpus: ['./docs', './packages/agentos/docs'],
availableTools: ['web_search', 'deep_research'],
maxTier: 3,
});
Properties
apiKey?
optionalapiKey:string
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:575
Optional API key override for classifier and generator LLM calls.
When omitted, QueryRouter prefers OPENAI_API_KEY and falls back to
OPENROUTER_API_KEY with the OpenRouter compatibility base URL.
availableTools?
optionalavailableTools:string[]
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:511
Optional tool/capability names exposed to the classifier prompt so it can reason about what the runtime can actually do.
Default
[]
baseUrl?
optionalbaseUrl:string
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:583
Optional base URL override for classifier and generator LLM providers.
When omitted, QueryRouter auto-selects the OpenRouter compatibility URL
only when OPENROUTER_API_KEY is being used implicitly.
cacheResults?
optionalcacheResults:boolean
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:504
Whether to cache query results.
When enabled, route() caches completed QueryResult objects in memory
and reuses them for identical query/history/request-option inputs until
router state changes (for example corpus refresh or retriever swap).
Default
true
classifierModel?
optionalclassifierModel:string
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:445
LLM model for the classifier.
Default
'gpt-4o-mini'
classifierProvider?
optionalclassifierProvider:string
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:448
LLM provider for the classifier.
Default
'openai'
confidenceThreshold?
optionalconfidenceThreshold:number
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:442
Minimum confidence threshold for accepting a classification result. If confidence falls below this, the router may escalate to a higher tier.
Default
0.7
conversationWindowSize?
optionalconversationWindowSize:number
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:487
Number of recent conversation messages to include as context for classification and generation.
Default
5
deepResearch()?
optionaldeepResearch: (query,sources) =>Promise<{sources:RetrievedChunk[];synthesis:string; }>
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:552
Optional host-provided deep research callback.
Provide this to replace the built-in placeholder research branch with a
real multi-source research runtime. The sources argument receives
normalized research-source hints such as web, docs, or media,
not raw classifier retrieval labels.
Parameters
query
string
sources
string[]
Returns
Promise<{ sources: RetrievedChunk[]; synthesis: string; }>
deepResearchEnabled?
optionaldeepResearchEnabled:boolean
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:480
Whether to enable deep research mode for tier 3 queries. Research mode performs iterative multi-pass retrieval and synthesis.
Default
true
embeddingApiKey?
optionalembeddingApiKey:string
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:593
Optional API key override for embeddings only.
When omitted, embeddings fall back to apiKey, then OPENAI_API_KEY,
then OPENROUTER_API_KEY.
This is useful when generation uses an OpenAI-compatible endpoint like
OpenRouter but embeddings should stay on a direct OpenAI key.
embeddingBaseUrl?
optionalembeddingBaseUrl:string
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:604
Optional base URL override for embeddings only.
When omitted, embeddings inherit baseUrl unless embeddingApiKey is
explicitly set, in which case the embedding path assumes the provider's
default endpoint. If neither override is set and QueryRouter falls back to
OPENROUTER_API_KEY, it automatically uses the OpenRouter compatibility
URL for embeddings as well.
embeddingModel?
optionalembeddingModel:string
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:457
Embedding model identifier.
Default
'text-embedding-3-small'
embeddingProvider?
optionalembeddingProvider:string
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:454
Embedding provider name.
Default
'openai'
generationModel?
optionalgenerationModel:string
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:460
LLM model for T0/T1 generation.
Default
'gpt-4o-mini'
generationModelDeep?
optionalgenerationModelDeep:string
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:463
LLM model for T2/T3 generation (deep).
Default
'gpt-4o'
generationProvider?
optionalgenerationProvider:string
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:466
LLM provider for generation.
Default
'openai'
githubRepos?
optionalgithubRepos:RepoIndexConfig
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:612
Configuration for background GitHub repository indexing.
When provided, the router will asynchronously index GitHub repos after
init() completes and merge the resulting chunks into the corpus.
graphEnabled?
optionalgraphEnabled:boolean
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:473
Whether to enable GraphRAG-based retrieval for tier >= 2 queries. Requires a configured GraphRAG engine.
Default
true
graphExpand()?
optionalgraphExpand: (seedChunks) =>Promise<RetrievedChunk[]>
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:519
Optional host-provided graph expansion callback.
Provide this to replace the built-in placeholder graphExpand() branch
with a real GraphRAG or relationship-expansion implementation.
Parameters
seedChunks
Returns
Promise<RetrievedChunk[]>
includePlatformKnowledge?
optionalincludePlatformKnowledge:boolean
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:633
Load bundled platform knowledge (tools, skills, FAQ, API reference,
troubleshooting) into the corpus during init().
When enabled, the router ships with instant knowledge about every AgentOS capability — no external docs required for platform questions.
Default
true
knowledgeCorpus
knowledgeCorpus:
string[]
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:435
Directories containing .md / .mdx files to ingest as the knowledge
corpus.
init() will throw if these paths resolve to zero readable markdown
sections, because a successful router init should imply a non-empty corpus.
maxContextTokens?
optionalmaxContextTokens:number
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:493
Maximum estimated tokens to allocate for documentation context.
Default
4000
maxTier?
optionalmaxTier:QueryTier
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:451
Maximum tier the classifier may assign.
Default
3
onClassification()?
optionalonClassification: (result) =>void
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:561
Hook called after classification completes. Receives the ClassificationResult for consumer integration.
Parameters
result
Returns
void
onRetrieval()?
optionalonRetrieval: (result) =>void
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:567
Hook called after retrieval completes. Receives the RetrievalResult for consumer integration.
Parameters
result
Returns
void
rerank()?
optionalrerank: (query,chunks,topN) =>Promise<RetrievedChunk[]>
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:527
Optional host-provided reranker callback.
Provide this to replace the built-in lexical heuristic reranker with a provider-backed or cross-encoder reranker.
Parameters
query
string
chunks
topN
number
Returns
Promise<RetrievedChunk[]>
strategyConfig?
optionalstrategyConfig:QueryRouterStrategyConfig
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:622
Retrieval strategy configuration for the HyDE-aware query router.
Controls how the classifier selects between none, simple, moderate
(HyDE), and complex (HyDE + decompose) retrieval strategies.
See
QueryRouterStrategyConfig
verifyCitations?
optionalverifyCitations:boolean
Defined in: packages/agentos/src/orchestration/pipeline/query/types.ts:542
Enable post-generation citation verification when the router has an active embedding path and retrieved source chunks.
When enabled, route() runs CitationVerifier over the generated answer
and retrieved sources, then attaches the result to QueryResult.grounding.
If embeddings are unavailable or no sources were retrieved, verification is
skipped gracefully.