Skip to content

[Bug]: heartbeat isolatedSession rotates sessionId but reuses old transcript file #65564

@akessel56

Description

@akessel56

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

V2026.4.11
heartbeats are growing each time they are run.
This is with a dedicated heartbeat agent
heartbeat.isolatedSession: true
heartbeat.lightContext: true
heartbeat.lightContext: true
Run heartbeat twice
Observe:
sessionId changes between runs
~/.openclaw/agents/heartbeat/sessions/.jsonl stays the same file and grows
first-turn Gemini input tokens increase across runs

Steps to reproduce

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.

Expected behavior

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.

Actual behavior

Evidence

Session store output after one run

openclaw sessions --agent heartbeat --json
```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

Another run a few minutes later:
openclaw sessions --agent heartbeat --json
```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",
    }
  ]
}
```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




### OpenClaw version

version 2026.4.11

### Operating system

Debian 12 (Bookworm)

### Install method

npm global

### Model

gemini-3.1-flash-lite

### Provider / routing chain

openclaw -> google/gemini-3.1-flash-lite-preview

### Additional provider/model setup details

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.



### Logs, screenshots, and evidence

```shell
## 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.

Impact and severity

Can't really use heartbeat, as the costs will keep rising.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingclawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions