Skip to content

fix(tool_parsing): Qwen bare-marker regex strips remove \nend\n #5548

Open
shuwudow wants to merge 1 commit into
odysseus-dev:devfrom
shuwudow:fix/qwen-bare-marker-strips-end-keyword
Open

fix(tool_parsing): Qwen bare-marker regex strips remove \nend\n #5548
shuwudow wants to merge 1 commit into
odysseus-dev:devfrom
shuwudow:fix/qwen-bare-marker-strips-end-keyword

Conversation

@shuwudow

Copy link
Copy Markdown

Summary

Chat messages that have end statements, for example in the context of coding languages, cut off the \nend\n part.
The QWEN_BARE_MARKER_RE regex used optional pipe delimiters around end (\|?end\|?), which matched the bare keyword end on its own line. Chat messages containing Ruby code that closes blocks with a lone end — had those lines stripped from the rendered message in the front-end. The \nend\n part disappeared both from sent and received messages.

Fix: require the pipes (|end|) so the pattern only matches Qwen's actual turn marker. The |end| and /|end| cases still strip correctly, so Qwen artifact cleanup is unchanged.

Applied to the duplicate regex in both src/tool_parsing.py (backend) and static/js/chatRenderer.js (frontend).

Target branch

  • This PR targets dev, not main.

Linked Issue

Fixes #5547

Linked to #5546 because both commits modify the same file (tool_parsing.py), however changed areas do not match.

Type of Change

  • Bug fix (non-breaking — fixes a confirmed issue)
  • New feature (non-breaking — adds new behaviour)
  • Breaking change (changes or removes existing behaviour)
  • Refactor / cleanup (behaviour unchanged)
  • Documentation only
  • CI / tooling / configuration

Checklist

  • I searched open issues and open PRs — this is not a duplicate.
  • This PR targets dev
  • My changes are limited to the scope described above — no unrelated refactors or whitespace changes mixed in.
  • I actually ran the app (docker compose up or uvicorn app:app) and verified the change works end-to-end. Type-checks and unit tests are not enough.

How to Test

  1. Start via docker compose up -d --build
  2. Paste snippet, for example:
loop do
    puts "yo"
end
  1. After sending out the message, the end fragment shouldn't disappear anymore.

Since this change affects qwen models, I must mention that I verified its originally intended stripping functionality only by AI agent, I rebuilt Docker image, agent ran runtime regex substitution tests (Python + JS) showing bare end is preserved while |end|, /|end|>, </|end|>, and bare assistant are still stripped identically to pre-fix.
I did not test live Qwen model end-to-end. Should be Qwen-compatible — real Qwen markers are wrapped in | characters (like |end|), and those are still stripped correctly, unless I'm missing something.

Visual / UI changes — REQUIRED if you touched anything that renders

Anything that changes what the UI looks like — buttons, icons, padding, colors, fonts, spacing, layout, CSS, HTML, SVG, or any static/js/ module that draws to the DOM — needs all of the following. PRs that change rendering without these WILL be closed.

  • Screenshot or short clip of the change in the running app, attached below. Mobile screenshot too if the change affects mobile.
  • Style match: the change uses Odysseus's existing visual language. Specifically:
    • Reuse existing CSS variables (--red, --fg, --bg, --card, --border, etc.) — do not introduce new color values, font sizes, or spacing units.
    • Reuse existing button/input/card/border classes. Don't invent parallel styling.
    • No Unicode emoji in UI or code. Use inline SVG (matching the monochrome icon style already in static/index.html) or plain text.
    • Monospaced font (Fira Code) for primary UI text. Don't override.
    • Dark theme is the default; any light-mode work must be wired through the existing theme system, not hard-coded.
  • No new component patterns. If a similar widget already exists in the app, extend it instead of writing a parallel one.
  • I am not an LLM agent submitting a bulk PR. It is human-reviewed fix, used an agent one to spot it.

Screenshots / clips

before:
before

after:
after

…\nend\n` disappear

Chat messages that have end statements, for example in the context of coding languages,
cut off the "\nend\n" part which is not seen in front-end. Changed similar function
parsing lines in both tool_parsing.py and in chatRenderer.js.

Fix: require the pipes (`|end|`) so only Qwen's actual turn marker
matches. The `|end|` and `/|end|` cases still strip correctly, so
Qwen artifact cleanup SHOULD be left unchanged.
@github-actions github-actions Bot added the ready for review Description complete — ready for maintainer review label Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Description complete — ready for maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: end keywords are stripped

1 participant