openclaw - 💡(How to fix) Fix [Bug]: heartbeat session at agent:main:main pins model from creation time, ignores openclaw.json edits across runs (follow-up to #51677) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#74284Fetched 2026-04-30 06:26:08
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
2
Author
Timeline (top)
commented ×1cross-referenced ×1

The autonomous heartbeat session keyed agent:main:main continues to use the model that was current at the session's creation time, even after agents.defaults.model.primary is changed in openclaw.json and the gateway is restarted. #51677 closed the equivalent issue on the reply path; this report is a heartbeat-path follow-up.

Root Cause

It's possible v2026.4.22 fixes this incidentally; I haven't verified the heartbeat path on v2026.4.22 yet because I had already reset the session before rolling forward.

Fix Action

Workaround

Manually reset the session:

mv ~/.openclaw/agents/main/sessions/<id>.jsonl{,.reset.$(date -u +%s)}
python3 -c '
import json
p = "/home/ubuntu/.openclaw/agents/main/sessions/sessions.json"
d = json.load(open(p))
del d["agent:main:main"]
json.dump(d, open(p, "w"), indent=2)
'

Next heartbeat creates a fresh session and picks up the new primary correctly.

Code Example

[gateway] agent model: openai-codex/gpt-5.4
...
{"api":"google-generative-ai","provider":"google","model":"gemini-3.1-pro-preview","usage":{"input":2123,"cacheRead":371407,...}}

---

mv ~/.openclaw/agents/main/sessions/<id>.jsonl{,.reset.$(date -u +%s)}
python3 -c '
import json
p = "/home/ubuntu/.openclaw/agents/main/sessions/sessions.json"
d = json.load(open(p))
del d["agent:main:main"]
json.dump(d, open(p, "w"), indent=2)
'
RAW_BUFFERClick to expand / collapse

Summary

The autonomous heartbeat session keyed agent:main:main continues to use the model that was current at the session's creation time, even after agents.defaults.model.primary is changed in openclaw.json and the gateway is restarted. #51677 closed the equivalent issue on the reply path; this report is a heartbeat-path follow-up.

Reproduction

  1. Run gateway on v2026.4.15. Config: agents.defaults.model.primary = "google/gemini-3.1-flash-lite-preview", fallbacks include google/gemini-3.1-pro-preview. Heartbeat enabled (HEARTBEAT.md in workspace).
  2. Wait long enough for the autonomous heartbeat tick to create the agent:main:main session. The session jsonl opens with a model_change event pinning provider/model. The sessions.json entry caches modelProvider: "google", model: "gemini-3.1-flash-lite-preview".
  3. Edit openclaw.json: change agents.defaults.model.primary to openai-codex/gpt-5.4 and clear fallbacks.
  4. Restart gateway.
  5. Observe subsequent heartbeat ticks. They continue to use gemini-3.1-pro-preview (the fallback baked in at session creation) per the model_change event in the existing transcript.

Logs show:

[gateway] agent model: openai-codex/gpt-5.4
...
{"api":"google-generative-ai","provider":"google","model":"gemini-3.1-pro-preview","usage":{"input":2123,"cacheRead":371407,...}}

i.e. the gateway-level resolved model is openai-codex/gpt-5.4, but the heartbeat session continues to call gemini.

Workaround

Manually reset the session:

mv ~/.openclaw/agents/main/sessions/<id>.jsonl{,.reset.$(date -u +%s)}
python3 -c '
import json
p = "/home/ubuntu/.openclaw/agents/main/sessions/sessions.json"
d = json.load(open(p))
del d["agent:main:main"]
json.dump(d, open(p, "w"), indent=2)
'

Next heartbeat creates a fresh session and picks up the new primary correctly.

Why this isn't covered by #51677

#51677 was closed citing get-reply.ts and model-selection.ts (the reply path). The heartbeat is a different code path: an autonomous cron-style turn loop that resumes the existing agent:main:main session jsonl on every tick. That path replays the leading model_change event as part of the transcript context, and that event is what determines the model for the LLM call.

It's possible v2026.4.22 fixes this incidentally; I haven't verified the heartbeat path on v2026.4.22 yet because I had already reset the session before rolling forward.

Bonus issue in the same session

While investigating I also noticed the heartbeat session had compactionCount: 0 and a 2.27 MB transcript covering 9 days of HEARTBEAT_OK ticks, replayed in full on each tick on top of a 47k-character bootstrap. Cache hits softened the bill but each tick was still pushing 370k+ cached input tokens. Not the same bug, but worth flagging.

Environment

  • OpenClaw 2026.4.15 (originally observed); rolled to v2026.4.22 after manual reset
  • Linux x86_64, Node 24.14.1, user-level systemd unit
  • Channels: telegram (long-poll)
  • Heartbeat enabled via workspace HEARTBEAT.md

extent analysis

TL;DR

The autonomous heartbeat session does not update its model after changing agents.defaults.model.primary in openclaw.json and restarting the gateway, requiring a manual session reset to apply the new model.

Guidance

  • The issue seems to stem from the heartbeat session's model_change event being pinned at session creation time, which determines the model for subsequent LLM calls.
  • To verify the issue, check the sessions.json entry for the agent:main:main session and the model_change event in the session jsonl transcript.
  • The provided workaround involves manually resetting the session by renaming the session jsonl file and removing the session entry from sessions.json.
  • It is recommended to test the heartbeat path on version v2026.4.22 to see if the issue is incidentally fixed.

Example

The workaround provided in the issue can be used to manually reset the session:

mv ~/.openclaw/agents/main/sessions/<id>.jsonl{,.reset.$(date -u +%s)}
python3 -c '
import json
p = "/home/ubuntu/.openclaw/agents/main/sessions/sessions.json"
d = json.load(open(p))
del d["agent:main:main"]
json.dump(d, open(p, "w"), indent=2)
'

Notes

The issue may be specific to the heartbeat path and not covered by the fix in #51677, which addressed the reply path.

Recommendation

Apply the provided workaround to manually reset the session, as it is a reliable method to update the model for the heartbeat session.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug]: heartbeat session at agent:main:main pins model from creation time, ignores openclaw.json edits across runs (follow-up to #51677) [1 comments, 2 participants]