Overview
The heartbeat service readsHEARTBEAT.md in your workspace every 30 minutes (configurable) and uses an LLM to decide whether there are active tasks. If tasks are found, the agent executes them and delivers results to your most recently active chat channel.
Key features:
- Periodic wake-up without manual triggers
- LLM-powered task detection using virtual tool calls
- Automatic result delivery to active channels
- Configurable interval and enable/disable control
Architecture
The heartbeat operates in two phases:Phase 1: Decision
ReadsHEARTBEAT.md and asks the LLM via a virtual tool call whether there are active tasks. This avoids unreliable text parsing and token-based detection.
From nanobot/heartbeat/service.py:85-106:
Phase 2: Execution
Only triggered when Phase 1 returnsrun. The on_execute callback runs the task through the full agent loop and returns the result to deliver.
From nanobot/heartbeat/service.py:140-163:
Usage
Configuration
The heartbeat service is configured when initializing theHeartbeatService class (nanobot/heartbeat/service.py:53-69):
| Parameter | Type | Description |
|---|---|---|
workspace | Path | Path to workspace containing HEARTBEAT.md |
provider | LLMProvider | LLM provider for decision making |
model | str | Model to use for heartbeat decisions |
on_execute | Callable | Callback to execute tasks (returns result string) |
on_notify | Callable | Callback to deliver results to channels |
interval_s | int | Wake-up interval in seconds (default: 1800) |
enabled | bool | Enable/disable the service |
Setting Up Tasks
Edit~/.nanobot/workspace/HEARTBEAT.md (created automatically by nanobot onboard):
HEARTBEAT.md for you.
Starting the Service
Fromnanobot/heartbeat/service.py:108-119:
Manual Trigger
You can manually trigger a heartbeat check without waiting for the interval:Use Cases
1. Morning Briefing
Create a daily morning briefing with news, weather, and calendar:2. Server Monitoring
Monitor server health and alert on issues:3. Inbox Management
Automate email triage and responses:4. Project Status Updates
Automatic project tracking:Tool Schema
The heartbeat decision uses a virtual tool call with this schema (nanobot/heartbeat/service.py:14-37):
Best Practices
- Keep tasks actionable: Write clear, specific tasks that the agent can execute independently
- Use checkboxes: The
- [ ]format helps the LLM identify incomplete tasks - Set realistic intervals: Default 30 minutes is good for most use cases; adjust based on task urgency
- Test manually first: Use
trigger_now()or interact directly before relying on automatic execution - Monitor logs: Check that tasks are being detected and executed as expected