openclaw - ✅(Solved) Fix [Bug]: Agent repeats own content across turns (4.2) [1 pull requests, 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#60580Fetched 2026-04-08 02:49:28
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
1
Timeline (top)
cross-referenced ×2referenced ×2commented ×1

Fix Action

Fixed

PR fix notes

PR #60855: fix: restore assistant message canonicalization in validateReplayTurns

Description (problem / solution / changelog)

Summary

Fixes a regression introduced in v4.2 where agents repeat content across turns.

Root Cause

validateReplayTurns (introduced in v4.2) was missing the canonicalizeAssistantHistoryMessages repair step. This function repairs malformed assistant messages where content is a string instead of the canonical array format [{type:"text",text:"..."}].

When validateReplayTurns is called directly (e.g., during overflow recovery or session restore) without going through sanitizeSessionHistory, malformed messages bypass repair. This causes the model to see corrupted history and repeat content.

Fix

Added canonicalizeAssistantHistoryMessages call inside validateReplayTurns before any validation or provider plugin processing.

Testing

  • Manual verification that malformed assistant messages are repaired before validation
  • Existing replay validation tests pass

References

  • Fixes #60580

Changed files

  • src/agents/pi-embedded-runner/google.ts (modified, +15/-3)
  • src/agents/pi-embedded-runner/replay-history.ts (modified, +11/-3)
RAW_BUFFERClick to expand / collapse

After upgrading to 4.2, agents repeat content they've already said, as if prior responses aren't in their conversation history. Intermittent, worse in longer sessions.

Two separate instances, both Anthropic Opus 4.6, Telegram streaming off, compaction safeguard. Started after 3.31 → 4.2 upgrade.

Not delivery duplicates (#39795, #42681) — logs show single delivery. No compaction events during repetition.

Suspect 4.2's replay hook changes (transcript policy/cleanup) may be losing prior assistant turns during history reconstruction.

OpenClaw 2026.4.2 (d74a122), Linux

extent analysis

TL;DR

Reverting or adjusting the replay hook changes introduced in version 4.2 may resolve the issue of agents repeating content they've already said.

Guidance

  • Investigate the transcript policy and cleanup logic in the replay hook to see if it's causing the loss of prior assistant turns during history reconstruction.
  • Review the logs to confirm that the issue is indeed related to the history reconstruction and not a delivery or compaction problem.
  • Test the system with a shorter session to see if the issue is still present, which could help determine if the problem is related to the length of the session.
  • Consider rolling back to version 3.31 or a previous version where this issue was not present to see if the problem is specific to version 4.2.

Example

No code snippet is provided as the issue does not include specific code details.

Notes

The issue seems to be specific to version 4.2 and the changes made to the replay hook. The fact that it's intermittent and worse in longer sessions suggests that it might be related to how the conversation history is being reconstructed.

Recommendation

Apply workaround: Revert to a previous version (e.g., 3.31) until the issue with the replay hook changes in version 4.2 is resolved, as this will likely prevent the loss of prior assistant turns during history reconstruction.

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 - ✅(Solved) Fix [Bug]: Agent repeats own content across turns (4.2) [1 pull requests, 1 comments, 2 participants]