Skip to main content

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

TypeDescriptionExample Trigger Keywords
crypto_monitoringRepeated price checksprice, BTC, ETH, crypto, coin, token
news_monitoringRepeated topic news searchesnews, latest, headlines, article
website_monitoringRepeated site visitssite, page, check, url, webpage
daily_reportDaily summary requestsdaily, report, summary, morning, tonight
api_trackingAPI or data endpoint pollingapi, endpoint, status, uptime, ping

Rate Limiting

The engine enforces strict limits to avoid notification fatigue:

LimitValue
Max suggestions per day2
Dedup window per type48 hours
Minimum hits to trigger3 in 24 hours
Scan interval7200 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.pyOpportunityEngine class src/scheduler/opportunity.pyOpportunityEngineJob (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(...))