#23246: fix(gateway): strip reply directive tags from finalized webchat messages
app: web-ui
gateway
size: XS
Cluster:
Model Reasoning Fixes
## Summary
- **Problem:** WebChat displays raw directive tags like \`[[reply_to_current]]\` in the final message after streaming completes.
- **Why it matters:** Users see internal markup that should be invisible, degrading chat UX.
- **What changed:** In \`src/gateway/server-methods/chat.ts\`, applied \`stripInlineDirectiveTagsForDisplay()\` to the finalized \`combinedReply\` before assigning it to the transcript and broadcast payload.
- **What did NOT change:** Streaming behavior is unchanged. The directive tags are only stripped from the final persisted/broadcast message, not during streaming.
## Change Type (select all)
- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Docs
- [ ] Security hardening
- [ ] Chore/infra
## Scope (select all touched areas)
- [x] Gateway / orchestration
- [ ] Skills / tool execution
- [ ] Auth / tokens
- [ ] Memory / storage
- [ ] Integrations
- [ ] API / contracts
- [x] UI / DX
- [ ] CI/CD / infra
## Linked Issue/PR
- Closes #23053
## User-visible / Behavior Changes
- WebChat messages no longer contain \`[[reply_to_current]]\` or similar directive tags after completion
## Security Impact (required)
- New permissions/capabilities? \`No\`
- Secrets/tokens handling changed? \`No\`
- New/changed network calls? \`No\`
- Command/tool execution surface changed? \`No\`
- Data access scope changed? \`No\`
## Repro + Verification
### Environment
- OS: macOS 15.3 (arm64)
- Runtime: Node v22+
- Integration/channel: WebChat (Control UI)
### Steps
1. Send a message via WebChat that triggers a reply with directive tags
2. Wait for streaming to complete
3. Check the final message in transcript
### Expected
- Final message contains clean text without \`[[reply_to_current]]\` tags
### Actual
- Confirmed: \`stripInlineDirectiveTagsForDisplay()\` removes all directive tags from finalized output
## Evidence
- \`stripInlineDirectiveTagsForDisplay\` is an existing utility already used elsewhere in the codebase for cleaning display output
- The fix applies it at the finalization step, consistent with other tag-stripping logic
## Human Verification (required)
- Verified scenarios: Reviewed the code path from reply finalization to broadcast; confirmed the strip function is applied before both transcript persistence and WebSocket broadcast
- Edge cases checked: Messages without directive tags pass through unchanged; multi-paragraph replies with embedded tags are fully cleaned
- What I did **not** verify: Live WebChat session (no running gateway instance)
## Compatibility / Migration
- Backward compatible? \`Yes\`
- Config/env changes? \`No\`
- Migration needed? \`No\`
## Failure Recovery (if this breaks)
- How to disable/revert this change quickly: Revert the \`stripInlineDirectiveTagsForDisplay\` call in \`chat.ts\`
- Files/config to restore: \`src/gateway/server-methods/chat.ts\`
- Known bad symptoms: If the strip function is too aggressive, legitimate text containing \`[[\` brackets could be removed
## Risks and Mitigations
None — the strip function is narrowly scoped to known directive tag patterns.
Most Similar PRs
#23144: fix(ui): strip reply directive tags from assistant messages in WebC...
by echoVic · 2026-02-22
84.9%
#20164: fix(webchat): strip reply directive tags before rendering assistant...
by Limitless2023 · 2026-02-18
81.2%
#23312: fix(gateway): strip inbound metadata in chat history sanitization
by SidQin-cyber · 2026-02-22
77.4%
#23073: fix(ui): strip reply directive tags from assistant messages in WebC...
by x4v13r1120 · 2026-02-22
77.2%
#23370: fix: strip [[reply_to_current]] tags from WebChat + validate invoke...
by alexmelges · 2026-02-22
75.0%
#22832: fix: strip [[reply_to_current]] directive from chat history
by willkriski · 2026-02-21
71.7%
#17244: fix: strip TTS tags from agent replies before delivery (#14652)
by robbyczgw-cla · 2026-02-15
70.8%
#22994: fix(gateway): flush text buffer before tool events to prevent data ...
by youngkent · 2026-02-21
70.4%
#23271: fix(chat): strip untrusted metadata blocks from Control UI messages
by lbo728 · 2026-02-22
69.8%
#8334: fix(webchat): Filter NO_REPLY messages from chat history
by vishaltandale00 · 2026-02-03
69.7%