Aleph
Architecture

Dispatcher

Tool registry, risk evaluation, and semantic tool retrieval (hydration).

Dispatcher

The Dispatcher manages tool registration, discovery, and risk evaluation. It aggregates tools from multiple sources, assesses their risk levels, and provides semantic retrieval so the Thinker can discover relevant tools beyond the static tool list.

Location: src/dispatcher/


Architecture

┌──────────────────────────────────────────────────────┐
│                    Dispatcher                        │
├──────────────────────────────────────────────────────┤
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐│
│  │ ToolRegistry │  │ RiskEvaluator│  │ ToolIndex    ││
│  │• Native      │  │• RiskLevel   │  │• Semantic    ││
│  │• MCP         │  │• Assessment  │  │  retrieval   ││
│  │• Skills      │  │              │  │• Hydration   ││
│  │• Custom      │  │              │  │              ││
│  └──────────────┘  └──────────────┘  └──────────────┘│
└──────────────────────────────────────────────────────┘

Tool Registry

ToolRegistry aggregates all available tools from multiple sources:

SourceTypeExample
NativeBuilt-in Rust toolsmemory_search, note_manage
MCPExternal MCP serversGitHub, filesystem
SkillsDynamically registered skillsCustom skill tools
CustomUser-defined toolsConfigured extensions

Risk Evaluation

RiskEvaluator assigns a RiskLevel to each tool:

pub enum RiskLevel {
    Safe,       // Read-only, no side effects
    Low,        // Minor side effects (e.g., file reads)
    Medium,     // Moderate risk (e.g., file writes)
    High,       // Significant risk (e.g., code execution)
    Critical,   // Destructive operations
}

Tool Index (Semantic Retrieval)

The ToolIndex enables semantic tool discovery. Instead of relying solely on tool names and descriptions, the system can retrieve tools based on the semantic meaning of the user's query.

pub struct HydrationResult {
    pub tools: Vec<HydratedTool>,
    pub level: HydrationLevel,
}

pub enum HydrationLevel {
    None,       // No hydration performed
    Partial,    // Some tools hydrated
    Full,       // All relevant tools hydrated
}

The HydrationPipeline coordinates semantic retrieval:

  1. Purpose Inference — Infer the user's intent from the query
  2. Tool Retrieval — Retrieve candidate tools via semantic similarity
  3. Tool Meta Enrichment — Augment tool definitions with contextual metadata

Key Types

TypePurposeLocation
ToolRegistryAggregates all tool sourcessrc/dispatcher/registry/
RiskEvaluatorAssesses tool risk levelssrc/dispatcher/risk.rs
ToolIndexSemantic tool indexsrc/dispatcher/tool_index/
HydrationResultResult of semantic retrievalsrc/dispatcher/tool_index/
ToolDefinitionUnified tool metadatasrc/dispatcher/types.rs
ToolSourceOrigin of a toolsrc/dispatcher/types.rs

See Also

On this page