[PR #2093] [CLOSED] fix: preserve content after inline thinking blocks #5433

Closed
opened 2026-10-22 04:16:16 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2093
Author: @lemontaffy
Created: 6/3/2026
Status: ❌ Closed

Base: staging ← Head: fix/thinking-parser-empty-content


📝 Commits (10+)

  • 19411f3 Fix mobile composer text input collapse (#1136)
  • 77a30fa Fix tracker aliases, avatars, HUD temps, and changelog (#1137)
  • e85da38 Reduce chat startup and focus refetch lag
  • 10b6330 Revert "Reduce chat startup and focus refetch lag"
  • 1ab4c3f Register pre-alpha workflow on default branch
  • 1f7b25a Merge pull request #1382 from munimunigamer/ci/register-prealpha-workflow
  • 389a682 Add Bunny review command bootstrap (#1821)
  • 9e96048 Register Bunny auto review dispatcher on main (#1872)
  • c49f1d9 Enable Bunny dispatch for draft PRs (#2026)
  • 4e62759 fix(llm): preserve reply text after inline reasoning close tag

📊 Changes

16 files changed (+888 additions, -76 deletions)

View changed files

➕ .github/workflows/bunny-review-auto.yml (+38 -0)
➕ .github/workflows/bunny-review-command.yml (+96 -0)
➕ .github/workflows/prealpha-platform-builds.yml (+335 -0)
📝 CHANGELOG.md (+16 -0)
📝 packages/client/src/components/chat/ConversationInput.tsx (+5 -5)
📝 packages/client/src/components/chat/RoleplayHUD.tsx (+19 -37)
📝 packages/client/src/components/panels/SettingsPanel.tsx (+1 -1)
📝 packages/client/src/components/panels/settings/TrackerCardColorSettings.tsx (+17 -11)
📝 packages/client/src/features/tracker-panel/hooks/use-tracker-sprite-lookup.ts (+11 -6)
📝 packages/client/src/features/tracker-panel/lib/tracker-metadata.ts (+31 -0)
📝 packages/client/src/lib/character-display.ts (+40 -0)
📝 packages/server/scripts/run-tests.mjs (+1 -0)
📝 packages/server/src/routes/generate.routes.ts (+8 -4)
📝 packages/server/src/routes/generate/generate-route-utils.ts (+40 -4)
➕ packages/server/src/services/llm/__tests__/inline-thinking.test.ts (+167 -0)
📝 packages/server/src/services/llm/inline-thinking.ts (+63 -8)

📄 Description

Linked issue

Closes #2092

Why this change

  • Fixes a bug where visible AI response text after an inline reasoning/thinking block could be swallowed into the thinking pane.
  • Some models emit responses like <thinking>...</thinking> followed by the actual reply. When the parser fails to split the closing reasoning tag from the reply text, the message content can become empty and the real response may be lost.
  • This is especially important for models/providers that emit <think> / <thinking> style tags, mismatched close tags, or streamed reasoning output.

What changed

  • Updated inline thinking block parsing to preserve visible content after the final closing reasoning tag.
  • Made reasoning tag handling more tolerant for <think> and <thinking> forms.
  • Added handling for mismatched thinking tag forms such as <thinking>...</think> and <think>...</thinking>.
  • Added guarded handling for orphan closing reasoning tags followed by visible reply text.
  • Added or updated tests covering inline reasoning blocks followed by visible content.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Ran pnpm check locally.
  • Verified the parser behavior through automated tests for reasoning/thinking tag cases.
  • Did not perform Docker/container validation.
  • Did not perform browser UI validation because this change is limited to server-side response parsing.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

N/A — this is a server-side response parsing fix.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/2093 **Author:** [@lemontaffy](https://github.com/lemontaffy) **Created:** 6/3/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `fix/thinking-parser-empty-content` --- ### 📝 Commits (10+) - [`19411f3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/19411f3675ea22a60b5803feecfd0e8b17a6ab06) Fix mobile composer text input collapse (#1136) - [`77a30fa`](https://github.com/Pasta-Devs/Marinara-Engine/commit/77a30fa4ee43b368f4ba4709b0161705e7c05881) Fix tracker aliases, avatars, HUD temps, and changelog (#1137) - [`e85da38`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e85da38d6f3a5abaceffc80dd1d661281bf4b497) Reduce chat startup and focus refetch lag - [`10b6330`](https://github.com/Pasta-Devs/Marinara-Engine/commit/10b633089c8840d9d057ff99351c0091db8d78eb) Revert "Reduce chat startup and focus refetch lag" - [`1ab4c3f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1ab4c3f367e98478cb1aded6d0ce7018145500bc) Register pre-alpha workflow on default branch - [`1f7b25a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1f7b25aae5560c35911bdaae0d436bd0e17346f8) Merge pull request #1382 from munimunigamer/ci/register-prealpha-workflow - [`389a682`](https://github.com/Pasta-Devs/Marinara-Engine/commit/389a682b07f3d55b9319b6e3272e2426d1fa6ea3) Add Bunny review command bootstrap (#1821) - [`9e96048`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9e960485ff4c503a99cdc539ac11f4979b5c1675) Register Bunny auto review dispatcher on main (#1872) - [`c49f1d9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c49f1d950cad132de73ac213e7865147098b31ee) Enable Bunny dispatch for draft PRs (#2026) - [`4e62759`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4e62759788f1130236d68748d873333106a8a17a) fix(llm): preserve reply text after inline reasoning close tag ### 📊 Changes **16 files changed** (+888 additions, -76 deletions) <details> <summary>View changed files</summary> ➕ `.github/workflows/bunny-review-auto.yml` (+38 -0) ➕ `.github/workflows/bunny-review-command.yml` (+96 -0) ➕ `.github/workflows/prealpha-platform-builds.yml` (+335 -0) 📝 `CHANGELOG.md` (+16 -0) 📝 `packages/client/src/components/chat/ConversationInput.tsx` (+5 -5) 📝 `packages/client/src/components/chat/RoleplayHUD.tsx` (+19 -37) 📝 `packages/client/src/components/panels/SettingsPanel.tsx` (+1 -1) 📝 `packages/client/src/components/panels/settings/TrackerCardColorSettings.tsx` (+17 -11) 📝 `packages/client/src/features/tracker-panel/hooks/use-tracker-sprite-lookup.ts` (+11 -6) 📝 `packages/client/src/features/tracker-panel/lib/tracker-metadata.ts` (+31 -0) 📝 `packages/client/src/lib/character-display.ts` (+40 -0) 📝 `packages/server/scripts/run-tests.mjs` (+1 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+8 -4) 📝 `packages/server/src/routes/generate/generate-route-utils.ts` (+40 -4) ➕ `packages/server/src/services/llm/__tests__/inline-thinking.test.ts` (+167 -0) 📝 `packages/server/src/services/llm/inline-thinking.ts` (+63 -8) </details> ### 📄 Description <!-- Target branch: `staging`. The default base in this UI is `main` (release branch). --> <!-- Change the base to `staging` before submitting unless this is a maintainer-approved mainline change. --> <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #2092 ## Why this change * Fixes a bug where visible AI response text after an inline reasoning/thinking block could be swallowed into the thinking pane. * Some models emit responses like `<thinking>...</thinking>` followed by the actual reply. When the parser fails to split the closing reasoning tag from the reply text, the message content can become empty and the real response may be lost. * This is especially important for models/providers that emit `<think>` / `<thinking>` style tags, mismatched close tags, or streamed reasoning output. ## What changed * Updated inline thinking block parsing to preserve visible content after the final closing reasoning tag. * Made reasoning tag handling more tolerant for `<think>` and `<thinking>` forms. * Added handling for mismatched thinking tag forms such as `<thinking>...</think>` and `<think>...</thinking>`. * Added guarded handling for orphan closing reasoning tags followed by visible reply text. * Added or updated tests covering inline reasoning blocks followed by visible content. ## Validation * [x] `pnpm check` passes locally * [ ] Container (Docker / Podman) built and ran without issue * [ ] Ran the app, clicked through the changes manually * [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) * [ ] Above manual verification completed (describe below) * [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes * Ran `pnpm check` locally. * Verified the parser behavior through automated tests for reasoning/thinking tag cases. * Did not perform Docker/container validation. * Did not perform browser UI validation because this change is limited to server-side response parsing. ## Docs and release impact * [x] No docs changes needed * [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed * [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) N/A — this is a server-side response parsing fix. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:16:16 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5433
No description provided.