Skip to content

fix(cli): keep snake_case underscores intact in strip markdown mode#13652

Merged
jquesnelle merged 2 commits into
NousResearch:mainfrom
IAvecilla:fix-underscore-display
Apr 21, 2026
Merged

fix(cli): keep snake_case underscores intact in strip markdown mode#13652
jquesnelle merged 2 commits into
NousResearch:mainfrom
IAvecilla:fix-underscore-display

Conversation

@IAvecilla

Copy link
Copy Markdown
Contributor

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_case showed up as snaketest_case. The culprit is _strip_markdown_syntax in cli.py, whose underscore emphasis regexes lacked word-boundary lookarounds and so matched _with_ as italic inside any snake_case token. Since final_response_markdown defaults 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-tui INLINE_RE / stripInlineMarkup design.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

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: added test_strip_mode_preserves_intraword_underscores_in_snake_case_identifiers and test_strip_mode_still_strips_boundary_underscore_emphasis to 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 an estimateRows test confirming recover_with_credential_pool no 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:

  • New tests have been added in test_cli_markdown_rendering.py and markdown.test.ts

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
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: macOS (Darwin 25.3.0)

Documentation & Housekeeping

  • I've updated relevant documentation
  • I've updated cli-config.yaml.example
  • I've updated CONTRIBUTING.md / AGENTS.md
  • I've considered cross-platform impact
    and JS regex lookbehinds are both supported on all supported
    runtimes; no platform-specific code touched.
  • I've updated tool descriptions/schemas

@jquesnelle jquesnelle merged commit ce98e1e into NousResearch:main Apr 21, 2026
6 of 7 checks passed
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Apr 21, 2026
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants