#Yet more heartbeat issues

40 messages · Page 1 of 1 (latest)

exotic swallow
#

I set up a heartbeat to run with its own agent.
"agents": {
"defaults": {
"model": {
"primary": "zai/glm-5-turbo",
"fallbacks": [
"google/gemini-3-flash",
"google/gemini-3.1-flash-lite-preview",
"google/gemini-3.1-pro-preview"
]
},
"models": {
"google/gemini-3.1-flash-lite-preview": {
"alias": "31lite"
},
"google/gemini-3-flash": {
"alias": "flash"
},
"google/gemini-3.1-pro-preview": {
"alias": "pro"
},
"google/gemini-2.5-flash": {
"alias": "25flash"
},
"zai/glm-5-turbo": {
"alias": "turbo"
},
"zai/glm-5.1": {
"alias": "glm"
},
"custom-10-0-4-81-1234/gemma-4-e4b-it": {
"alias": "gemma4"
}
},
"workspace": "/home/akessel56/.openclaw/workspace",
"userTimezone": "America/Chicago",
"envelopeTimezone": "user",
"envelopeTimestamp": "on",
"compaction": {
"mode": "safeguard"
},
"timeoutSeconds": 600
},
"list":[
{ "id": "main", "default": true },
{
"id": "heartbeat",
"workspace": "~/.openclaw/workspace-heartbeat",
"heartbeat": {
"every": "30m",
"model": "google/gemini-3.1-flash-lite-preview",
"isolatedSession": true,
"lightContext": true,
"target": "discord",
"to": "channel:1482214704784080906"
}
}
]
},

But it seems even with isolatedSession:true - context seems to be continuing to increase with each run.

The session doesn't show in openclaw sessions --json, I'm relying on the logs at google ai studio

main coralBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

pearl coveBOT
cosmic islandBOT
#

A couple things are going on here.

  1. isolatedSession: true does not create a new visible session key each run. It creates a fresh transcript/sessionId each run under a stable synthetic key, typically:

agent:heartbeat:main:heartbeat

So the key stays stable on purpose, but the run should still be fresh.

  1. openclaw sessions --json only shows the default agent store by default. Since your heartbeat is on a separate agent, try:
openclaw --version
openclaw sessions --agent heartbeat --json
openclaw sessions --all-agents --json
openclaw system heartbeat last
#

Also, the custom workspace is separate from session storage. The heartbeat agent's sessions live under:

~/.openclaw/agents/heartbeat/sessions/

not under ~/.openclaw/workspace-heartbeat.

One more nuance, lightContext: true only trims bootstrap workspace context down to HEARTBEAT.md. It does not remove the normal system prompt, tools, etc. So a baseline prompt cost is expected. What should not happen is the transcript growing linearly from prior heartbeat turns.

So my read is:

  • Not seeing it in openclaw sessions --json is expected, wrong scope.
  • Seeing some non-trivial prompt size is expected.
  • Seeing per-run prompt size keep increasing from prior heartbeat turns is not what isolatedSession: true is meant to do.

If you paste:

exotic swallow
#

version: v2026.4.9
(ssc-3.12.5) akessel56@rpi5:~ $ openclaw sessions --agent heartbeat --json
{
"path": "/home/akessel56/.openclaw/agents/heartbeat/sessions/sessions.json",
"count": 1,
"activeMinutes": null,
"sessions": [
{
"key": "agent💓main:heartbeat",
"updatedAt": 1776024205230,
"ageMs": 476697,
"sessionId": "b42c8867-7aa1-4383-9b18-54d24951260a",
"systemSent": true,
"abortedLastRun": false,
"inputTokens": 32726,
"outputTokens": 133,
"totalTokens": 28298,
"totalTokensFresh": true,
"model": "gemini-3.1-flash-lite-preview",
"modelProvider": "google",
"contextTokens": 1048576,
"agentId": "heartbeat",
"kind": "direct"
}
]
}

These are the first turn for each run of the heartbeat from Ai Studio

Created

Apr 12, 2026, 1:03:39 PM
ID

et7bab-MK6WMjMcPmJ270Qg
Model

models/gemini-3.1-flash-lite-preview
Tokens

Input tokens: 12314
Output tokens: 36
Total tokens: 12350
Tools

Function calling
2)

#

Created

Apr 12, 2026, 1:33:17 PM
ID

bOXbacb0KM7ruge8y83IBA
Model

models/gemini-3.1-flash-lite-preview
Tokens

Input tokens: 13753
Output tokens: 35
Total tokens: 13788
Tools

Function calling

Apr 12, 2026, 2:03:12 PM
ID

cOzbaczAGOuTjMcP-LHSuQg
Model

models/gemini-3.1-flash-lite-preview
Tokens

Input tokens: 17190
Output tokens: 35
Total tokens: 17225
Tools

Function calling

cosmic islandBOT
#

That helps a lot.

A few concrete takeaways:

  • Your heartbeat agent is there, so the earlier sessions --json part was just agent scope.
  • The 12k first-turn input is believable, because heartbeat still sends the system prompt + tools even with lightContext: true.
  • But 12k → 32k on later first turns does sound suspicious. I would not expect that from isolatedSession: true.

The big thing, you are on v2026.4.9, and there was a relevant fix in v2026.4.10:

  • fix: prevent isolated heartbeat session key :heartbeat suffix accumulation

So before digging deeper, I’d honestly update to at least 2026.4.10, ideally 2026.4.11:
https://docs.openclaw.ai/install/updating

One important nuance: openclaw sessions --agent heartbeat --json shows the current store entry, not every past isolated transcript file. So count: 1 is not proof that only one transcript exists.

#

The best check is this:

openclaw sessions --agent heartbeat --json
ls -lt ~/.openclaw/agents/heartbeat/sessions/*.jsonl | head

Then let one more heartbeat fire, and run them again.

What I’d expect if isolation is working:

  • the sessionId in sessions --agent heartbeat --json changes
  • a new *.jsonl file appears for the new run

If the sessionId stays the same across heartbeat ticks, then isolation is not actually resetting the transcript.

So my recommendation is:

#
  1. Update first to latest stable.
  2. Re-check whether the heartbeat sessionId changes every run.
  3. If it still grows after update, paste:
    • two consecutive openclaw sessions --agent heartbeat --json outputs
    • ls -lt ~/.openclaw/agents/heartbeat/sessions/*.jsonl | head
    • the next two AI Studio input-token counts

Then we can tell pretty quickly whether it is real transcript carryover, or just provider/cache accounting.

Relevant docs:

#

Yeah, that trend looks wrong.

12314 -> 13753 -> 17190 on the first turn of each heartbeat run is more than normal prompt jitter. With isolatedSession: true plus lightContext: true, I would expect a fairly stable baseline, not a steady climb like that.

The important bit is your version:

  • you are on v2026.4.9
  • there was a relevant heartbeat-isolation fix in v2026.4.10

So I’d treat this as:

  1. first, update to latest stable (ideally 2026.4.11)
    https://docs.openclaw.ai/install/updating

  2. re-test the same heartbeat

  3. if it still climbs after updating, I’d call it a bug and file it here:

#

https://github.com/openclaw/openclaw/issues

Your report is already pretty solid. I’d include:

  • version: v2026.4.9
  • your heartbeat config
  • the three AI Studio first-turn inputs:
    • 12314
    • 13753
    • 17190

One sanity check after updating:

openclaw sessions --agent heartbeat --json
ls -lt ~/.openclaw/agents/heartbeat/sessions/*.jsonl | head
exotic swallow
#

okay so did a manual run and:
(ssc-3.12.5) akessel56@rpi5:~ $ openclaw sessions --agent heartbeat --json
{
"path": "/home/akessel56/.openclaw/agents/heartbeat/sessions/sessions.json",
"count": 1,
"activeMinutes": null,
"sessions": [
{
"key": "agent💓main:heartbeat",
"updatedAt": 1776028301794,
"ageMs": 86618,
"sessionId": "31ec7166-6c8c-4730-b136-e5a4110fc3a8",
"systemSent": true,
"abortedLastRun": false,
"inputTokens": 80178,
"outputTokens": 622,
"totalTokens": 35240,
"totalTokensFresh": true,
"model": "gemini-3.1-flash-lite-preview",
"modelProvider": "google",
"contextTokens": 1048576,
"agentId": "heartbeat",
"kind": "direct"
}
]
}

And

(ssc-3.12.5) akessel56@rpi5:~ $ ls -lt ~/.openclaw/agents/heartbeat/sessions/*.jsonl | head
-rw-r--r-- 1 akessel56 akessel56 177126 Apr 12 16:11 /home/akessel56/.openclaw/agents/heartbeat/sessions/db376b0d-ebe3-42d5-9def-0a089dc4a0a9.jsonl

Then I ran again a few minutes later and:

(ssc-3.12.5) akessel56@rpi5:~ $ openclaw sessions --agent heartbeat --json
{
"path": "/home/akessel56/.openclaw/agents/heartbeat/sessions/sessions.json",
"count": 1,
"activeMinutes": null,
"sessions": [
{
"key": "agent💓main:heartbeat",
"updatedAt": 1776028517330,
"ageMs": 46353,
"sessionId": "6e1f19ae-991f-4053-b8a2-a7c8a0864a9a",
"systemSent": true,
"abortedLastRun": false,
"inputTokens": 35390,
"outputTokens": 12,
"totalTokens": 35390,
"totalTokensFresh": true,
"model": "gemini-3.1-flash-lite-preview",
"modelProvider": "google",
"contextTokens": 1048576,
"agentId": "heartbeat",
"kind": "direct"
}
]
}

And

(ssc-3.12.5) akessel56@rpi5:~ $ ls -lt ~/.openclaw/agents/heartbeat/sessions/*.jsonl | head
-rw-r--r-- 1 akessel56 akessel56 178358 Apr 12 16:15 /home/akessel56/.openclaw/agents/heartbeat/sessions/db376b0d-ebe3-42d5-9def-0a089dc4a0a9.jsonl

cosmic islandBOT
#

Okay, that’s the smoking gun.

isolatedSession is only half-working in your repro:

  • the sessionId does change
    (31ec... -> 6e1f...)
  • but the transcript file does not change
    it stays on db376b0d-...jsonl
  • and that file keeps growing

So the heartbeat is getting a fresh session ID, but it is still appending to the old transcript file. That would absolutely explain the context growth.

I’d describe this as:

isolatedSession: true rotates sessionId but reuses the previous sessionFile, so transcript history keeps accumulating.

That is a real bug report, not expected behavior.

#
  • Dedicated heartbeat agent
  • heartbeat.isolatedSession: true
  • heartbeat.lightContext: true
  • Run heartbeat twice
  • Observe:
    • sessionId changes between runs
    • ~/.openclaw/agents/heartbeat/sessions/<old-id>.jsonl stays the same file and grows
    • first-turn Gemini input tokens increase across runs

Honestly, this is a really solid repro. Nice catch.

If you want, I can help you turn your thread into a tight GitHub issue body so it’s easy for maintainers to act on.

exotic swallow
#

This is the latest build, I already updated to 2026.4.11

#

Yes please help me turn the issue into a solid bug report

cosmic islandBOT
#

Yep, I’d paste something close to this.

Title

heartbeat isolatedSession rotates sessionId but keeps appending to old transcript file

Body

## Summary

When using a dedicated heartbeat agent with `heartbeat.isolatedSession: true`, the heartbeat appears to get a fresh `sessionId` on each run, but it keeps appending to the same old transcript file. As a result, context keeps growing across heartbeat runs.

This seems to defeat the expected isolation behavior.

## Version
#

- OpenClaw: `v2026.4.9`

(If I repro this after updating, I will edit this section with the latest version.)

## Relevant config

```json5
{
  "agents": {
    "defaults": {
      "timeoutSeconds": 600
    },
    "list": [
      { "id": "main", "default": true },
      {
#

"id": "heartbeat",
"workspace": "~/.openclaw/workspace-heartbeat",
"heartbeat": {
"every": "30m",
"model": "google/gemini-3.1-flash-lite-preview",
"isolatedSession": true,
"lightContext": true,
"target": "discord",
"to": "channel:1482214704784080906"
}
}
]
}
}

#
## Expected behavior

With `heartbeat.isolatedSession: true`, each heartbeat run should use a fresh transcript, so prior heartbeat turns should not accumulate in context.

I would expect either:

- a new transcript file per run, or
- at minimum, no reuse of the previous run's transcript history

## Actual behavior

The heartbeat `sessionId` changes between runs, but the transcript file does not. The same old `*.jsonl` file keeps growing.

This strongly suggests the heartbeat is rotating the session ID while still reusing the previous transcript file.
#
## Steps to reproduce

1. Configure a dedicated heartbeat agent with:
   - `isolatedSession: true`
   - `lightContext: true`
2. Trigger a heartbeat run.
3. Check:
   - `openclaw sessions --agent heartbeat --json`
   - `ls -lt ~/.openclaw/agents/heartbeat/sessions/*.jsonl | head`
4. Trigger another heartbeat run.
5. Check the same two commands again.

## Evidence

### Session store output after one run
#

```bash
openclaw sessions --agent heartbeat --json
{
  "path": "/home/akessel56/.openclaw/agents/heartbeat/sessions/sessions.json",
  "count": 1,
  "activeMinutes": null,
  "sessions": [
    {
      "key": "agent💓main:heartbeat",
      "updatedAt": 1776028301794,
      "ageMs": 86618,
      "sessionId": "31ec7166-6c8c-4730-b136-e5a4110fc3a8",
#

"systemSent": true,
"abortedLastRun": false,
"inputTokens": 80178,
"outputTokens": 622,
"totalTokens": 35240,
"totalTokensFresh": true,
"model": "gemini-3.1-flash-lite-preview",
"modelProvider": "google",
"contextTokens": 1048576,
"agentId": "heartbeat",
"kind": "direct"
}
]
}


```bash
#

ls -lt ~/.openclaw/agents/heartbeat/sessions/*.jsonl | head


```bash
-rw-r--r-- 1 akessel56 akessel56 177126 Apr 12 16:11 /home/akessel56/.openclaw/agents/heartbeat/sessions/db376b0d-ebe3-42d5-9def-0a089dc4a0a9.jsonl

After another run a few minutes later

openclaw sessions --agent heartbeat --json
{
  "path": "/home/akessel56/.openclaw/agents/heartbeat/sessions/sessions.json",
  "count": 1,
#

"activeMinutes": null,
"sessions": [
{
"key": "agent💓main:heartbeat",
"updatedAt": 1776028517330,
"ageMs": 46353,
"sessionId": "6e1f19ae-991f-4053-b8a2-a7c8a0864a9a",
"systemSent": true,
"abortedLastRun": false,
"inputTokens": 35390,
"outputTokens": 12,
"totalTokens": 35390,
"totalTokensFresh": true,
"model": "gemini-3.1-flash-lite-preview",
"modelProvider": "google",
"contextTokens": 1048576,
"agentId": "heartbeat",

#

"kind": "direct"
}
]
}


```bash
ls -lt ~/.openclaw/agents/heartbeat/sessions/*.jsonl | head
-rw-r--r-- 1 akessel56 akessel56 178358 Apr 12 16:15 /home/akessel56/.openclaw/agents/heartbeat/sessions/db376b0d-ebe3-42d5-9def-0a089dc4a0a9.jsonl

Why this looks wrong

#
The `sessionId` changed:

- `31ec7166-6c8c-4730-b136-e5a4110fc3a8`
- `6e1f19ae-991f-4053-b8a2-a7c8a0864a9a`

But the transcript file stayed the same:

- `db376b0d-ebe3-42d5-9def-0a089dc4a0a9.jsonl`

and increased in size:

- `177126`
- `178358`

So the new isolated session seems to be reusing the previous transcript file.
#

## Additional signal from Gemini / AI Studio

Looking at the first turn of each heartbeat run in AI Studio, input tokens also increase over time:

- `12314`
- `13753`
- `17190`

That matches the idea that context is still accumulating across runs.

## Notes

I originally also noticed that the heartbeat session did not show up in plain `openclaw sessions --json`, but that part was just because it is on a separate agent. `openclaw sessions --agent heartbeat --json` does show it.
#

If you want, I can also make a shorter maintainer-friendly version that trims the duplicated outputs and gets straight to the repro.

exotic swallow
#

Is there a way for me to clear (/new equivalent) for a heartbeat agent session?

In the meantime I guess I should turn the heartbeat off.

cosmic islandBOT
#

Yeah, there isn’t a clean first-class /new equivalent for that synthetic heartbeat session, at least not one I can point to in docs.

For a dedicated heartbeat agent, the practical reset is:

  1. Pause heartbeats

    openclaw system heartbeat disable
    
  2. Stop the gateway

  3. Move the heartbeat agent’s sessions dir aside (safer than deleting)

    mv ~/.openclaw/agents/heartbeat/sessions ~/.openclaw/agents/heartbeat/sessions.bak.$(date +%s)
    
  4. Start the gateway again

#
  1. Re-enable heartbeats
    openclaw system heartbeat enable
    

That is basically the closest thing to a fresh /new for this agent.

A couple notes:

  • Since this is a separate heartbeat-only agent, resetting ~/.openclaw/agents/heartbeat/sessions/ is nicely scoped.
  • This is a workaround, not a fix. With the current bug, it may start accumulating again later.
  • If you just want it off for now, openclaw system heartbeat disable is the right quick move.
  • For a persistent disable, setting heartbeat every to "0m" also works.

Docs:

#

If this fixed it enough for now, please right-click the solution message → Apps → ✅ Mark Solution so Answer Overflow can index it.

exotic swallow
#

Well, I've always said if there is a bug, I will find it.

cosmic islandBOT
#

Hah, apparently you did 😅

Honestly, this is a very solid bug find.
sessionId changing while the same transcript file keeps growing is a great repro, very hard to argue with.

If you file the issue with the writeup above, I think it’ll be actionable fast.

Glad we pinned it down. 🎉
If this thread got you what you needed, please right-click the solution message → Apps → ✅ Mark Solution so Answer Overflow can index it for the next person.