Skip to content

Fix duplicate Control UI assistant-media replies - #74502

Closed
HemantSudarshan wants to merge 1 commit into
openclaw:mainfrom
HemantSudarshan:hemant/73956-webchat-assistant-media-dedupe
Closed

HemantSudarshan wants to merge 1 commit into
openclaw:mainfrom
HemantSudarshan:hemant/73956-webchat-assistant-media-dedupe

Conversation

@HemantSudarshan

Copy link
Copy Markdown
Contributor

Summary

  • Problem: Control UI/WebChat could persist a second gateway-injected assistant message from the :assistant-media path when a media-bearing agent payload no longer resolved to playable media.
  • Why it matters: stale or non-playable TTS/media references could repeat the final assistant text in the transcript, making the assistant appear to reply twice.
  • What changed: the agent-run assistant-media transcript append now requires resolved media content before writing the supplemental transcript message.
  • What did NOT change (scope boundary): command/non-agent media replies still preserve visible text when no model transcript exists.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause (if applicable)

  • Root cause: the agent-run assistant-media append path gated on the presence of mediaUrl/mediaUrls, then fell back to text when those media references failed to resolve to embeddable content.
  • Missing detection / guardrail: there was coverage for resolved TTS audio not duplicating text, but not for stale/non-playable media references with visible text.
  • Contributing context: the supplemental assistant-media message is only needed when it can carry media content that the normal model transcript does not already contain.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/gateway/server-methods/chat.directive-tags.test.ts
  • Scenario the test should lock in: an agent-run final payload with text and a stale local audio path must not append a second assistant transcript message.
  • Why this is the smallest reliable guardrail: the test exercises the WebChat chat.send transcript append seam where the duplicate was created.
  • Existing test that already covers this (if any): resolved auto-TTS media is covered by the adjacent audio-only transcript test.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

Control UI/WebChat should no longer show duplicate text-only assistant replies from stale or non-playable assistant-media/TTS supplements.

Diagram (if applicable)

Before:
agent final text + stale media ref -> assistant-media fallback -> duplicate text transcript message

After:
agent final text + stale media ref -> no resolved media -> no supplemental assistant-media transcript message

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: Windows local dev environment
  • Runtime/container: Node/pnpm local repo checkout
  • Model/provider: Not provider-specific
  • Integration/channel (if any): Control UI / WebChat
  • Relevant config (redacted): agent-run payload with text plus stale local audio media path

Steps

  1. Run WebChat chat.send through the gateway seam with an agent run started.
  2. Emit a final reply payload containing visible text and a stale local audio mediaUrl/mediaUrls.
  3. Inspect emitted assistant transcript updates.

Expected

  • No supplemental :assistant-media assistant transcript message is appended when no playable media resolves.

Actual

  • Before this change, the assistant-media path could append a text-only duplicate of the normal final answer.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What I personally verified:

  • pnpm test src/gateway/server-methods/chat.directive-tags.test.ts -- --reporter=verbose
  • pnpm test src/gateway/server-methods/chat.directive-tags.test.ts -t "does not persist agent media supplements" -- --reporter=verbose
  • pnpm check:changed

Edge cases checked:

  • Resolved auto-TTS media still appends audio-only assistant media content via the existing adjacent test.

What I did not verify:

  • Full pnpm test suite.
  • Browser-driven Control UI manual session.

Note:

  • pnpm test:changed currently fails on unrelated Windows path expectations in src/crestodian/operations.test.ts and src/crestodian/rescue-message.test.ts (/tmp/work vs C:\tmp\work).

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: a malformed media payload might no longer create a text-only supplemental transcript entry.
    • Mitigation: agent final text is already represented by the normal model transcript; command/non-agent media fallback behavior is unchanged.

Supersedes #74501, which used the previous codex-prefixed branch name.

@clawsweeper

clawsweeper Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: the same contributor opened #75481 as the refreshed canonical PR for the same Control UI assistant-media duplicate-reply fix, with the same gateway guard/test plus the missing changelog entry. Current main still has the underlying fallback path, so the product bug should remain tracked through #73956 and #75481 rather than this older branch.

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Review details

Best possible solution:

Close this stale implementation PR and use #75481 as the canonical branch to review, rebase if needed, validate, and land for #73956.

Do we have a high-confidence way to reproduce the issue?

Yes. The linked bug has a concrete reproduction path: an agent-run final payload with visible text plus stale local audio mediaUrl/mediaUrls can fall through to a text-only :assistant-media append on current main.

Is this the best way to solve the issue?

No for this PR as the branch to merge. The code direction is narrow and appropriate, but #75481 is the better path because it refreshes the same fix onto newer main and includes the required changelog entry.

Security review:

Security review cleared: The diff only changes a gateway transcript-append guard and a focused regression test; it adds no dependencies, workflows, permissions, secret handling, package resolution, or code-execution surface.

What I checked:

Likely related people:

  • steipete: Recent GitHub commit history shows repeated maintenance of the gateway chat/media/TTS surface, including adjacent assistant-media/TTS dedupe behavior and tests. (role: recent maintainer and likely follow-up owner; confidence: high; commits: 7829c438a60f, 0113248d917c, 7e41913a203a; files: src/gateway/server-methods/chat.ts, src/gateway/server-methods/chat.directive-tags.test.ts, src/gateway/server-methods/chat-webchat-media.ts)
  • samzong: Authored a recent chat.send media offload change that touched the same gateway chat path and directive-tag tests near this media routing surface. (role: adjacent owner; confidence: medium; commits: 25ef9c0c419d; files: src/gateway/server-methods/chat.ts, src/gateway/server-methods/chat.directive-tags.test.ts, src/gateway/chat-attachments.ts)
  • neeravmakwana: Authored prior Control UI /tts audio WebChat delivery work across the same gateway chat, media helper, transcript injection, UI rendering, and tests. (role: adjacent owner; confidence: medium; commits: 9aaa000da044; files: src/gateway/server-methods/chat.ts, src/gateway/server-methods/chat-webchat-media.ts, src/gateway/server-methods/chat-transcript-inject.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against c38d94677c09.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Control UI duplicates assistant replies via assistant-media delivery path

1 participant