Bug type / 问题类型
Behavior bug (incorrect routing/session selection without crash)
行为错误(路由 / 会话选择异常,无崩溃)
Summary / 摘要
Telegram direct messages can still be routed into agent:main:main instead of staying isolated in agent:main:telegram:direct:<id>, even after the duplicate-reply fix from #40519 .
In my case, this polluted the session that was being used for heartbeat, causing heartbeat to inherit unrelated user conversation history and burn a large amount of tokens.
即使在 #40519 修复了“重复回复”之后,Telegram 私聊消息似乎仍然可能被路由进 agent:main:main,而不是稳定地留在 agent:main:telegram:direct:<id> 中。
在我的实际案例里,这直接污染了原本用于 heartbeat 的会话,导致 heartbeat 继承了无关的用户聊天历史,并显著增加 token 消耗。
Related issues / PRs / 相关 Issue / PR
What I expected / 期望行为
Telegram DMs should consistently stay in:
agent:main:telegram:direct:<telegram-user-id>
and should not be appended to:
especially when agent:main:main is being used for heartbeat or other main-session purposes.
Telegram 私聊应始终稳定进入:
agent:main:telegram:direct:<telegram-user-id>
而不应该被追加到:
尤其不应该在 agent:main:main 已经被用于 heartbeat 或其他 main-session 场景时混入其中。
What actually happened / 实际发生的情况
A session whose origin/delivery context was clearly heartbeat:
session key: agent:main:main
origin.provider: heartbeat
deliveryContext.to: heartbeat
was later reused for ordinary Telegram DM requests.
That same session first handled heartbeat prompts such as:
Read HEARTBEAT.md if it exists ... If nothing needs attention, reply HEARTBEAT_OK
but later also received multiple normal user requests, including translation tasks like:
translating short English snippets
translating multiple OpenClaw release notes into Chinese Markdown
As a result:
the heartbeat/main session accumulated unrelated user conversation history
heartbeat runs became expensive because they inherited this polluted context
session isolation between Telegram DM and main/heartbeat behavior was effectively broken
有一个会话,其 origin / delivery context 明确显示它本应属于 heartbeat:
session key: agent:main:main
origin.provider: heartbeat
deliveryContext.to: heartbeat
但后来这个会话又被普通 Telegram 私聊请求复用了。
这个会话一开始处理的是 heartbeat 提示,例如:
Read HEARTBEAT.md if it exists ... If nothing needs attention, reply HEARTBEAT_OK
但之后又收到了多条普通用户请求,包括翻译类任务,例如:
翻译简单英文句子
把多篇 OpenClaw 发布说明翻译成中文 Markdown
结果就是:
heartbeat / main 会话积累了大量无关的用户聊天历史
heartbeat 因继承这部分污染上下文而变得昂贵
Telegram 私聊与 main / heartbeat 之间的会话隔离实际上被破坏了
Why this seems distinct from #40005 / #40519 / 为什么这和 #40005 / #40519 不完全一样
My understanding is that #40519 fixed duplicate execution / duplicate replies for the case where the same Telegram DM is surfaced under both:
agent:main:main
agent:main:telegram:direct:<id>
However, in my case, the underlying session-selection / routing contamination still appears to happen.
So the duplicate reply symptom may be fixed, but the more fundamental issue remains:
Telegram DMs can still land in agent:main:main
agent:main:main can still be polluted by direct-chat traffic
我的理解是,#40519 修复的是重复执行 / 重复回复 问题,也就是同一条 Telegram 私聊同时出现在:
agent:main:main
agent:main:telegram:direct:<id>
时只执行一次。
但在我的案例里,更底层的会话选择 / 路由污染 似乎仍然存在。
也就是说,“重复回复”这个表层症状可能被修好了,但更深层的问题还在:
Telegram 私聊仍然可能落进 agent:main:main
agent:main:main 仍然可能被 direct chat 污染
Evidence / 证据
From sessions.json, the polluted session was:
session key: agent:main:main
sessionId: 392fda28-76ed-4115-b56b-1f77bc87bdcb
origin.label: heartbeat
origin.provider: heartbeat
deliveryContext.to: heartbeat
Its transcript file was:
/Users/.../.openclaw/agents/main/sessions/0313f1ed-7b78-4f79-a216-fa40abe3d147.jsonl
Within that same transcript, I observed both:
A. Heartbeat traffic
Examples included prompts like:
Read HEARTBEAT.md if it exists ... reply HEARTBEAT_OK
and heartbeat-related actions such as reading:
HEARTBEAT.md
heartbeat-state.json
B. Normal user DM traffic
Later in the same transcript, I observed many ordinary user requests, including:
translation of Hello world
translation of multiple OpenClaw release notes:
v2026.2.25
v2026.2.26
v2026.3.1
v2026.3.2
v2026.3.7
v2026.3.7-beta.1
v2026.3.8-beta.1
v2026.3.8
These were clearly not heartbeat tasks.
根据 sessions.json,被污染的会话是:
session key: agent:main:main
sessionId: 392fda28-76ed-4115-b56b-1f77bc87bdcb
origin.label: heartbeat
origin.provider: heartbeat
deliveryContext.to: heartbeat
对应 transcript 文件为:
/Users/.../.openclaw/agents/main/sessions/0313f1ed-7b78-4f79-a216-fa40abe3d147.jsonl
在同一个 transcript 中,我同时观察到了:
A. Heartbeat 流量
例如:
Read HEARTBEAT.md if it exists ... reply HEARTBEAT_OK
以及 heartbeat 相关行为,例如读取:
HEARTBEAT.md
heartbeat-state.json
B. 普通用户 Telegram 私聊流量
在同一 transcript 的后半段,又出现了多条普通用户请求,包括:
翻译 Hello world
翻译多篇 OpenClaw 发布说明:
v2026.2.25
v2026.2.26
v2026.3.1
v2026.3.2
v2026.3.7
v2026.3.7-beta.1
v2026.3.8-beta.1
v2026.3.8
这些显然都不是 heartbeat 任务。
Additional observation / 补充观察
Earlier heartbeat turns in the same session also did more than a plain HEARTBEAT_OK:
queried weather
queried reminders
produced morning/evening summaries
So once ordinary Telegram DMs also entered the same session, the context became a mix of:
heartbeat logic
reminders/weather checks
normal user conversation
This made the token cost of heartbeat much worse.
这个会话里更早的 heartbeat 轮次,本身也不只是简单返回 HEARTBEAT_OK,还做过:
所以一旦普通 Telegram 私聊也进入同一个 session,整个上下文就变成了:
heartbeat 逻辑
天气 / 提醒检查
普通用户对话
这会明显放大 heartbeat 的 token 成本。
Reproduction idea / 复现思路
I cannot guarantee a 100% minimal repro yet, but the pattern appears to be:
Have heartbeat enabled so agent:main:main is active
Use Telegram DM with the same agent
Over time, observe that normal DM requests may append into agent:main:main instead of remaining isolated in agent:main:telegram:direct:<id>
我目前还不能给出 100% 极简、稳定复现步骤,但观察到的模式大致是:
开启 heartbeat,让 agent:main:main 处于活跃状态
同时使用 Telegram 私聊同一个 agent
经过一段时间后,普通 DM 请求可能会被追加到 agent:main:main,而不是稳定留在 agent:main:telegram:direct:<id>
Temporary workaround / 临时绕过方案
I manually cleaned the polluted agent:main:main session by:
archiving its transcript
removing the agent:main:main entry from sessions.json
After that, the dirty main/heartbeat session disappeared and could be recreated cleanly.
This is only a workaround, not a fix.
我目前的临时处理方式是手动清理被污染的 agent:main:main:
归档它的 transcript
从 sessions.json 中移除 agent:main:main 这条映射
这样做之后,旧的脏 main/heartbeat session 会消失,下次 heartbeat 会重新创建一个干净会话。
但这只是绕过方法,不是根修复。
Expected fix direction / 建议修复方向
At minimum, Telegram DM session selection should be strictly isolated so that normal DMs cannot append to agent:main:main.
More robustly:
Heartbeat should use a dedicated isolated session namespace rather than agent:main:main
Telegram DMs should never reuse a heartbeat-origin main session
Fixes like fix: dedupe inbound Telegram DM replies per agent #40519 should apply not only to duplicate execution, but also to the underlying session-selection ambiguity
至少应保证 Telegram DM 的会话选择严格隔离,避免普通私聊被追加到 agent:main:main。
更稳妥的方向可能包括:
Heartbeat 应使用独立的隔离 session namespace,而不是复用 agent:main:main
Telegram 私聊不应复用一个 origin 为 heartbeat 的 main session
像 fix: dedupe inbound Telegram DM replies per agent #40519 这样的修复不应只处理“重复执行”,也应覆盖更底层的 session-selection 歧义
OpenClaw version / OpenClaw 版本
Observed on OpenClaw 2026.3.7 runtime, with behavior investigated on March 9, 2026, after reviewing the 2026.3.8 changelog and the merged fix in #40519 .
问题发生在 OpenClaw 2026.3.7 运行时环境中;我是在 2026-03-09 排查这个现象时,结合 2026.3.8 的 changelog 和已合并的 #40519 修复一起比对后确认的。
Operating system / 操作系统
macOS (Apple Silicon)
Install method / 安装方式
npm global
Impact and severity / 影响与严重性
Affected: Telegram DM + heartbeat users
Severity: Medium to High
Consequences:
heartbeat session pollution
token waste
session isolation confusion
risk of future routing/context leakage across main vs direct traffic
受影响范围:Telegram 私聊 + heartbeat 用户
严重性:中到高
后果包括:
heartbeat 会话被污染
token 浪费
会话隔离混乱
main / direct 流量后续发生上下文泄漏的风险
Bug type / 问题类型
Behavior bug (incorrect routing/session selection without crash)
行为错误(路由 / 会话选择异常,无崩溃)
Summary / 摘要
Telegram direct messages can still be routed into
agent:main:maininstead of staying isolated inagent:main:telegram:direct:<id>, even after the duplicate-reply fix from #40519.In my case, this polluted the session that was being used for heartbeat, causing heartbeat to inherit unrelated user conversation history and burn a large amount of tokens.
即使在 #40519 修复了“重复回复”之后,Telegram 私聊消息似乎仍然可能被路由进
agent:main:main,而不是稳定地留在agent:main:telegram:direct:<id>中。在我的实际案例里,这直接污染了原本用于 heartbeat 的会话,导致 heartbeat 继承了无关的用户聊天历史,并显著增加 token 消耗。
Related issues / PRs / 相关 Issue / PR
What I expected / 期望行为
Telegram DMs should consistently stay in:
agent:main:telegram:direct:<telegram-user-id>and should not be appended to:
agent:main:mainespecially when
agent:main:mainis being used for heartbeat or other main-session purposes.Telegram 私聊应始终稳定进入:
agent:main:telegram:direct:<telegram-user-id>而不应该被追加到:
agent:main:main尤其不应该在
agent:main:main已经被用于 heartbeat 或其他 main-session 场景时混入其中。What actually happened / 实际发生的情况
A session whose origin/delivery context was clearly heartbeat:
session key:agent:main:mainorigin.provider:heartbeatdeliveryContext.to:heartbeatwas later reused for ordinary Telegram DM requests.
That same session first handled heartbeat prompts such as:
Read HEARTBEAT.md if it exists ... If nothing needs attention, reply HEARTBEAT_OKbut later also received multiple normal user requests, including translation tasks like:
As a result:
有一个会话,其 origin / delivery context 明确显示它本应属于 heartbeat:
session key:agent:main:mainorigin.provider:heartbeatdeliveryContext.to:heartbeat但后来这个会话又被普通 Telegram 私聊请求复用了。
这个会话一开始处理的是 heartbeat 提示,例如:
Read HEARTBEAT.md if it exists ... If nothing needs attention, reply HEARTBEAT_OK但之后又收到了多条普通用户请求,包括翻译类任务,例如:
结果就是:
Why this seems distinct from #40005 / #40519 / 为什么这和 #40005 / #40519 不完全一样
My understanding is that #40519 fixed duplicate execution / duplicate replies for the case where the same Telegram DM is surfaced under both:
agent:main:mainagent:main:telegram:direct:<id>However, in my case, the underlying session-selection / routing contamination still appears to happen.
So the duplicate reply symptom may be fixed, but the more fundamental issue remains:
agent:main:mainagent:main:maincan still be polluted by direct-chat traffic我的理解是,#40519 修复的是重复执行 / 重复回复问题,也就是同一条 Telegram 私聊同时出现在:
agent:main:mainagent:main:telegram:direct:<id>时只执行一次。
但在我的案例里,更底层的会话选择 / 路由污染似乎仍然存在。
也就是说,“重复回复”这个表层症状可能被修好了,但更深层的问题还在:
agent:main:mainagent:main:main仍然可能被 direct chat 污染Evidence / 证据
From
sessions.json, the polluted session was:session key:agent:main:mainsessionId:392fda28-76ed-4115-b56b-1f77bc87bdcborigin.label:heartbeatorigin.provider:heartbeatdeliveryContext.to:heartbeatIts transcript file was:
/Users/.../.openclaw/agents/main/sessions/0313f1ed-7b78-4f79-a216-fa40abe3d147.jsonlWithin that same transcript, I observed both:
A. Heartbeat traffic
Examples included prompts like:
Read HEARTBEAT.md if it exists ... reply HEARTBEAT_OKand heartbeat-related actions such as reading:
HEARTBEAT.mdheartbeat-state.jsonB. Normal user DM traffic
Later in the same transcript, I observed many ordinary user requests, including:
Hello worldv2026.2.25v2026.2.26v2026.3.1v2026.3.2v2026.3.7v2026.3.7-beta.1v2026.3.8-beta.1v2026.3.8These were clearly not heartbeat tasks.
根据
sessions.json,被污染的会话是:session key:agent:main:mainsessionId:392fda28-76ed-4115-b56b-1f77bc87bdcborigin.label:heartbeatorigin.provider:heartbeatdeliveryContext.to:heartbeat对应 transcript 文件为:
/Users/.../.openclaw/agents/main/sessions/0313f1ed-7b78-4f79-a216-fa40abe3d147.jsonl在同一个 transcript 中,我同时观察到了:
A. Heartbeat 流量
例如:
Read HEARTBEAT.md if it exists ... reply HEARTBEAT_OK以及 heartbeat 相关行为,例如读取:
HEARTBEAT.mdheartbeat-state.jsonB. 普通用户 Telegram 私聊流量
在同一 transcript 的后半段,又出现了多条普通用户请求,包括:
Hello worldv2026.2.25v2026.2.26v2026.3.1v2026.3.2v2026.3.7v2026.3.7-beta.1v2026.3.8-beta.1v2026.3.8这些显然都不是 heartbeat 任务。
Additional observation / 补充观察
Earlier heartbeat turns in the same session also did more than a plain
HEARTBEAT_OK:So once ordinary Telegram DMs also entered the same session, the context became a mix of:
This made the token cost of heartbeat much worse.
这个会话里更早的 heartbeat 轮次,本身也不只是简单返回
HEARTBEAT_OK,还做过:所以一旦普通 Telegram 私聊也进入同一个 session,整个上下文就变成了:
这会明显放大 heartbeat 的 token 成本。
Reproduction idea / 复现思路
I cannot guarantee a 100% minimal repro yet, but the pattern appears to be:
agent:main:mainis activeagent:main:maininstead of remaining isolated inagent:main:telegram:direct:<id>我目前还不能给出 100% 极简、稳定复现步骤,但观察到的模式大致是:
agent:main:main处于活跃状态agent:main:main,而不是稳定留在agent:main:telegram:direct:<id>Temporary workaround / 临时绕过方案
I manually cleaned the polluted
agent:main:mainsession by:agent:main:mainentry fromsessions.jsonAfter that, the dirty main/heartbeat session disappeared and could be recreated cleanly.
This is only a workaround, not a fix.
我目前的临时处理方式是手动清理被污染的
agent:main:main:sessions.json中移除agent:main:main这条映射这样做之后,旧的脏 main/heartbeat session 会消失,下次 heartbeat 会重新创建一个干净会话。
但这只是绕过方法,不是根修复。
Expected fix direction / 建议修复方向
At minimum, Telegram DM session selection should be strictly isolated so that normal DMs cannot append to
agent:main:main.More robustly:
agent:main:main至少应保证 Telegram DM 的会话选择严格隔离,避免普通私聊被追加到
agent:main:main。更稳妥的方向可能包括:
agent:main:mainOpenClaw version / OpenClaw 版本
Observed on OpenClaw
2026.3.7runtime, with behavior investigated on March 9, 2026, after reviewing the2026.3.8changelog and the merged fix in #40519.问题发生在 OpenClaw
2026.3.7运行时环境中;我是在 2026-03-09 排查这个现象时,结合2026.3.8的 changelog 和已合并的 #40519 修复一起比对后确认的。Operating system / 操作系统
macOS (Apple Silicon)
Install method / 安装方式
npm global
Impact and severity / 影响与严重性
Affected: Telegram DM + heartbeat users
Severity: Medium to High
Consequences:
受影响范围:Telegram 私聊 + heartbeat 用户
严重性:中到高
后果包括: