Skip to content

Commit 24d1e2c

Browse files
HemantSudarshanBunsDev
authored andcommitted
Gateway: skip text-only assistant media supplements
1 parent 6fd35f6 commit 24d1e2c

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Docs: https://docs.openclaw.ai
2929
- Telegram: inherit the process DNS result order for Bot API transport and downgrade recovered sticky IPv4 fallback promotions to debug logs, while keeping pinned-IP escalation warnings visible. Fixes #75904. Thanks @highfly-hi and @neeravmakwana.
3030
- Web search/MiniMax: allow `MINIMAX_OAUTH_TOKEN` to satisfy MiniMax Search credentials, so OAuth-authorized MiniMax Token Plan setups do not need a separate web-search key. Fixes #65768. Thanks @kikibrian and @zhouhe-xydt.
3131
- Providers/MiniMax: derive Coding Plan usage polling from the configured MiniMax base URL, so global setups no longer query the CN usage host. Fixes #65054. Thanks @sixone74 and @Yanhu007.
32+
- Control UI/WebChat: skip assistant-media transcript supplements when stale media refs resolve to no playable media, so text-only final replies are not stored a second time as gateway-injected assistant messages. Fixes #73956. Thanks @HemantSudarshan.
3233
- Sessions: reject `sessions_send` targets that resolve to thread-scoped chat sessions, so inter-agent coordination cannot be injected into active human-facing Slack or Discord threads. Fixes #52496. Thanks @barry-p5cc.
3334
- Subagents: honor `sessions_spawn` with `expectsCompletionMessage: false` by skipping parent completion handoff delivery while still running child cleanup. Fixes #75848. Thanks @alfredjbclaw.
3435
- Media/completions: treat media-only message-tool sends as delivered async completion output, avoiding duplicate raw `MEDIA:` fallback posts after video or music generation finishes.

‎src/gateway/server-methods/chat.directive-tags.test.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,48 @@ describe("chat directive tag stripping for non-streaming final payloads", () =>
715715
);
716716
});
717717

718+
it("does not persist agent media supplements when no playable media resolves", async () => {
719+
const transcriptDir = createTranscriptFixture("openclaw-chat-send-agent-stale-tts-");
720+
const staleAudioPath = path.join(transcriptDir, "stale.mp3");
721+
mockState.config = {
722+
agents: {
723+
defaults: {
724+
workspace: transcriptDir,
725+
},
726+
},
727+
};
728+
mockState.triggerAgentRunStart = true;
729+
mockState.dispatchedReplies = [
730+
{
731+
kind: "final",
732+
payload: {
733+
text: "Text-only test: one clean reply, no TTS, no media, no tool narration.",
734+
mediaUrl: staleAudioPath,
735+
mediaUrls: [staleAudioPath],
736+
trustedLocalMedia: true,
737+
},
738+
},
739+
];
740+
const respond = vi.fn();
741+
const context = createChatContext();
742+
743+
await runNonStreamingChatSend({
744+
context,
745+
respond,
746+
idempotencyKey: "idem-stale-agent-media",
747+
expectBroadcast: false,
748+
waitFor: "dedupe",
749+
});
750+
751+
const assistantUpdates = mockState.emittedTranscriptUpdates.filter(
752+
(update) =>
753+
typeof update.message === "object" &&
754+
update.message !== null &&
755+
(update.message as { role?: unknown }).role === "assistant",
756+
);
757+
expect(assistantUpdates).toEqual([]);
758+
});
759+
718760
it("keeps visible text on non-agent TTS final media because no model transcript exists", async () => {
719761
const transcriptDir = createTranscriptFixture("openclaw-chat-send-command-tts-final-");
720762
const audioPath = path.join(transcriptDir, "tts.mp3");

‎src/gateway/server-methods/chat.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,6 +2262,9 @@ export const chatHandlers: GatewayRequestHandlers = {
22622262
const persistedContentForAppend = hasAssistantDisplayMediaContent(persistedAssistantContent)
22632263
? persistedAssistantContent
22642264
: undefined;
2265+
if (!persistedContentForAppend?.length) {
2266+
return;
2267+
}
22652268
const transcriptReply =
22662269
mediaMessage?.transcriptText ??
22672270
extractAssistantDisplayTextFromContent(assistantContent) ??

0 commit comments

Comments
 (0)