Skip to content

Fix duplicate Control UI assistant-media replies - #75481

Merged
BunsDev merged 2 commits into
openclaw:mainfrom
HemantSudarshan:hemant/73956-webchat-assistant-media-dedupe-refresh
May 2, 2026
Merged

BunsDev merged 2 commits into
openclaw:mainfrom
HemantSudarshan:hemant/73956-webchat-assistant-media-dedupe-refresh

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 stale media references no longer resolved to playable content.
  • 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: refreshed Fix duplicate Control UI assistant-media replies #74502 onto current main, kept the agent-run assistant-media transcript append gated on resolved display media, and added a changelog entry.
  • 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 transcript/display/payload 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 (not just CI), and how:

  • Verified scenarios:
    • pnpm test src/gateway/server-methods/chat.directive-tags.test.ts -t "does not persist agent media supplements" -- --reporter=verbose
    • pnpm test src/gateway/server-methods/chat.directive-tags.test.ts -- --reporter=verbose
    • pnpm exec oxfmt --check --threads=1 src/gateway/server-methods/chat.ts src/gateway/server-methods/chat.directive-tags.test.ts
    • pnpm check:changelog-attributions
    • git diff --check upstream/main...HEAD
    • Changed-gate equivalent from the exported plan: common guards, direct tsgo core/core-test, lint:core, runtime sidecar loader guard, import-cycle guard, webhook body guard, and pairing auth guards.
  • Edge cases checked: resolved auto-TTS media still appends audio-only assistant media content via the adjacent file-level test; non-agent command TTS still preserves visible text.
  • What I did not verify: full pnpm test suite; browser-driven Control UI manual session; Testbox, because blacksmith is not installed in this checkout.

Note: local pnpm check:changed did not execute normally on this Windows path because the script direct-run guard/path handling returned no plan and the tsgo wrapper splits C:\Projects\Personal Project\... at the space. I ran the same changed-gate plan through the exported modules and bypassed only the Windows shell quoting layer for tsgo.

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.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: XS labels May 1, 2026
@clawsweeper

clawsweeper Bot commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR skips agent-run WebChat assistant-media transcript appends when resolved display media is empty, adds a stale-media regression test, and adds an Unreleased changelog fix.

Reproducibility: yes. A source-level reproduction is an agent-run chat.send final payload with visible text and a stale trusted local audio mediaUrl/mediaUrls; current main can resolve no playable media and still append fallback text through the :assistant-media path.

Next step before merge
No repair lane is needed because the PR already contains the focused code change, regression coverage, and changelog entry; maintainer review and CI should gate merge.

Security
Cleared: The diff only changes a gateway transcript append guard, a focused regression test, and changelog text; it does not alter dependencies, workflows, permissions, secrets, package resolution, or code execution surfaces.

Review details

Best possible solution:

Land this narrow gateway fix after exact-head CI/changed-gate validation, while keeping the broader inline-media work in #75727 separate.

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

Yes. A source-level reproduction is an agent-run chat.send final payload with visible text and a stale trusted local audio mediaUrl/mediaUrls; current main can resolve no playable media and still append fallback text through the :assistant-media path.

Is this the best way to solve the issue?

Yes. Requiring resolved non-text media before appending the agent-run assistant-media supplement is the narrowest maintainable fix, and the separate non-agent media path still preserves visible text.

What I checked:

Likely related people:

  • steipete: Prior review context ties recent main history for the WebChat audio/media supplemental transcript path and adjacent gateway chat media behavior to this maintainer. (role: recent maintainer and likely follow-up owner; confidence: high; commits: 7829c438a60f, 54731492a285, 0113248d917c; files: src/gateway/server-methods/chat.ts, src/gateway/server-methods/chat.directive-tags.test.ts, docs/web/control-ui.md)
  • BunsDev: Prior review context and current-main history show recent Control UI/media reply hardening and WebChat continuity work touching the same gateway/media surfaces. (role: adjacent owner; confidence: medium; commits: 43a941b51c16, 1cf68b9243aa, cb9d7884cca3; files: src/gateway/server-methods/chat.ts, src/gateway/server-methods/chat-webchat-media.ts, src/gateway/server-methods/chat.directive-tags.test.ts)

Remaining risk / open question:

  • Exact PR-head CI and changed-gate validation were not rerun in this read-only review; merge should still rely on normal CI for the latest head.

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

@BunsDev BunsDev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for the assistant-media duplicate-reply fix.

Reviewed the refreshed head 38e4dc2299e3929eec42589c37ff75c075321c91. The patch keeps the fix scoped to the agent-run assistant-media transcript supplement: stale/non-playable media refs no longer append a text-only gateway-injected assistant message, while resolved media supplements and non-agent command/TTS fallback behavior remain covered by adjacent tests.

Validation I ran:

  • pnpm test src/gateway/server-methods/chat.directive-tags.test.ts -- --reporter=verbose
  • pnpm exec oxfmt --check --threads=1 src/gateway/server-methods/chat.ts src/gateway/server-methods/chat.directive-tags.test.ts CHANGELOG.md
  • pnpm check:changelog-attributions
  • git diff --check origin/main...HEAD
  • Testbox pnpm check:changed, plus exact-head CI sampling

Remaining CI failures are unrelated to this PR's touched files:

  • check-test-types: src/agents/subagent-registry-lifecycle.test.ts mock type mismatch
  • check-dependencies: unrelated dependency scan failure in src/auto-reply/reply/session-fork.runtime.ts

Not merging in this review step because the aggregate CI is still red on unrelated lanes and main merge requires explicit maintainer approval.

@BunsDev
BunsDev force-pushed the hemant/73956-webchat-assistant-media-dedupe-refresh branch 2 times, most recently from eb001ff to e67a9be Compare May 2, 2026 04:50
@BunsDev
BunsDev force-pushed the hemant/73956-webchat-assistant-media-dedupe-refresh branch from e67a9be to 24d1e2c Compare May 2, 2026 05:07
@BunsDev
BunsDev merged commit d5dbc45 into openclaw:main May 2, 2026
97 of 101 checks passed
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

2 participants