π Cron Scheduling
cron.py turns Jarvis from reactive to proactive. Scheduled tasks in standard cron format with automatic error recovery.
π Scheduled Task Examples
- β’0 9 * * 1-5 β daily pending items report at 9 a.m. (weekdays)
- β’*/30 * * * * β check for important emails every 30min
- β’0 18 * * 5 β weekly summary every Friday at 6 p.m.
- β’0 0 * * 0 β back up memory.db every Sunday at midnight
- β’*/5 * * * * β heartbeat for critical services every 5min
π‘ Practical Tip
Avoid schedules that run too frequently with expensive models. A heartbeat every 5min with GPT-4o costs ~R$50/day. Use inexpensive models for periodic checks.
π Heartbeat β Active Monitoring
Heartbeat is Jarvisβs nervous system. Configurable periodic checks that proactively alert you when something is out of the ordinary.
π What the Heartbeat Monitors
- β’Critical service APIs: status code != 200 β alert
- β’Memory usage: memory.db > 100MB β compact
- β’Daily API cost: > threshold β alert and throttle
- β’Important files: did the hash change? β possible compromise
- β’Jarvis's own uptime: response timeout β auto-restart
π‘ Practical Tip
Set up heartbeats at multiple intervals: fast (5min) for critical services, slow (1h) for non-urgent checks. Balance cost vs. responsiveness.
π Webhooks with n8n and Zapier
Webhooks connect Jarvis to the existing automation ecosystem. n8n, Zapier, Make.com can trigger Jarvis actions via HTTP.
π Webhook Integration Flow
- β’n8n detects a new lead in the CRM β POST to /webhook/new-lead
- β’Jarvis receives an event, analyzes it with an LLM, and generates a personalized email
- β’Jarvis calls GmailTool to send an email to the lead
- β’Jarvis updates the CRM via API with the action result
- β’Audit log records the entire chain
π‘ Practical Tip
Always validate the webhookβs HMAC signature before processing. Unauthenticated webhooks are vulnerable to replay attacks and spam.
π€ Background Sub-Agents
Sub-agents enable true parallelism. The main Jarvis creates sub-agents for long-running tasks without blocking the main conversation.
π Sub-Agent Use Cases
- β’Large repository analysis: a sub-agent scans and indexes while the main agent talks
- β’Extensive web research: 3 sub-agents research in parallel, the main agent aggregates
- β’Report compilation: sub-agent collects data, primary agent formats and sends it
- β’Continuous monitoring: sub-agent monitors in a loop, main agent receives alerts
- β’Deploy pipeline: a sub-agent executes steps, the main agent reports progress
π‘ Practical Tip
Limit the number of simultaneous sub-agents (recommended: max 5). Each sub-agent consumes tokens and incurs costs. Use an agent pool for reuse.
π€ TinyClaw Multi-Agents
TinyClaw is the standard for INTELECTO agent teams. Specialized agents collaborate passing work among themselves with defined roles.
π Common Roles in TinyClaw
- β’@coder: generates code and tests based on the spec
- β’@reviewer: analyzes generated code for bugs and style
- β’@writer: documents the code and generates a changelog
- β’@deployer: runs deploy scripts with approval
- β’@orchestrator: coordinates work among the other agents
π‘ Practical Tip
Each TinyClaw agent has a specialized SOUL.md. @reviewer is deliberately critical; @coder focuses on functionality; @writer prioritizes clarity.
π System Observability
Without observability, optimization is guesswork. metrics.py collects latency, cost, errors, and real-time tool usage.
π Collected Metrics
- β’Latency per request: p50, p95, p99 in ms
- β’Tokens per request: input + output + cost in USD
- β’Tool calls: frequency and success rate per tool
- β’Error rate: by error type and provider
- β’Agent loop depth: distribution of rounds used per conversation
π‘ Practical Tip
Export metrics to a dashboard via the /metrics endpoint. Grafana + Prometheus, or just a simple endpoint that Jarvis reads when asked.
β Module 4.3 Summary
Next:
Track 5: Architectures