⚠️ IMPORTANT: All features are experimental, under active development. Use at your own risk. Customization to your workflow required. © 2026 GLG, a.s. | ← Back to Index
4. Focus Engine — Smart Context Selection
The Focus Engine is UAML's key differentiator. Instead of dumping all memories into context, it intelligently selects the most relevant ones within a token budget.
4.1 How It Works
Your Query → Focus Engine → Ranked, filtered, budget-constrained context
↑
Configuration (presets or custom rules)
4.2 Input Filter (What Gets Stored)
6 sequential filter stages protect data quality:
| Stage | Filter | What It Does | Configurable? |
|---|---|---|---|
| 1 | Length filter | Rejects entries < N chars | min_entry_length (default: 10) |
| 2 | Token limit | Rejects entries > N tokens | max_entry_tokens (default: 2000) |
| 3 | PII detector | Detects emails, phones, IDs, credit cards | Per-type: allow/mask/reject |
| 4 | Category filter | Per-category policies | allow/deny/encrypt/require_consent |
| 5 | Rate limiter | Token-bucket rate limiting | rate_limit_per_min (default: 100) |
| 6 | Relevance gate | Rejects low-quality entries | min_relevance_score (default: 0.3) |
4.3 Output Filter (What Gets Recalled)
The Focus Engine scores and ranks memories using:
- Relevance to the query (semantic similarity)
- Freshness (exponential time decay)
- Confidence (source reliability)
- Token budget (never exceed the context window allocation)
4.4 Presets
Three built-in presets — choose based on your use case:
| Preset | Description | Best For |
|---|---|---|
| Conservative | Strict filtering, high relevance threshold | Production, customer-facing |
| Standard | Balanced filtering (default) | General use |
| Research | Loose filtering, more context | Exploration, analysis |
# Apply a preset
uaml.apply_preset("conservative")
# Or via REST
curl -X PUT http://localhost:8780/api/v1/focus-config \
-d '{"preset": "standard"}'
4.5 Custom Rules (Starter+)
Fine-tune individual parameters:
config = {
"min_relevance_score": 0.5, # 0.0–1.0 (higher = stricter)
"max_entry_tokens": 1500, # max tokens per entry
"freshness_decay": 0.95, # time decay factor
"min_confidence": 0.6, # minimum confidence threshold
"pii_policy": "mask", # allow | mask | reject
"categories": {
"personal": "encrypt",
"work": "allow",
"sensitive": "require_consent"
}
}
4.6 Rules Changelog (Pro+)
Every configuration change is logged:
GET /api/v1/rules-log?limit=20
Returns: who changed what, when, expected impact. After 7 days, automatic evaluation compares predicted vs. actual impact.