Expert Pool System
The stella-agent includes a Parallel Expert Pool - a sophisticated system that routes potentially sensitive queries through specialized domain experts for analysis before generating responses.
What is the Expert Pool?β
The Expert Pool provides:
- Safety layer for sensitive topics (medical, legal, financial, ethical)
- Parallel expert execution for fast, comprehensive analysis
- Dynamic expert selection based on content and risk scoring
- Consensus synthesis that resolves conflicting expert findings
Multi-Stage Pipelineβ
When user input is classified as potentially sensitive, it flows through a multi-stage pipeline:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β EXPERT POOL PIPELINE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β User Input β
β β β
β βΌ β
β βββββββββββββββ β
β β InputGate β βββ Routes as SAFE or UNSAFE β
β β β βββ Selects relevant experts β
β βββββββββββββββ β
β β β
β βββ SAFE βββββββββββββββββββββββββΊ Direct LLM Response β
β β β
β βββ UNSAFE βββ β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββ β
β β EXPERT POOL β β
β β βββββββββββ βββββββββββ βββββββββββ β β
β β β Medical β β Ethics β β Legal β β β
β β βββββββββββ βββββββββββ βββββββββββ β β
β β βββββββββββ βββββββββββ β β
β β β Finance β βTimekeeperβ (parallel) β β
β β βββββββββββ βββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββ β
β β β
β βΌ β
β βββββββββββββββ β
β β Aggregator β βββ Synthesizes expert findings β
β βββββββββββββββ β
β β β
β βΌ β
β Natural Response β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Pipeline Stagesβ
Stage 1: InputGateβ
The InputGate is the entry point that analyzes and routes user input:
- Analyzes user input for content classification
- Routes as
SAFE(direct response) orUNSAFE(requires expert review) - Selects which experts should analyze the query
- Calculates risk scores for expert activation
Stage 2: ExpertPoolβ
The ExpertPool executes domain experts in parallel:
- Executes selected experts in parallel using
asyncio.gather() - Each expert provides independent analysis
- Experts run simultaneously for faster response times
- Handles failures gracefully (one expert failing doesn't block others)
Stage 3: Aggregatorβ
The Aggregator synthesizes expert findings into a coherent response:
- Collects all expert results
- Analyzes conflicts and consensus
- Synthesizes findings into a natural, conversational response
- Streams response tokens in real-time
Parallel Executionβ
Selected experts run concurrently for optimal performance:
# All selected experts run simultaneously
tasks = [expert.analyze(input) for expert in selected_experts]
results = await asyncio.gather(*tasks, return_exceptions=True)
Benefits:
- Faster response times (experts don't wait for each other)
- Independent analysis (no expert influences another)
- Graceful error handling (one failure doesn't block others)
Source Files Referenceβ
| Component | File Path |
|---|---|
| Expert Pool | agents/stella-agent/src/stella_agent/pipeline/expert_pool.py |
| Input Gate | agents/stella-agent/src/stella_agent/pipeline/input_gate.py |
| Aggregator | agents/stella-agent/src/stella_agent/pipeline/aggregator.py |
| Expert Result | agents/stella-agent/src/stella_agent/models/expert_result.py |
| Expert Configs | agents/stella-agent/src/stella_agent/experts/*.json |
Next Stepsβ
- Default Experts - Learn about the 5 built-in experts
- Configuration - Understand the configuration schema
- Custom Experts - Add your own domain experts