Skip to content

fix(base): strip markdown asterisks in pairs instead of removing all#28731

Open
LifeJiggy wants to merge 1 commit into
NousResearch:mainfrom
LifeJiggy:fix/asterisk-tts-strip
Open

fix(base): strip markdown asterisks in pairs instead of removing all#28731
LifeJiggy wants to merge 1 commit into
NousResearch:mainfrom
LifeJiggy:fix/asterisk-tts-strip

Conversation

@LifeJiggy

Copy link
Copy Markdown
Contributor

Title: fix(base): strip markdown asterisks in pairs instead of removing all

What does this PR do?

prepare_tts_text() in the base gateway adapter used a character-class regex [*_#[]()]that stripped **every** asterisk from text, breaking math expressions like5 * 3 = 15(rendered as5 3 = 15`), pointer notation, and any other literal asterisk usage.

Fix: apply markdown-aware paired-asterisk regexes (***, **, *) before the character-class strip for remaining markdown characters, so that only formatting asterisks are removed while standalone ones survive.

Related Issue

Fixes #28010

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • gateway/platforms/base.py: Replaced re.sub(r'[*_#[]()]', '', text)with three paired-asterisk regexes followed by a reduced character class[_#\[\]()] that no longer includes *

How to Test

  1. Set up a gateway platform with TTS enabled (e.g. Telegram voice replies)
  2. Send a message containing literal asterisks like 5 * 3 = 15 or foo *bar* baz
  3. Before fix: TTS reads "5 3 = 15" (asterisk stripped) and "foo bar baz" (italic stripped)
  4. After fix: TTS reads "5 * 3 = 15" (standalone * preserved) while *italic* still correctly strips markers

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: Windows 11

Documentation & Housekeeping

  • N/A — no config, docs, or schema changes

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery tool/tts Text-to-speech and transcription P3 Low — cosmetic, nice to have labels May 19, 2026
prepare_tts_text used a character-class regex [*_#\[\]()] that stripped
EVERY asterisk from text, breaking math expressions like '5 * 3 = 15'
(rendered as '5  3 = 15') and any other literal asterisk usage.

Fix: apply markdown-aware paired-asterisk regexes (***, **, *) before
the character-class strip for remaining markdown characters, so that
only formatting asterisks are removed while standalone ones survive.

Fixes NousResearch#28010.
@LifeJiggy LifeJiggy force-pushed the fix/asterisk-tts-strip branch from 8c31632 to 384b215 Compare May 19, 2026 16:59
@LifeJiggy

Copy link
Copy Markdown
Contributor Author

@teknium1 PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have tool/tts Text-to-speech and transcription type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: *Asterisk characters () being stripped or replaced in terminal output*

2 participants