Skip to content

Require reasoning tags to start at line beginning#5

Closed
jannikstdl wants to merge 1 commit intomainfrom
codex/create-solution-proposals
Closed

Require reasoning tags to start at line beginning#5
jannikstdl wants to merge 1 commit intomainfrom
codex/create-solution-proposals

Conversation

@jannikstdl
Copy link
Copy Markdown
Owner

Motivation

  • Reduce false-positive detection of reasoning tags when they appear inline, in prose, or as printed examples so tag parsing only triggers on intended model streaming markers.
  • Preserve previous protection against tags appearing inside fenced code blocks to avoid breaking code samples.
  • Improve robustness of the streaming parser so examples like printed <think>...</think> do not change parsing state.

Description

  • Updated backend/open_webui/utils/middleware.py to add is_tag_at_line_start and require tags to start at the beginning of a line (ignoring leading whitespace).
  • Continued to skip matches inside fenced code blocks using the existing is_inside_fenced_code_block helper.
  • Replaced single re.search with iterating re.finditer so candidate matches can be validated with both fenced-code and line-start checks before accepting.
  • Preserved existing attribute extraction and downstream tag_content_handler behavior when a valid start tag is found.

Testing

  • No automated tests were executed for this change.
  • Changes were added and committed to backend/open_webui/utils/middleware.py without running test suites.

Codex Task

@jannikstdl jannikstdl marked this pull request as draft January 13, 2026 11:01
@jannikstdl jannikstdl closed this Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant