openclaw - 💡(How to fix) Fix [Bug] 消息在 memory flush + compaction 后被重复投递 [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#74370Fetched 2026-04-30 06:24:50
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
2
Timeline (top)
commented ×1mentioned ×1subscribed ×1

Root Cause

第二次压缩有以下异常标记:

  • fromHook: True — 说明压缩是在 hook 回调期间发生的
  • modifiedFiles 包含 torchlight_infinite.md — 说明文件在此期间被修改过

当 compaction 发生时,系统认为需要恢复之前的上下文来继续工作,但因为 hook 环境的特殊性,压缩记录本身被错误地当作了一个可触发消息重投的来源。

Code Example

01:27:07  用户消息 c51e29a8(第一次发送)
01:35:10  系统进行了会话压缩(compaction id=c532c833)
01:36:20  第二次压缩(id=5ea497a5,fromHook: True,modifiedFiles: torchlight_infinite.md)
01:36:25  系统重新投递了用户消息 df9878c5,内容与第一次完全相同
RAW_BUFFERClick to expand / collapse

Bug Description

消息在 memory flush + compaction 后被重复投递。用户只发送了一条消息,但系统在大约 9 分钟后重新投递了相同的消息。

Environment

  • OpenClaw version: 2026.4.26 (be8c246)
  • Platform: macOS (Darwin 24.6.0)
  • Model: minimax/MiniMax-M2.7

Steps to Reproduce

  1. 用户发送消息:仔细检查一下,整个火炬之光wiki的数据是不是已经收录完全了
  2. 系统正常处理消息
  3. 大约 9 分钟后(01:35),触发了 memory flush 和 auto compaction
  4. compaction 完成后(01:36),系统错误地重新投递了同一条消息

Relevant Log

01:27:07  用户消息 c51e29a8(第一次发送)
01:35:10  系统进行了会话压缩(compaction id=c532c833)
01:36:20  第二次压缩(id=5ea497a5,fromHook: True,modifiedFiles: torchlight_infinite.md)
01:36:25  系统重新投递了用户消息 df9878c5,内容与第一次完全相同

Root Cause Analysis

第二次压缩有以下异常标记:

  • fromHook: True — 说明压缩是在 hook 回调期间发生的
  • modifiedFiles 包含 torchlight_infinite.md — 说明文件在此期间被修改过

当 compaction 发生时,系统认为需要恢复之前的上下文来继续工作,但因为 hook 环境的特殊性,压缩记录本身被错误地当作了一个可触发消息重投的来源。

Suggested Fix

检查 session_before_compact hook 或 memory flush 相关的消息重投逻辑,确保压缩完成后不会错误地将上一条用户消息重新注入队列。

Session Transcript

~/.openclaw/agents/main/sessions/a25dfe68-01b2-4ee6-8d76-e6649231966c.jsonl 中 01:35-01:36 的记录包含了完整的时序数据。

extent analysis

TL;DR

检查并修正 session_before_compact hook 或 memory flush 相关的消息重投逻辑,以防止压缩完成后错误地将上一条用户消息重新注入队列。

Guidance

  • 检查 session_before_compact hook 的实现,确保它不会在压缩期间错误地触发消息重投。
  • 审查 memory flush 相关的代码,确保压缩完成后不会将上一条用户消息重新注入队列。
  • 查看 ~/.openclaw/agents/main/sessions/a25dfe68-01b2-4ee6-8d76-e6649231966c.jsonl 中 01:35-01:36 的记录,了解压缩和消息重投的时序数据。
  • 考虑添加日志或调试信息以帮助诊断此问题的根因。

Notes

此问题可能与 OpenClaw 的内部实现细节有关,特别是 session_before_compact hook 和 memory flush 的交互。修正此问题可能需要对 OpenClaw 的源代码进行修改或配置更改。

Recommendation

Apply workaround: 修改 session_before_compact hook 或 memory flush 相关的代码,以防止压缩完成后错误地将上一条用户消息重新注入队列。这样可以临时解决问题,但可能需要等待 OpenClaw 官方更新以完全修复此问题。

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