openclaw - ✅(Solved) Fix GLM-5.1 model causes infinite loop in heartbeat - repeats HEARTBEAT_OK indefinitely [1 pull requests, 1 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#61952Fetched 2026-04-08 03:10:48
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
referenced ×3cross-referenced ×1

Fix Action

Workaround

Use minimax/MiniMax-M2.7 for heartbeat/cron tasks, keep GLM-5.1 only for manual conversations.


Reported by: CC (OpenClaw AI assistant) on behalf of user

PR fix notes

PR #61976: fix: prevent heartbeat HEARTBEAT_OK replies from polluting session transcript

Description (problem / solution / changelog)

Fixes #61952

Problem

When heartbeat triggers, the model replies with HEARTBEAT_OK. While stripHeartbeatToken correctly suppresses delivery to the user, the heartbeat prompt + response are still written to the session transcript. On subsequent heartbeats, the model sees accumulated HEARTBEAT_OK turns in history and keeps repeating them, causing an infinite loop that bloats the session context and consumes massive tokens.

This is especially prevalent with models like GLM-5.1 that tend to mimic patterns seen in conversation history.

Fix

When a heartbeat run produces no meaningful output (empty reply or pure HEARTBEAT_OK with shouldSkip=true), roll back the session transcript file to its pre-run state by truncating the bytes added during the heartbeat exchange.

Safety measures

  • Only applies to non-isolated sessions (isolated sessions already use fresh session each run)
  • Checks file size actually grew before truncating
  • If the transcript file was created by the heartbeat run, removes it entirely
  • Rollback failures are logged as warnings, never thrown

Not affected

  • Meaningful heartbeat alerts (delivered to user, kept in transcript)
  • Exec completion events and cron events
  • Sessions with isolatedSession: true

Changed files

  • src/infra/heartbeat-runner.ts (modified, +85/-1)
RAW_BUFFERClick to expand / collapse

Bug Description

When GLM-5.1 model is used as the default model, the heartbeat trigger causes the model to enter an infinite loop, repeatedly outputting "HEARTBEAT_OK" without stopping. This results in massive token consumption and session context bloat.

Environment

  • OpenClaw version: 2026.4.5 (3e72c03)
  • Platform: macOS (Mac mini)
  • Model: zai/glm-5.1 (primary), minimax/MiniMax-M2.7 (fallback)
  • Model provider: Z.ai (智谱AI BigModel)
  • Channel: 飞书 (Feishu)

Steps to Reproduce

  1. Set primary model to zai/glm-5.1 in openclaw.json
  2. Wait for heartbeat to trigger (every 30 minutes)
  3. Observe: model starts repeating "HEARTBEAT_OK" infinitely

Expected Behavior

Model should respond once with HEARTBEAT_OK (which gets suppressed) and stop.

Actual Behavior

Model enters infinite loop, outputting hundreds/thousands of "HEARTBEAT_OK" responses. Session context becomes severely bloated. Gateway needs to be physically restarted to recover.

Additional Context

  • Switching back to minimax/MiniMax-M2.7 resolves the issue
  • This does NOT happen when heartbeat uses minimax/MiniMax-M2.7
  • GLM-5.1 works fine for manual conversations
  • The issue only affects automated heartbeat/cron tasks
  • One possible related factor: GLM-5.1 API may have different streaming/response behavior compared to other providers

Workaround

Use minimax/MiniMax-M2.7 for heartbeat/cron tasks, keep GLM-5.1 only for manual conversations.


Reported by: CC (OpenClaw AI assistant) on behalf of user

extent analysis

TL;DR

Switch to minimax/MiniMax-M2.7 for heartbeat/cron tasks to avoid the infinite loop issue with GLM-5.1.

Guidance

  • Verify that the issue is specific to the GLM-5.1 model by testing other models with the heartbeat trigger.
  • Check the OpenClaw configuration to ensure that the heartbeat trigger is properly set up and not causing unintended behavior.
  • Consider reaching out to the Z.ai (智谱AI BigModel) support team to investigate potential differences in streaming/response behavior between GLM-5.1 and other models.
  • Test the workaround of using minimax/MiniMax-M2.7 for heartbeat/cron tasks while keeping GLM-5.1 for manual conversations.

Example

No code snippet is provided as the issue does not require a code-level fix, but rather a configuration change.

Notes

The issue seems to be specific to the GLM-5.1 model and the heartbeat trigger, and switching to minimax/MiniMax-M2.7 resolves the issue. However, it is unclear what causes the difference in behavior between the two models.

Recommendation

Apply the workaround of using minimax/MiniMax-M2.7 for heartbeat/cron tasks, as it is a simple and effective solution to avoid the infinite loop issue with GLM-5.1.

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