Skip to content

πŸ› fix think-block cleanup truncating visible text - #3751

Open
ump45nose wants to merge 1 commit into
ModelEngine-Group:developfrom
ump45nose:fix/preserve-text-before-stray-think-close-3689
Open

πŸ› fix think-block cleanup truncating visible text#3751
ump45nose wants to merge 1 commit into
ModelEngine-Group:developfrom
ump45nose:fix/preserve-text-before-stray-think-close-3689

Conversation

@ump45nose

Copy link
Copy Markdown

Summary

  • require a matched <think>...</think> pair before removing content
  • preserve visible text before stray closing tags and between multiple think blocks
  • correct the focused regression expectations for both cases

Why

The optional opening tag allowed .*?</think> to consume ordinary model output. A malformed provider response containing only </think> could therefore silently truncate everything before it.

Fixes #3689.

Tests

  • python3 focused assertions covering 6 think-block cases
  • python3 -m py_compile backend/utils/str_utils.py test/backend/utils/test_str_utils.py
  • git diff --check

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.

remove_think_blocks regex deletes content that is not in a <think> block

1 participant