Skip to content

fix: don't delete ordinary bold reasoning text that looks like an OpenRouter phase label - #479

Closed
Satya Arjunan (satya-arjunan) wants to merge 1 commit into
synthetic-sciences:mainfrom
satya-arjunan:fix/reasoning-bold-text-deletion
Closed

Satya Arjunan (satya-arjunan) wants to merge 1 commit into
synthetic-sciences:mainfrom
satya-arjunan:fix/reasoning-bold-text-deletion

Conversation

@satya-arjunan

@satya-arjunan Satya Arjunan (satya-arjunan) commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #480

Problem

reasoningDisplayText() (frontend/ui/src/components/tool-display.ts) strips OpenRouter's concatenated provider-summary phase headings from reasoning text before rendering — its doc comment explains the shape: "Each summary phase starts with a bold label, but adjacent phases are not guaranteed to include a separator (...done.**Next**)."

The regex matching those headings had no check confirming a bold span is actually one of them:

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

It matches any **bold** span anywhere in reasoning text, from any provider, and replaces it with "\n\n" — deleting it entirely while leaving the surrounding text untouched. Confirmed against a real session: a direct (non-OpenRouter) provider's reasoning contained completely ordinary inline emphasis —

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

— and the bold span vanished from the rendered UI, leaving the text stopping after "about", a blank line, then ": featureCounts works best...". Checked the raw stored message data first: the model's actual output was completely intact — this is purely a display bug in reasoningDisplayText, not anything wrong with generation or storage.

Fix

OpenRouter's concatenated headings never have whitespace before the opening ** — they touch the previous phase's closing punctuation directly (done.**Next**), or start the string. Ordinary inline emphasis in real prose always has a space before it. That's a clean, provider-agnostic signal to distinguish the two shapes without threading provider identity through the render tree:

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

Requires the match to be at the start of the text or immediately preceded by a non-whitespace character.

Verification

  • All existing tests for this function still pass unchanged — every documented OpenRouter-shaped case (**Evaluating Titanic dataset analysis**..., ...started!**Choosing a reputable Titanic dataset**, **Inspecting assay quality**\n...) is preceded by either start-of-string or punctuation with no space, so none of them regress.
  • New regression test using the exact reported string, asserting it passes through unchanged.
  • bun run typecheck (frontend/ui) — clean.

…nRouter phase label

reasoningDisplayText() strips OpenRouter's concatenated provider-summary
phase headings ("...done.**Next**") from reasoning text before rendering.
The regex matched any **bold** span anywhere in the text unconditionally,
with no check that it's actually one of those headings - so a completely
ordinary bold span in a direct (non-bridged) provider's reasoning, e.g.
"Let me also make sure about **featureCounts GTF requirement**: ...", got
silently deleted and replaced with a blank line, while the text immediately
before and after it rendered fine. The model's actual output was intact in
storage; only the UI display was wrong.

Confirmed against raw stored data before diagnosing this as a rendering
bug, not a generation bug.

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 does.
Scopes the regex to only match at the start of the text or immediately
after a non-whitespace character, which distinguishes the two shapes
without needing to thread provider identity through the render tree.
Verified against all existing OpenRouter-shaped test cases (still pass
unchanged) plus a new regression test for the exact reported case.
@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown

Satya Arjunan (@satya-arjunan) is attempting to deploy a commit to the InkVell Team on Vercel.

A member of the Team first needs to authorize it.

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.

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

2 participants