Creates a new QueryClassifier instance.
Classifier configuration with model, provider, and thresholds.
Attach a CapabilityDiscoveryEngine for Tier 0 capability summaries.
When attached, the plan-aware classifier (classifyWithPlan) injects
category-level summaries of all available skills, tools, and extensions
into the LLM prompt. This allows the LLM to recommend capability
activations alongside the retrieval plan, without loading full schemas.
A configured and initialized CapabilityDiscoveryEngine, or null to detach.
const engine = new CapabilityDiscoveryEngine(embeddingManager, vectorStore);
await engine.initialize({ tools, skills, extensions, channels });
classifier.setCapabilityDiscoveryEngine(engine);
Classifies a user query into a retrieval tier and strategy.
Steps:
generateText.strategy field (falls back to tier-inferred).maxTier.The user's query text to classify.
Optional conversationHistory: ConversationMessage[]Optional recent conversation messages for context.
Optional _options: QueryRouterRequestOptionsA ClassificationResult with tier, strategy, confidence, reasoning, and metadata.
Classifies a query and produces a full ExecutionPlan.
This is an enhanced alternative to classify that evaluates more dimensions (source selection, memory relevance, modality, temporal preferences, decomposability, capability recommendations) and outputs a structured plan that the UnifiedRetriever can execute directly, along with skill/tool/extension recommendations for the agent runtime.
When a CapabilityDiscoveryEngine is attached (via setCapabilityDiscoveryEngine), the LLM prompt includes Tier 0 summaries (~150 tokens) of all available capabilities, enabling the LLM to recommend specific skills, tools, and extensions.
Falls back to buildDefaultExecutionPlan with heuristic capability selection when classification fails or the LLM response is malformed.
The user's query text to classify.
Optional conversationHistory: ConversationMessage[]Optional recent conversation messages for context.
Optional options: QueryRouterRequestOptionsA tuple of [ClassificationResult, ExecutionPlan].
const [classification, plan] = await classifier.classifyWithPlan(
'Search the web for recent AI news and summarize findings',
);
// plan.skills → [{ skillId: 'web-search', ... }]
// plan.tools → []
const result = await unifiedRetriever.retrieve(query, plan);
Chain-of-thought LLM classifier that determines retrieval depth (T0-T3) and retrieval strategy (
none/simple/moderate/complex) for each incoming query.The strategy field controls whether HyDE (Hypothetical Document Embedding) is engaged during retrieval and at what depth.
Example