#Why does heartbeat need the whole session context?
1 messages · Page 1 of 1 (latest)
Short version: because heartbeat needs state, not because it should keep reviving old chats.
By default, heartbeat runs in the agent’s main session, so it can:
- see ongoing session state,
- notice completed background/system events,
- avoid duplicate nudges,
- and know where
target: "last"should deliver.
But that line, “Do not infer or repeat old tasks from prior chats”, is a behavior rule, not a hard memory wipe. In other words, “you can see context, but don’t resurrect stale stuff just because it’s in the transcript.”
A couple important details:
- OpenClaw already filters out no-op heartbeat prompt/
HEARTBEAT_OKpairs from history, so heartbeat noise is not supposed to pile up. - If you want a much more stateless/cheap heartbeat, use:
heartbeat.isolatedSession: true= fresh session, no prior conversation historyheartbeat.lightContext: true= tiny bootstrap, basically justHEARTBEAT.md
So the real split is:
- default heartbeat: context-aware
- isolated + lightContext heartbeat: almost stateless
Docs:
If you want, I can also point at the exact code path where heartbeat history gets filtered.
I don't agree. I don't use the main session at all but use a direct chat, the main session is just filled with HEARTBEAT_OK. It just takes so much time to process the useless context in the LLM. The heartbeat contains just a few standalone tasks
Yeah, that’s a fair complaint. For standalone heartbeat tasks, I agree the shared-session default is kind of wasteful.
What’s happening today is:
- heartbeat turns still get stored in the transcript,
HEARTBEAT_OKpairs are filtered when building model context,- but the prompt line “do not infer or repeat old tasks” is still only a behavior hint, not a hard isolation boundary.
So if your heartbeat is just “run these few tasks”, the real fix is not the prompt text, it’s:
{
agents: {
defaults: {
heartbeat: {
every: "30m",
isolatedSession: true,
lightContext: true,
target: "last"
}
}
}
}
And if the destination is fixed, even better, use explicit target + to instead of last.
So bluntly: you’re right. That sentence does not solve token waste.
isolatedSession: true is the knob that actually stops heartbeat from dragging chat history along.
Docs: