Skip to content

Ordinary bold reasoning text is silently deleted if it looks like an OpenRouter phase label #480

Closed

Description

Summary

Ordinary bold text (**like this**) inside a model's reasoning/thinking output can silently vanish from the rendered UI — the text immediately before and after it renders fine, but the bold span itself disappears, leaving a blank gap. The model's actual output is completely unaffected; this is purely a display bug.

Real example

A local Ollama-served model's reasoning contained:

Let me also make sure about featureCounts GTF requirement: featureCounts works best with a GFF/GTF that has gene/transcript features...

Rendered in the UI, this appeared as the line stopping after "Let me also make sure about", a blank line, then the next line starting with ": featureCounts works best...". Checked the raw stored message data directly before concluding this was a rendering issue — the text is stored completely intact; the bug is entirely in reasoningDisplayText().

Root cause

frontend/ui/src/components/tool-display.ts:

const providerReasoningPhase = /\*\*([^*\n]+)\*\*(?:\r?\n[ \t]*)*/g

This exists (per its own doc comment) to strip OpenRouter's concatenated provider-summary phase headings from reasoning text — headings shaped like ...done.**Next** with no separator between adjacent phases. But the regex has no check confirming a given bold span actually is one of those headings; it matches any **bold** text anywhere in reasoning content, from any provider, and unconditionally replaces the match with "\n\n" — deleting the bold span itself while everything around it survives untouched.

Fix

Opened #479 with a minimal, provider-agnostic fix: OpenRouter's concatenated headings never have whitespace before the opening ** (they touch the previous phase's closing punctuation directly, or start the string) — ordinary inline emphasis in real prose always has a space before it. Scoping the match to require start-of-text or a preceding non-whitespace character distinguishes the two shapes cleanly, verified against every existing test case for this function (all unchanged) plus a new regression test for the exact case above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions