← Back to PRs

#16089: fix(tts): clarify directive syntax in prompts and strip malformed tags

by kmixter open 2026-02-14 08:11 View on GitHub →
channel: whatsapp-web agents stale size: S
## Summary The system prompt hint for TTS directives was vague (`[[tts:...]]`), leading models to invent unsupported syntax like `[[tts:soft]]` or emit orphan `[[/tts:text]]` closing tags that get read aloud verbatim. This PR: - Replaces the vague hint with explicit key=value examples and available parameter names (stability, style, speed, similarityBoost) - Warns when models use bare directives without key=value format - Strips orphan `[[/tts:*]]` closing tags that leak through to the TTS engine - Parses directives in the TTS tool path so tags in tool call text are cleaned before synthesis ## Test plan - [x] Added tests for orphan closing tag stripping (end-of-text and mid-text) - [x] Added assertion that paired block tags do not leak closing tags - [x] All 37 TTS tests pass - [x] Tested live via WhatsApp Generated with [Claude Code](https://claude.com/claude-code) <!-- greptile_comment --> <h3>Greptile Summary</h3> Improved TTS directive parsing to prevent malformed tags from being read aloud. Replaced vague system prompt hint with explicit key-value syntax examples, added orphan closing tag stripping, and warns models when using unsupported bare directives. - Updated system prompt to show explicit parameters (like `stability`, `style`, `speed`, `similarityBoost`) with examples - Strips orphan closing tags that models sometimes emit without matching openers - Warns when models use bare directives instead of required key-value format - Integrated directive parsing in tts-tool so tags in tool call text are cleaned before synthesis - Tests cover orphan tag stripping at end-of-text and mid-text positions <h3>Confidence Score: 5/5</h3> - Safe to merge - focused fix with comprehensive test coverage - The changes are well-contained, defensive (adding fallback stripping), and thoroughly tested with 37 passing tests. The implementation correctly handles edge cases like orphan tags and bare directives, improving UX without breaking existing functionality. - No files require special attention <sub>Last reviewed commit: cb2ca7e</sub> <!-- greptile_other_comments_section --> <sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs