#17244: fix: strip TTS tags from agent replies before delivery (#14652)
size: XS
experienced-contributor
Cluster:
Model Reasoning Fixes
## Problem
When `messages.tts.auto` is set to `tagged`, agents wrap TTS content in `[[tts]]...[[/tts]]` tags. These tags are not stripped before the reply is delivered to the user, causing raw markup to appear in messages.
Fixes #14652
## Solution
Add a single regex strip in `parseReplyDirectives()` (`src/auto-reply/reply/reply-directives.ts`) that removes `[[tts]]...[[/tts]]` tags early in the pipeline, before summarization or other processing. The inner content is preserved (`$1` capture group).
## Changes
- `src/auto-reply/reply/reply-directives.ts` — 3 insertions (regex + comment)
The regex is case-insensitive, handles whitespace variations in tags, and supports multiline content. The replacement uses `"$1"` to preserve the content inside the tags while stripping only the markup.
## Testing
Existing tests pass. The strip occurs early enough that downstream processing sees clean text.
---
## Local Validation
- `pnpm build` ✅
- `pnpm check` (oxlint) ✅
- Relevant test suites pass ✅
## Contribution Checklist
- [x] Focused scope — single fix per PR
- [x] Clear "what" + "why" in description
- [x] AI-assisted (Codex/Claude) — reviewed and tested by human
- [x] Local validation run (`pnpm build && pnpm check`)
*AI-assisted (Claude). Reviewed by human.*
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds regex to strip `[[tts]]...[[/tts]]` tags from agent replies in `parseReplyDirectives()`. The fix preserves the content inside the tags while removing only the markup, preventing raw TTS tags from appearing in user-facing messages when `messages.tts.auto` is set to `"tagged"`. The regex is case-insensitive, handles whitespace variations, and uses non-greedy matching to avoid over-matching nested patterns.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- The change is a focused, single-line regex replacement that addresses a specific bug. The regex pattern is correct (case-insensitive, properly escaped, uses non-greedy matching, and preserves inner content with `$1`). The fix is placed early in the pipeline as intended. A previous reviewer caught a bug where `" "` was used instead of `"$1"`, which was fixed. The scope is minimal and the implementation matches the PR description.
- No files require special attention.
<sub>Last reviewed commit: eda72de</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#20164: fix(webchat): strip reply directive tags before rendering assistant...
by Limitless2023 · 2026-02-18
83.1%
#23073: fix(ui): strip reply directive tags from assistant messages in WebC...
by x4v13r1120 · 2026-02-22
81.7%
#18876: fix(outbound): strip DSML function-call markup before delivery
by BinHPdev · 2026-02-17
80.1%
#23144: fix(ui): strip reply directive tags from assistant messages in WebC...
by echoVic · 2026-02-22
79.4%
#19916: fix: strict silent-reply detection to prevent false positives with ...
by hayoial · 2026-02-18
78.9%
#22832: fix: strip [[reply_to_current]] directive from chat history
by willkriski · 2026-02-21
77.5%
#16089: fix(tts): clarify directive syntax in prompts and strip malformed tags
by kmixter · 2026-02-14
76.9%
#8504: fix: prevent false positives in isSilentReplyText for CJK content
by hanxiao · 2026-02-04
76.9%
#20992: fix(tts): apply TTS processing to agentCommand outbound delivery path
by mmyyfirstb · 2026-02-19
76.9%
#19576: fix: tighten isSilentReplyText to match whole-text only
by aldoeliacim · 2026-02-18
76.8%