Skip to content

fix: strip <thought> tags from Gemma 4 responses#8562

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-fb3754b0
Apr 12, 2026
Merged

fix: strip <thought> tags from Gemma 4 responses#8562
teknium1 merged 3 commits into
mainfrom
hermes/hermes-fb3754b0

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Gemma 4 (26B/31B) wraps inline reasoning in <thought>...</thought> tags, which were leaking into visible responses. Salvaged from PR #6149 by @Unayung.

Changes

Test results

TestStripThinkBlocks: 10 passed

Fixes #6148. Salvaged from #6149 — contributor commits cherry-picked with authorship preserved.

Unayung and others added 3 commits April 12, 2026 12:37
Gemma 4 (26B/31B) uses <thought>...</thought> to wrap its reasoning
output. This tag was not included in the existing list of reasoning tag
variants stripped by _strip_think_blocks(), causing raw thinking blocks
to leak into the visible response.

Added a new re.sub() line for <thought> and extended the cleanup regex
to include 'thought' alongside the existing variants.

Fixes #6148
auxiliary_client.py had its own regex mirroring _strip_think_blocks
but was missing the <thought> variant. Also adds test coverage for
<thought> paired and orphaned tags.
@teknium1 teknium1 merged commit 400fe9b into main Apr 12, 2026
4 of 6 checks passed
@teknium1 teknium1 deleted the hermes/hermes-fb3754b0 branch April 12, 2026 19:44
dev-xyz-0-0 added a commit to dev-xyz-0-0/hermes-agent that referenced this pull request Apr 30, 2026
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.

[Bug]: <thought> tags from Gemma 4 not stripped from response content

2 participants