Expand description
Memory routing — classify recall queries and dispatch to the right backend.
The MemoryRouter trait is implemented by:
| Type | Strategy |
|---|---|
HeuristicRouter | Fast regex/keyword pattern matching. No LLM call. |
LlmRouter | Uses an LLM classifier for high-accuracy routing. |
HybridRouter | Runs HeuristicRouter first; escalates to LlmRouter when confidence is low. |
AsyncMemoryRouter | Async wrapper over any MemoryRouter for use in async contexts. |
§Routing pipeline
HeuristicRouterclassifies the query in < 1 ms using temporal-keyword detection and graph-relationship pattern matching.- If confidence >= threshold, the route is used directly.
- Otherwise,
HybridRouterforwards the query toLlmRouterfor a second opinion.
Structs§
- Heuristic
Router - Heuristic-based memory router.
- Hybrid
Router - Hybrid router: heuristic-first, escalates to LLM when confidence is low.
- LlmRouter
- LLM-based memory router.
- Routing
Decision - Routing decision with confidence and optional LLM reasoning.
- Temporal
Range - Resolved datetime boundaries for a temporal query.
Enums§
- Memory
Route - Classification of which memory backend(s) to query.
Traits§
- Async
Memory Router - Async extension for LLM-capable routers.
- Memory
Router - 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 tofallbackon unknown values. - resolve_
temporal_ range - Resolve temporal keywords in
queryto a(after, before)datetime boundary pair. - strip_
temporal_ keywords - Strip matched temporal keywords from a query string before passing to FTS5.