Overview
The heartbeat system reads tasks from aHEARTBEAT.md file in your workspace and executes them at a configurable interval (default: every 30 minutes).
Key Features
- Automatic execution - Tasks run in the background without manual intervention
- Async subagents - Long-running tasks execute independently via
spawntool - Flexible scheduling - Configure check interval (minimum 5 minutes)
- Independent communication - Subagents can message users directly
- Non-blocking - Heartbeat continues to next task while subagents work
Configuration
Add heartbeat configuration to~/.picoclaw/config.json:
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Enable/disable heartbeat |
interval | integer | 30 | Check interval in minutes (minimum: 5) |
Environment Variables
You can override configuration with environment variables:Creating Tasks
Create aHEARTBEAT.md file in your workspace:
Simple Tasks
For quick tasks that complete immediately:Long-Running Tasks
For tasks that take time (web search, API calls, etc.), use thespawn tool:
The Spawn Tool
Thespawn tool creates a subagent - an independent agent instance that runs tasks asynchronously.
How Spawn Works
Spawn Tool Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
task | string | Yes | The task for subagent to complete |
label | string | No | Short label for display purposes |
agent_id | string | No | Target agent ID to delegate task to |
Subagent Characteristics
| Feature | Description |
|---|---|
| Independent context | Subagent has its own context, no access to parent session history |
| Non-blocking | Parent agent continues immediately after spawning |
| Direct communication | Subagent uses message tool to communicate with user |
| Full tool access | Subagent has access to all tools (web_search, filesystem, etc.) |
| Isolated execution | Subagent failures don’t affect parent agent |
Example HEARTBEAT.md
Here’s a comprehensive example:Security and Sandboxing
Heartbeat tasks inherit the same security restrictions as the main agent:| Setting | Behavior |
|---|---|
restrict_to_workspace: true | All tasks (including subagents) restricted to workspace |
restrict_to_workspace: false | All tasks can access full filesystem |
Security Consistency
| Execution Path | Security Boundary |
|---|---|
| Main Agent | restrict_to_workspace ✅ |
| Heartbeat tasks | Inherits same restriction ✅ |
| Subagent / Spawn | Inherits same restriction ✅ |
Best Practices
Task Design
✅ Do:- Keep task descriptions clear and specific
- Use spawn for web searches and API calls
- Group related tasks under sections
- Set reasonable intervals (15-60 minutes typical)
- Create tasks that modify critical system files
- Use heartbeat for real-time monitoring (use cron instead)
- Spawn too many subagents simultaneously
- Set intervals below 5 minutes (minimum enforced)
Performance Tips
- Limit spawned tasks: Each subagent uses resources
- Batch related operations: Combine similar checks
- Adjust interval: Longer intervals = lower resource usage
- Monitor logs: Check for task failures or timeouts
Troubleshooting
Tasks Not Running
- Check heartbeat is enabled:
- Verify HEARTBEAT.md exists:
- Check logs for errors:
Subagents Not Responding
- Check that tasks explicitly mention using spawn
- Verify subagent has necessary tools enabled
- Check for timeout issues in long-running tasks
- Review logs for subagent errors
Performance Issues
- Reduce number of spawned tasks
- Increase heartbeat interval
- Check subagent resource usage
- Disable heartbeat temporarily if needed
Workspace Location
Heartbeat reads from:Related Features
- Scheduled Tasks (Cron) - Schedule one-time and recurring reminders
- Memory System - Persistent memory for task results
- Skills - Extend capabilities with custom skills