← Back to PRs

#17244: fix: strip TTS tags from agent replies before delivery (#14652)

by robbyczgw-cla open 2026-02-15 15:25 View on GitHub →
size: XS experienced-contributor
## 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