fix(agents): respect markdown code spans when stripping thinking tags#939
Closed
ngutman wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix(agents): respect markdown code spans when stripping thinking tags#939ngutman wants to merge 1 commit intoopenclaw:mainfrom
ngutman wants to merge 1 commit intoopenclaw:mainfrom
Conversation
The stripBlockTags function in pi-embedded-subscribe.ts was incorrectly matching <thinking> tags inside markdown code spans (backticks), causing message content to be truncated. For example, a message like: 'fixes leaked `<thinking>` tags' would have everything after the backtick-enclosed <thinking> stripped, because the regex didn't understand markdown context. Changes: - Added findCodeSpanRanges() helper to identify inline code (`) and fenced code blocks (```) in text - Added isInsideCodeSpan() helper to check if an index falls within code spans - Modified stripBlockTags() to skip thinking tag matches that fall inside code spans - Added 3 tests for the new behavior Fixes message truncation when discussing thinking tags in code examples.
Contributor
|
Ha what model was that? That's some hacky slop xD |
Contributor
|
Appreciate the bug report tho! |
Contributor
Author
|
@steipete running slopus - anthropic/claude-opus-4-5 🙈 |
Contributor
Author
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.
Summary
The
stripBlockTagsfunction inpi-embedded-subscribe.tswas incorrectly matching<thinking>tags inside markdown code spans (backticks), causing message content to be truncated.For example, a message like:
would have everything after the backtick-enclosed
<thinking>stripped, because the regex did not understand markdown context.Changes
findCodeSpanRanges()helper to identify inline code (`) and fenced code blocks (```) in textisInsideCodeSpan()helper to check if an index falls within code spansstripBlockTags()to skip thinking tag matches that fall inside code spansTest Plan
Context
When discussing code changes related to thinking tags (e.g., documenting what was fixed), the streaming output would be incorrectly truncated.
🤖 Generated with Clawdbot