Opportunity Engine
The Opportunity Engine scans the agent's episodic memory every 2 hours, identifies recurring tasks that could be automated, and proactively suggests automation strategies via Telegram — without the user having to ask.
How It Works
EpisodicMemory (last 24h)
│
▼
_detect_opportunities()
├── keyword index scan over 5 opportunity types
├── count hits per type
└── threshold check (≥3 hits in 24h)
│
▼
_is_rate_limited() ← max 2 suggestions/day, 48h dedup per type
│
▼
Telegram notification: "💡 Automation opportunity detected..."
│
▼
User can reply to trigger goal creation
Opportunity Types
| Type | Description | Example Trigger Keywords |
|---|---|---|
crypto_monitoring | Repeated price checks | price, BTC, ETH, crypto, coin, token |
news_monitoring | Repeated topic news searches | news, latest, headlines, article |
website_monitoring | Repeated site visits | site, page, check, url, webpage |
daily_report | Daily summary requests | daily, report, summary, morning, tonight |
api_tracking | API or data endpoint polling | api, endpoint, status, uptime, ping |
Rate Limiting
The engine enforces strict limits to avoid notification fatigue:
| Limit | Value |
|---|---|
| Max suggestions per day | 2 |
| Dedup window per type | 48 hours |
| Minimum hits to trigger | 3 in 24 hours |
| Scan interval | 7200 seconds (every 2 hours) |
Redis Keys
opp:daily:{user_id}:{date} → daily suggestion count (TTL 86400s)
opp:suggested:{user_id}:{type}:{date} → dedup per type (TTL 172800s)
opp:queue:{user_id} → pending suggestions queue (TTL 86400s)
CPI Integration
When the Cognitive Pressure Index (CPI) is high (>80), the Opportunity Engine skips its scan to avoid adding load during peak execution periods.
Example Notification
💡 Automation opportunity detected
I've noticed you check the BTC price frequently.
I can set up automatic monitoring and notify you
of significant changes (>4%).
Want me to create a price alert? Just say:
"Yes, monitor BTC above 70k and below 60k"
Source
src/opportunity_engine.py — OpportunityEngine class
src/scheduler/opportunity.py — OpportunityEngineJob (registered as opportunity_engine, every 7200s)
Configuration
The engine runs automatically. No configuration required. To disable:
# In docker-compose.yml or environment
# Remove the opportunity_engine scheduler registration in src/main.py
To change scan interval:
# src/main.py
scheduler.register("opportunity_engine", 3600, # every 1 hour
OpportunityEngineJob(...))