fix(cli): keep snake_case underscores intact in strip markdown mode#13652
Merged
Conversation
This was referenced Apr 21, 2026
Closed
ulasbilgen
pushed a commit
to ulasbilgen/hermes-adhd-agent
that referenced
this pull request
May 1, 2026
…isplay fix(cli): keep snake_case underscores intact in strip markdown mode
aj-nt
pushed a commit
to aj-nt/hermes-agent
that referenced
this pull request
May 1, 2026
…isplay fix(cli): keep snake_case underscores intact in strip markdown mode
Luminet2023
pushed a commit
to Luminet2023/hermes-agent
that referenced
this pull request
May 1, 2026
…isplay fix(cli): keep snake_case underscores intact in strip markdown mode
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
…isplay fix(cli): keep snake_case underscores intact in strip markdown mode
12 tasks
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
…isplay fix(cli): keep snake_case underscores intact in strip markdown mode
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
…isplay fix(cli): keep snake_case underscores intact in strip markdown mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes a bug where snake_case identifiers in streamed assistant output were rendered with underscores eaten e.g.
snake_test_caseshowed up assnaketest_case. The culprit is_strip_markdown_syntaxincli.py, whose underscore emphasis regexes lacked word-boundary lookarounds and so matched_with_as italic inside any snake_case token. Sincefinal_response_markdowndefaults to"strip", every streamed line flowed through this path.The fix adds
(?<!\w)...(?!\w)to the three underscore rules so they only match at real word boundaries, matching CommonMark and the existing ui-tuiINLINE_RE/stripInlineMarkupdesign.Type of Change
Changes Made
cli.py(_strip_markdown_syntax, lines ~1157-1162): added(?<!\w)...(?!\w)lookarounds to the_,__, and___emphasis regexes. Asterisk rules unchanged.tests/cli/test_cli_markdown_rendering.py: addedtest_strip_mode_preserves_intraword_underscores_in_snake_case_identifiersandtest_strip_mode_still_strips_boundary_underscore_emphasisto lock the behavior both ways.ui-tui/src/lib/text.ts(renderEstimateLine, lines 27-30): added the same lookarounds to the_/__rules so row estimation matches the rendering regex.ui-tui/src/__tests__/text.test.ts: added anestimateRowstest confirmingrecover_with_credential_poolno longer miscounts rows.How to Test
Ask: *"Please say the literal string snake_test_case and the path /tmp/snake_case_dir/file_with_name.py in a sentence, All underscores should not be displayed in the current version of hermes chat and they should be visible using the changes in this PR
Unit coverage:
test_cli_markdown_rendering.pyandmarkdown.test.tsChecklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping
cli-config.yaml.exampleCONTRIBUTING.md/AGENTS.mdand JS regex lookbehinds are both supported on all supported
runtimes; no platform-specific code touched.