Skip to main content
Heartbeat runs an agent on a recurring schedule and delivers the results via callbacks. Standalone — does NOT modify the Agent class.
In TypeScript the schedule accepts the same keywords (hourly, daily, weekly) plus intervals with an optional "every " prefix (every 30m, 30m, every 6h). onError is "retry" | "skip" or a callback, and maxRetries defaults to 3. The user configures a schedule; the heartbeat runs the agent and delivers results via callback.

How It Works

Quick Start

1

Basic Heartbeat

2

With Callback

3

Background Thread


Schedule Expressions

Heartbeat uses the same schedule parser as Schedule Tools:

Configuration


Error Handling


Best Practices

Call hb.start(blocking=False) to run in a daemon thread alongside your web server or bot.
Without on_result, results are only logged. Connect it to Slack, email, or a database for production use.
For long-running heartbeats, enable loop_detection=True on the agent to prevent stuck states.

Schedule Tools

Agent-centric scheduling via tool calls

Background Tasks

BackgroundRunner and ScheduleLoop