Skip to main content

Module router

Module router 

Source
Expand description

Memory routing — classify recall queries and dispatch to the right backend.

The MemoryRouter trait is implemented by:

TypeStrategy
HeuristicRouterFast regex/keyword pattern matching. No LLM call.
LlmRouterUses an LLM classifier for high-accuracy routing.
HybridRouterRuns HeuristicRouter first; escalates to LlmRouter when confidence is low.
AsyncMemoryRouterAsync wrapper over any MemoryRouter for use in async contexts.

§Routing pipeline

  1. HeuristicRouter classifies the query in < 1 ms using temporal-keyword detection and graph-relationship pattern matching.
  2. If confidence >= threshold, the route is used directly.
  3. Otherwise, HybridRouter forwards the query to LlmRouter for a second opinion.

Structs§

HeuristicRouter
Heuristic-based memory router.
HybridRouter
Hybrid router: heuristic-first, escalates to LLM when confidence is low.
LlmRouter
LLM-based memory router.
RoutingDecision
Routing decision with confidence and optional LLM reasoning.
TemporalRange
Resolved datetime boundaries for a temporal query.

Enums§

MemoryRoute
Classification of which memory backend(s) to query.

Traits§

AsyncMemoryRouter
Async extension for LLM-capable routers.
MemoryRouter
Decides which memory backend(s) to query for a given input.

Functions§

classify_graph_subgraph
Classify a query into the MAGMA edge types to use for subgraph-scoped BFS retrieval.
parse_route_str
Parse a route name string into a MemoryRoute, falling back to fallback on unknown values.
resolve_temporal_range
Resolve temporal keywords in query to a (after, before) datetime boundary pair.
strip_temporal_keywords
Strip matched temporal keywords from a query string before passing to FTS5.