Adaptive Learning Triggers - Learning When to Learn
Intelligent triggers based on patterns, not arbitrary time intervals
π― Adaptive Learning Triggers
The Problem with Time-Based Triggers
β "Run pattern extraction every week"
Problems:
ββ Week with 500 decisions: Extraction too late, patterns missed
ββ Week with 5 decisions: Wasted compute, nothing to learn
ββ Urgent pattern (same error 10x): Waits until Sunday
ββ Arbitrary: Why 7 days? Why not 3? Why not 14?
The Solution: Event-Driven Learning
β
"Learn when there's something to learn"
Triggers:
ββ Volume: 100 new decisions since last extraction
ββ Repetition: Same question asked 3+ times
ββ Performance: Success rate drops below threshold
ββ Confidence: Average confidence declining
ββ Novelty: New category/domain detected
Trigger System Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LEARNING TRIGGER SYSTEM β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β VOLUME β β REPETITION β β PERFORMANCE β β
β β Counter β β Detector β β Monitor β β
β β β β β β β β
β β 100 new β β Same Q 3x β β <80% rate β β
β β decisions β β in 24hrs β β for type β β
β ββββββββ¬βββββββ ββββββββ¬βββββββ ββββββββ¬βββββββ β
β β β β β
β ββββββββββββββββββββΌβββββββββββββββββββ β
β β β
β βΌ β
β βββββββββββββββββββ β
β β TRIGGER QUEUE β β
β β β β
β β Priority-based β β
β β De-duplicated β β
β ββββββββββ¬βββββββββ β
β β β
β βΌ β
β βββββββββββββββββββ β
β β LEARNING JOB β β
β β EXECUTOR β β
β β β β
β β Pattern extractβ β
β β Rule promotion β β
β β Archive check β β
β βββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Trigger Types
1. Volume Trigger
interface VolumeTrigger {
type: 'volume';
threshold: number; // Default: 100 decisions
scope: 'global' | 'category' | 'agent';
currentCount: number;
lastTriggered: Date;
}
// Example: Different thresholds per category
const volumeThresholds = {
'build': 50, // Build issues: learn faster
'angular': 100, // Angular: standard
'architecture': 20, // Architecture: rare but important
'default': 100
};
2. Repetition Trigger
interface RepetitionTrigger {
type: 'repetition';
question: string;
occurrences: number;
threshold: number; // Default: 3
timeWindow: number; // Default: 24 hours
firstSeen: Date;
lastSeen: Date;
}
// When triggered: Extract pattern IMMEDIATELY
// "If the same question is asked 3+ times, we should have a pattern for it"
3. Performance Trigger
interface PerformanceTrigger {
type: 'performance';
metric: 'success_rate' | 'confidence' | 'reference_rate';
category: string;
currentValue: number;
threshold: number;
trend: 'declining' | 'stable' | 'improving';
}
// Example thresholds
const performanceThresholds = {
success_rate: 0.80, // Below 80% success: re-analyze
confidence: 0.75, // Below 75% avg confidence: need patterns
reference_rate: 0.30, // Below 30% patterns used: wrong patterns?
};
4. Novelty Trigger
interface NoveltyTrigger {
type: 'novelty';
detected: 'new_category' | 'new_technology' | 'new_pattern';
identifier: string;
occurrences: number;
firstSeen: Date;
}
// When new category detected (e.g., "AI integration" decisions appearing):
// - Lower threshold for learning (learn fast from new domain)
// - Higher urgency for pattern extraction
5. Confidence Drop Trigger
interface ConfidenceDropTrigger {
type: 'confidence_drop';
category: string;
previousAvg: number;
currentAvg: number;
dropPercentage: number;
threshold: number; // Default: 15% drop
}
// If confidence drops 15%+ in a category:
// - Something changed (new patterns, deprecated patterns)
// - Trigger re-analysis
Meta-Learning: Learning When to Learn
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β META-LEARNING SYSTEM β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β After 1,000 decisions, analyze: β
β ββ Which triggers produced useful patterns? β
β ββ Which thresholds are too high/low? β
β ββ Which categories need faster learning? β
β ββ What's the optimal batch size for extraction? β
β β
β Learn trigger effectiveness: β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Trigger β Patterns β Useful β Effectiveness β β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β β Volume(100) β 45 β 32 β 71% β β β
β β Repetition β 12 β 11 β 92% β β β β
β β Performance β 8 β 6 β 75% β β β
β β Novelty β 5 β 4 β 80% β β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β Insight: Repetition trigger most effective β
β Action: Lower repetition threshold from 3 to 2 β
β β
β After 5,000 decisions: β
β ββ Build patterns: Stable, slow down extraction β
β ββ Angular patterns: Growing, maintain rate β
β ββ AI integration: New, accelerate extraction β
β ββ Auto-adjust thresholds per category β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Trigger Priority & De-duplication
interface TriggerPriority {
// Highest priority: Immediate action needed
CRITICAL: ['performance_drop', 'repeated_failure'];
// High priority: Should process soon
HIGH: ['repetition', 'confidence_drop'];
// Normal priority: Process in batch
NORMAL: ['volume', 'novelty'];
// Low priority: Background processing
LOW: ['cleanup', 'archive_check'];
}
// De-duplication: Don't run same extraction twice
interface TriggerDeduplication {
// If volume trigger fires for 'build' category:
// - Check if repetition already triggered for build
// - If yes, combine into single extraction job
// - Track which triggers contributed
}
Learning Job Types
1. Pattern Extraction
Triggered by: Volume, Repetition, Performance
Input: Batch of decisions matching criteria
Output: Extracted patterns, rule candidates
2. Rule Promotion
Triggered by: Pattern reaching threshold
Input: Pattern with 10+ successful uses
Output: Promoted to core rule
3. Anti-Pattern Detection
Triggered by: Repeated failures
Input: Failed decisions
Output: Anti-patterns (what NOT to do)
4. Archive Eligibility Check
Triggered by: Volume (after extraction)
Input: Decisions with extracted patterns
Output: Decisions ready for archive
Implementation
// Trigger Service
@Injectable()
export class AdaptiveTriggerService {
private triggers = new Map<string, TriggerState>();
private triggerQueue: PriorityQueue<Trigger>;
// Called on every new decision
async onNewDecision(decision: Decision): Promise<void> {
// Check all trigger conditions
await this.checkVolumeTrigger(decision);
await this.checkRepetitionTrigger(decision);
await this.checkPerformanceTrigger(decision);
await this.checkNoveltyTrigger(decision);
// Process any fired triggers
await this.processTriggerQueue();
}
// Called on outcome report
async onOutcomeReported(decisionId: string, success: boolean): Promise<void> {
await this.updatePerformanceMetrics(decisionId, success);
await this.checkConfidenceDropTrigger();
}
// Process triggers by priority
private async processTriggerQueue(): Promise<void> {
while (!this.triggerQueue.isEmpty()) {
const trigger = this.triggerQueue.pop();
// De-duplicate with pending jobs
if (this.isDuplicate(trigger)) continue;
// Execute appropriate learning job
await this.executeLearningJob(trigger);
}
}
}
Comparison: Time-Based vs Adaptive
| Aspect | Time-Based | Adaptive |
|---|---|---|
| Trigger | Every 7 days | When needed |
| Responsiveness | Days late | Minutes |
| Compute waste | High (slow weeks) | Minimal |
| Pattern quality | Averaged | Targeted |
| Learning speed | Fixed | Accelerates with activity |
| Optimization | Manual tuning | Self-optimizing |
Benefits
- Responsive: Learn immediately when patterns emerge
- Efficient: No wasted compute on quiet periods
- Adaptive: Thresholds optimize over time
- Targeted: Different triggers for different situations
- Self-improving: Meta-learning adjusts the system itself
Next Steps
- Implement trigger tracking in decision logging
- Build trigger evaluation service
- Create learning job queue
- Add meta-learning analysis job
- Build dashboard for trigger visibility