Skip to main content

Type Alias: QueryRouterEventUnion

QueryRouterEventUnion = ClassifyStartEvent | ClassifyCompleteEvent | ClassifyErrorEvent | RetrieveStartEvent | RetrieveVectorEvent | RetrieveGraphEvent | RetrieveRerankEvent | RetrieveCompleteEvent | RetrieveFallbackEvent | ResearchStartEvent | ResearchPhaseEvent | ResearchCompleteEvent | GenerateStartEvent | GenerateCompleteEvent | RouteCompleteEvent | GitHubIndexStartEvent | GitHubIndexCompleteEvent | GitHubIndexErrorEvent

Defined in: packages/agentos/src/query-router/types.ts:757

Discriminated union of all QueryRouter lifecycle events. The type field serves as the discriminant for exhaustive matching.

Example

function handleEvent(event: QueryRouterEventUnion) {
switch (event.type) {
case 'classify:start':
console.log(`Classifying: ${event.query}`);
break;
case 'retrieve:vector':
console.log(`Vector search returned ${event.chunkCount} chunks`);
break;
case 'route:complete':
console.log(`Done in ${event.durationMs}ms`);
break;
}
}