Skip to content

fix: platform base extract_images and truncate_message bugs - #200

Merged
teknium1 merged 1 commit into
NousResearch:mainfrom
0xbyt4:fix/platform-base-bugs-and-tests
Mar 5, 2026
Merged

fix: platform base extract_images and truncate_message bugs#200
teknium1 merged 1 commit into
NousResearch:mainfrom
0xbyt4:fix/platform-base-bugs-and-tests

Conversation

@0xbyt4

@0xbyt4 0xbyt4 commented Feb 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • extract_images(): Only remove extracted image tags from content. Previously, when at least one image was found, ALL markdown image tags were removed — including non-image links like ![doc](https://example.com/report.pdf) which were silently lost.
  • truncate_message(): Walk only chunk_body (not the prepended reopening prefix) when tracking code block state. The reopened fence (\``python) was being counted by the line-walking loop, toggling in_code` off and leaving continuation chunks with unclosed code blocks.

Test plan

  • 49 unit tests added covering:
    • MessageEvent: is_command, get_command, get_command_args
    • extract_images: markdown/HTML patterns, CDN URLs, non-image preservation (regression)
    • extract_media: MEDIA tags, [[audio_as_voice]] directive
    • truncate_message: splitting, chunk indicators, code block fence balancing (regression)
    • _get_human_delay: off/natural/custom modes
  • Full test suite passes (725 passed)

- extract_images: only remove extracted image tags from content, preserve
  non-image markdown links (e.g. PDFs) that were previously silently lost
- truncate_message: walk only chunk_body (not prepended prefix) so the
  reopened code fence does not toggle in_code off, leaving continuation
  chunks with unclosed code blocks
- Add 49 unit tests covering MessageEvent command parsing, extract_images,
  extract_media, truncate_message code block handling, and _get_human_delay
@teknium1

teknium1 commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Merged in commit 4fcfa32. Both fixes verified — extract_images now preserves non-image markdown links, and truncate_message correctly tracks code block state across chunks. All 1529 tests pass including 49 new ones. Nice catches! 🙏

@teknium1
teknium1 merged commit 4fcfa32 into NousResearch:main Mar 5, 2026
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…gs in platform base

Authored by 0xbyt4.

Two fixes:
- extract_images(): only remove extracted image tags, not all markdown image
  tags. Previously ![doc](report.pdf) was silently dropped when real images
  were also present.
- truncate_message(): walk chunk_body not full_chunk when tracking code block
  state, so the reopened fence prefix doesn't toggle in_code off and leave
  continuation chunks with unclosed code blocks.
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…gs in platform base

Authored by 0xbyt4.

Two fixes:
- extract_images(): only remove extracted image tags, not all markdown image
  tags. Previously ![doc](report.pdf) was silently dropped when real images
  were also present.
- truncate_message(): walk chunk_body not full_chunk when tracking code block
  state, so the reopened fence prefix doesn't toggle in_code off and leave
  continuation chunks with unclosed code blocks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants