The Adaptive Learning Layer is where Layerr gets smarter over time. It analyses execution traces, extracts patterns, and adjusts future routing decisions based on what actually worked.
Source What Is Learned Key File Execution Outcomes Which provider/model succeeded for which workload learning/adaptive/engine.tsUser Feedback Explicit thumbs-up/down on responses src/features/replay/learning/learningModel.tsProvider Learning Provider-specific performance trends src/features/replay/learning/learningModel.tsStrategy Learning Which strategies work best for which intents learning/adaptive/engine.tsFailure Patterns Common failure modes and their predictors runtime/protection/classifier.ts
[1] Extract Outcome --> Success? Quality? Cost? Latency?
[2] Correlate Features --> Which workload signals predicted the outcome?
[3] Update Weights --> Adjust routing and scoring weights
[4] Flag Drift --> Alert if provider quality degrades
[5] Build Summary --> Present learning insights to user
The confidence classifier (learning/adaptive/engine.ts) learns to predict routing confidence:
function classifyConfidence (
workload : WorkloadProfile ,
provider : ProviderMetadata ,
historicalTraces : Trace []
// Uses historical success rate, error patterns, and workload similarity
// Returns: high | medium | low | uncertain
The failure classifier (runtime/protection/classifier.ts) categorises failures and learns from them:
Failure Type Learning Action Rate limit Reduce request rate to this provider for similar workloads Timeout Increase timeout or switch to faster model Content policy Flag content type, suggest alternative provider Provider outage Automatically deprioritise provider for next N hours
Provider learning (src/features/replay/learning/learningModel.ts) tracks:
Metric Description providerLearningHistorical performance score per provider strategyLearningHistorical performance score per strategy Latency trends Is this provider getting slower? Error rate trends Is this provider becoming less reliable? Cost efficiency Quality per dollar, trending over time
Component File Purpose ProviderLearningViewsrc/features/replay/learning/Shows provider learning curves LearningReplayInsightssrc/features/replay/learning/Insights from replay analysis AdaptiveLearningControlssrc/features/intelligence/Toggle learning features on/off
File What It Does learning/adaptive/engine.tsMain adaptive learning engine. Updates weights, classifies confidence runtime/protection/classifier.tsFailure classification and pattern learning src/features/replay/learning/learningModel.tsFrontend data model for learning insights src/features/intelligence/hooks.tsReact hooks for intelligence and learning features
Replay Layer → provides trace history for pattern extraction
Provider Health → receives updated health scores from learning
Scoring Layer → receives updated provider quality scores
Strategy Engine → receives recalibration recommendations
Explainability → includes learning insights in explanations