Interface RetrievalPlan

Structured retrieval plan produced by the query classifier.

Replaces the simple 'none'|'simple'|'moderate'|'complex' strategy string with a granular specification of what retrieval sources to use, how to combine them, and what memory types to consult.

The plan is data — it describes WHAT to do, not HOW. The UnifiedRetriever interprets the plan and executes it.

Example

const plan: RetrievalPlan = {
strategy: 'moderate',
sources: { vector: true, bm25: true, graph: true, raptor: true, memory: true, multimodal: false },
hyde: { enabled: true, hypothesisCount: 1 },
memoryTypes: ['episodic', 'semantic'],
modalities: ['text'],
temporal: { preferRecent: false, recencyBoost: 1.0, maxAgeMs: null },
graphConfig: { maxDepth: 2, minEdgeWeight: 0.3 },
raptorLayers: [0, 1],
deepResearch: false,
confidence: 0.85,
reasoning: 'Moderate complexity question about auth architecture.',
};

See

buildDefaultPlan for creating sensible defaults per strategy level

interface RetrievalPlan {
    strategy: RetrievalStrategy;
    sources: RetrievalPlanSources;
    hyde: {
        enabled: boolean;
        hypothesisCount: number;
    };
    memoryTypes: MemoryTypeFilter[];
    modalities: ModalityFilter[];
    temporal: TemporalConfig;
    graphConfig: GraphTraversalConfig;
    raptorLayers: number[];
    deepResearch: boolean;
    confidence: number;
    reasoning: string;
}

Properties

strategy: RetrievalStrategy

Base retrieval strategy (determines overall pipeline depth).

Maps to the existing strategy tier system but carries richer config.

  • 'none': Skip retrieval entirely.
  • 'simple': Vector + BM25 only. Fast path.
  • 'moderate': All sources, HyDE enabled, single pass.
  • 'complex': All sources, HyDE with multi-hypothesis, deep research, decomposition.

Which retrieval sources to query.

Each flag independently enables or disables a retrieval source. The UnifiedRetriever skips sources whose dependencies are not available at runtime regardless of these flags.

hyde: {
    enabled: boolean;
    hypothesisCount: number;
}

HyDE (Hypothetical Document Embedding) configuration.

When enabled, a hypothetical answer is generated via LLM before embedding, bridging vocabulary gaps between questions and documents.

Type declaration

  • enabled: boolean

    Whether to use HyDE for this retrieval.

  • hypothesisCount: number

    Number of diverse hypotheses to generate. More hypotheses improve recall at the cost of additional LLM calls.

    Default

    1 for moderate, 3 for complex
    

See

HydeRetriever

memoryTypes: MemoryTypeFilter[]

Which cognitive memory types to consult.

  • 'episodic': Past interactions, events, conversations.
  • 'semantic': Facts, knowledge, learned concepts.
  • 'procedural': Workflows, how-to knowledge, skills.
  • 'prospective': Upcoming intentions, reminders, planned actions.
modalities: ModalityFilter[]

Which content modalities to search in multimodal index.

Text search is always performed via vector/BM25 sources; non-text modalities are handled by the multimodal indexer.

temporal: TemporalConfig

Temporal preferences for result ordering and filtering.

Controls whether recent results are boosted and how aggressively older content is penalized.

Graph traversal configuration for GraphRAG source.

Controls the depth and selectivity of entity relationship traversal starting from seed chunks discovered by vector/BM25 search.

raptorLayers: number[]

Which RAPTOR tree layers to search.

  • 0: Leaf chunks (original documents) — detail queries.
  • 1: First-level cluster summaries — theme queries.
  • 2+: Higher-level summaries — "big picture" queries.

An empty array searches all layers (default RAPTOR behaviour).

deepResearch: boolean

Whether deep research mode is enabled.

Deep research decomposes the query into sub-queries and recurses with moderate-level plans per sub-query. Only used with complex strategy.

confidence: number

Confidence score from the classifier (0 to 1).

Indicates how certain the classifier is about this plan. Low confidence may trigger plan escalation in the router.

reasoning: string

Human-readable reasoning from the classifier explaining why this plan was selected.