Repository navigation
Description
Summary
Follow-up to #91818. That issue was closed as resolved, but the closure appears to have matched the wrong fix model. The live Bncr reproduction is not just “block-streamed text plus final media payload”; it is a MEDIA: directive + channel.message delivery split where the intermediate/block path intentionally does not parse MEDIA: while the final/outbound path does parse it and later uses the remaining text as media caption.
As a result, a mixed final reply can still become:
- block/intermediate text-only send;
- final media send via channel.message / outbound delivery;
- the same text reused as media caption or emitted again around the media handoff.
This produces duplicated user-visible text even on OpenClaw 2026.6.5.
Why #91818 should not have been closed
The #91818 close comment cites two different things:
- Relevant-looking code around
src/auto-reply/reply/agent-runner-payloads.ts/block-reply-pipeline.tsthat can strip text from a final media payload when the block pipeline can prove the text was already sent. - But it also cites PR fix(gateway): skip deleted-agent guard for ACP harness session keys #91219 / commit
696c1ecd2068, which is unrelated (fix(gateway): skip deleted-agent guard for ACP harness session keys, files undersrc/gateway/session-utils*).
More importantly, the cited fix does not cover the actual MEDIA: directive split path described below.
Concrete source path in v2026.6.5
1. Block/intermediate replies do not extract MEDIA: directives
In src/auto-reply/reply/reply-delivery.ts, createBlockReplyDeliveryHandler normalizes block replies with:
const normalized = normalizeReplyPayloadDirectives({
payload: taggedPayload,
currentMessageId: params.currentMessageId,
silentToken: SILENT_REPLY_TOKEN,
trimLeadingWhitespace: true,
parseMode: "auto",
extractMediaDirectives: false,
});Because extractMediaDirectives: false, an assistant block/intermediate response that contains visible text plus a MEDIA: line cannot become a media-aware payload at this stage. The intermediate layer is effectively text-only.
2. Final delivery does parse MEDIA: directives
In src/auto-reply/reply/agent-runner-payloads.ts, final payload construction calls:
const parsed = normalizeReplyPayloadDirectives({
payload,
currentMessageId: params.currentMessageId,
silentToken: SILENT_REPLY_TOKEN,
parseMode: "always",
extractMarkdownImages: params.extractMarkdownImages,
});normalizeReplyPayloadDirectives(...) then uses parseReplyDirectives(...) to split final text and media:
const mediaUrls = params.payload.mediaUrls ?? parsed?.mediaUrls;
const mediaUrl = params.payload.mediaUrl ?? parsed?.mediaUrl ?? mediaUrls?.[0];
return {
payload: copyReplyPayloadMetadata(params.payload, {
...params.payload,
text,
mediaUrls,
mediaUrl,
...
}),
isSilent: parsed?.isSilent ?? false,
};So final delivery is media-aware while the block/intermediate path was not.
3. The cited dedupe only works if the block pipeline can prove a text-only payload was already sent
The close comment points at the preserveUnsentMediaAfterBlockStream logic:
const preserveUnsentMediaAfterBlockStream = (payload: ReplyPayload): ReplyPayload | null => {
...
const reply = resolveSendableOutboundReplyParts(payload);
if (!reply.hasMedia) {
return null;
}
if (!reply.trimmedText) {
return payload;
}
const textOnlyPayload = copyReplyPayloadMetadata(payload, {
...payload,
mediaUrl: undefined,
mediaUrls: undefined,
audioAsVoice: undefined,
});
if (!params.blockReplyPipeline?.hasSentPayload(textOnlyPayload)) {
return payload;
}
return copyReplyPayloadMetadata(payload, {
...payload,
text: undefined,
audioAsVoice: payload.audioAsVoice || undefined,
});
};This only strips final media text when blockReplyPipeline.hasSentPayload(textOnlyPayload) returns true. That is not guaranteed for MEDIA: directive final replies delivered through the source-channel/channel.message path, especially when the earlier text was sent by a direct block path, tool/progress path, or a different source delivery mechanism.
4. Outbound media delivery uses remaining text as media caption
In dist/deliver-D56UzjS7.js from installed 2026.6.5, final media delivery plans media units using:
const mediaUnits = planOutboundMediaMessageUnits({
mediaUrls: payloadSummary.mediaUrls,
caption: payloadSummary.text,
overrides: sendOverrides,
consumeReplyTo: applySendReplyToConsumption
});Then each media unit is sent as:
await deliveryHandler.sendMedia(unit.caption ?? "", unit.mediaUrl, unit.overrides)Therefore, if the dedupe path above fails to clear payload.text, the final media handoff reuses the same visible text as caption after the intermediate text was already sent.
Live reproduction evidence
Environment:
OpenClaw 2026.6.5 (5181e4f)
@xmoxmo/bncr 0.3.6
Final assistant reply shape:
测试 txt 附件来了,陌。
如果链路正常,你这边应该能看到这段文字 + 一个 `.txt` 文件。
MEDIA:/root/.openclaw/workspace/tmp/bncr-channel-message-test-20260610-1121.txt
Gateway/Bncr journal:
2026-06-10T11:22:18+08:00 [bncr] outbound text|Bncr:tgBot:-1003776014601:6278285192|测试 txt 附…
2026-06-10T11:22:18+08:00 [bncr] outbox push mid=d8c528dc-3c5c-4d89-9d48-3c03a72b1541|q=1
2026-06-10T11:22:18+08:00 [bncr] outbound message.outbound|Bncr:tgBot:-1003776014601:6278285192|-
2026-06-10T11:22:20+08:00 [bncr] outbox ack ok mid=d8c528dc-3c5c-4d89-9d48-3c03a72b1541|q=1|queueMs=1691|pushMs=1688
2026-06-10T11:22:21+08:00 [bncr] outbox push mid=58a44239-5d5b-4ad8-8717-92a29db514ca|q=1
2026-06-10T11:22:21+08:00 [bncr] outbound text|Bncr:tgBot:-1003776014601:6278285192|测试 txt 附…
2026-06-10T11:22:22+08:00 [bncr] outbox ack ok mid=58a44239-5d5b-4ad8-8717-92a29db514ca|q=1|queueMs=3348|pushMs=887
2026-06-10T11:22:22+08:00 [bncr] outbox push mid=e1cded76-cc16-43f4-bb43-f860f262f4c7|q=1
2026-06-10T11:22:23+08:00 [bncr] outbox ack ok mid=e1cded76-cc16-43f4-bb43-f860f262f4c7|q=0|queueMs=1960|pushMs=1221
All outbox entries ACK successfully. This is not an ACK retry or client-side duplicate rendering.
Expected behavior
For one logical assistant final reply containing text plus MEDIA: attachment(s), the user-visible text must be delivered exactly once.
Acceptable fixes:
- Make intermediate/block replies media-aware too. If the intermediate layer sends text from a reply that contains
MEDIA:, it should also carry the attachment metadata / logical media identity, so final delivery can dedupe/merge correctly. - Strip duplicated text from one side. Either suppress the earlier standalone text, or clear the final media caption/text when the final payload came from the same text+MEDIA directive.
- Carry stable logical reply/media identity across block/final/source-channel handoffs. Then adapters can safely downgrade the later duplicate to already-sent without relying on text-only
hasSentPayloadheuristics.
Suggested test
Add a regression that exercises the exact MEDIA: directive path, not just { text, mediaUrl } payloads:
- input assistant content:
hello\n\nMEDIA:/tmp/a.txt - block/intermediate delivery enabled
- source-channel/channel.message final delivery enabled
- assert final observable send plan contains:
- one visible
hellotext, and - one
/tmp/a.txtmedia send, - but no second
hellocaption/text.
- one visible
The existing test keeps unsent final media after block pipeline streamed the text is close, but it starts from a structured { text, mediaUrl } payload. The bug is in the legacy MEDIA: directive split where block delivery does not parse media directives and final delivery does.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 10, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 10, 2026, 3:40 AM ET / 07:40 UTC.
Summary
Keep open: current main still has the asymmetric MEDIA directive handling described in the report, and the open design follow-up tracks the broader channel.message contract rather than replacing this narrower duplicate-text bug.
Reproducibility: yes. for source-level reproduction: current main still has block delivery that skips MEDIA extraction, final delivery that parses MEDIA, and outbound media delivery that uses remaining text as caption. I did not execute a live Bncr transport repro in this read-only review.
Next step
This is a narrow source-reproducible delivery bug with clear likely files and a focused regression-test shape; the linked design issue should remain separate.
Review details
Best possible solution:
Fix the shared reply payload/dedupe path so a text+MEDIA directive whose visible text was already sent delivers the attachment without reusing that text as a second caption, while leaving the broader channel.message payload contract to the linked design issue.
Do we have a high-confidence way to reproduce the issue?
Yes for source-level reproduction: current main still has block delivery that skips MEDIA extraction, final delivery that parses MEDIA, and outbound media delivery that uses remaining text as caption. I did not execute a live Bncr transport repro in this read-only review.
Is this the best way to solve the issue?
Yes for the narrow bug: the maintainable fix belongs in shared reply payload construction or block/final dedupe before transport delivery, not in a Bncr-specific workaround. The broader choice to delegate logical text+media physical sending to plugins is separately tracked in #91867.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 7f1d82ab2518.
Label changes
Label justifications:
P2: The report is a normal-priority user-visible channel delivery bug with clear source evidence and bounded blast radius.impact:message-loss: The issue is about duplicated visible channel text during mixed text-plus-media reply delivery.Evidence reviewed
Acceptance criteria:
What I checked:
AGENTS.md:1, 7f1d82ab2518)src/auto-reply/reply/reply-delivery.ts:123, 7f1d82ab2518)src/auto-reply/reply/agent-runner-payloads.ts:223, 7f1d82ab2518)src/auto-reply/reply/agent-runner-payloads.ts:335, 7f1d82ab2518)src/infra/outbound/deliver.ts:1876, 7f1d82ab2518)src/auto-reply/reply/agent-runner-payloads.test.ts:519, 7f1d82ab2518)Likely related people:
src/auto-reply/reply/reply-delivery.ts,src/auto-reply/reply/agent-runner-payloads.ts,src/infra/outbound/deliver.ts)src/infra/outbound/deliver.ts,src/infra/outbound/message-plan.ts,src/plugin-sdk/reply-payload.ts)src/infra/outbound/deliver.ts,src/infra/outbound/payloads.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.xmoxmo commentedon Jun 10, 2026
Additional live reproduction and a shorter chain summary from the latest Bncr/channel.message test.
Test environment:
Test final reply shape:
Observed Bncr/Gateway log around the test:
The important part is this sequence:
All outbox messages ACK successfully, so this is still not an ACK retry or adapter retry.
The clearest chain summary is:
So the bug is best described as a cross-layer invariant break: once a logical final reply containing
text + MEDIAis split into source-channel/channel.message deliveries, the visible text is not consistently marked as already-sent or removed from the later media handoff. The fix should ensure that this logical reply produces exactly one visible text unit plus the attachment, regardless of whether the attachment travels throughmessage.outbound, source-channel delivery, or the final media/caption path.xmoxmo commentedon Jun 10, 2026
One more design clarification from the adapter/plugin side.
I do not think this means
channel.messageshould be removed. It is useful as the runtime delivery contract for final replies, reply/thread context, durable final delivery, receipts, and channel capabilities.The concern is that the backend send planning for
channel.messageshould not diverge from the already stablemessage.send/ plugin send semantics by eagerly turning one logical message into separate physical text/media sends in core.A better invariant would be:
This matters for Bncr in particular because Bncr is a bridge to many downstream platforms. Some downstream platforms support media + caption/summary as one message, while others require text and attachment to be split. Bncr's backend can already make that platform-specific decision. If OpenClaw core splits text and media before Bncr sees the logical payload, it removes that choice and can make capable platforms behave worse.
In other words, the issue is not only duplicated text. The deeper delivery-contract problem is:
For a final reply like:
the adapter should ideally receive one logical
text + mediapayload and decide:So the preferred fix shape is not just "clear captions somewhere". The more robust fix is to make
channel.messagepreserve logical message shape and reuse the same stable plugin/backend sending semantics asmessage.send/sendPayloadwhere possible, leaving physical splitting policy to the channel plugin.xmoxmo commentedon Jun 10, 2026
I opened a separate design issue for the broader delivery-contract concern so this bug can stay focused on the concrete duplicate-text reproduction:
Short version:
channel.messageshould remain the runtime delivery contract, but it should preserve logicaltext + mediapayload shape as long as possible and let the channel plugin/backend choose the physical send shape, instead of core eagerly splitting text/media before adapter-specific handling.vincentkoc commentedon Jun 10, 2026
Fixed on main in aeb537c.
The final reply now carries assistant-message identity and compares against successfully delivered direct block payloads, preserving emission order and meaningful whitespace. Already-sent text/media is removed while genuinely new final attachments remain deliverable.
Verification: