[PR #5174] [MERGED] Add Assistant Reasoning Prefill #6657

Closed
opened 2026-10-23 04:12:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5174
Author: @kaldigo
Created: 8/17/2026
Status: ✅ Merged
Merged: 8/17/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/assistant-reasoning-prefill


📝 Commits (8)

  • 8042577 Add assistant reasoning prefill
  • 87940e1 fix: preserve assistant reasoning prefill metadata
  • 8a46015 fix(generation): gate reasoning prefills by provider
  • 05edf03 Merge remote-tracking branch 'origin/staging' into review/pr-5174
  • d92a9b7 fix(generation): preserve reasoning prefill fallbacks
  • fd2beb1 test(provider): terminate mock SSE events
  • 230d37c fix(generation): align fallback prefill handling
  • f87c7db Merge branch 'staging' into feat/assistant-reasoning-prefill

📊 Changes

15 files changed (+399 additions, -21 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/prompts/generation-parameters.md (+6 -0)
📝 packages/client/src/components/ui/GenerationParametersEditor.tsx (+21 -0)
📝 packages/client/src/features/chat-settings/sections/AdvancedParametersSection.tsx (+1 -0)
📝 packages/client/src/localization/locales/en.json (+2 -0)
📝 packages/server/src/routes/generate.routes.ts (+36 -6)
📝 packages/server/src/routes/generate/generate-route-utils.ts (+42 -2)
📝 packages/server/src/services/generation/generation-parameters.ts (+7 -0)
📝 packages/server/src/services/generation/provider-generation-runtime.ts (+22 -1)
📝 packages/server/src/services/llm/connection-fallback-provider.ts (+61 -10)
📝 packages/server/src/services/llm/providers/openai.provider.ts (+4 -0)
📝 packages/shared/src/constants/defaults.ts (+1 -0)
📝 packages/shared/src/schemas/prompt.schema.ts (+1 -0)
📝 packages/shared/src/types/prompt.ts (+2 -0)
📝 scripts/regressions/provider-compat.regression.ts (+191 -2)

📄 Description

Linked issue

Closes #5173

Why this change

  • Marinara supports visible Assistant Prefill text but cannot prefill a compatible model's separate reasoning channel.
  • Providers such as Kimi K3 support continuing a partial assistant message using reasoning_content.
  • Users need to configure visible answer continuation and hidden reasoning continuation independently.

What changed

  • Added assistantReasoningPrefill to the shared generation-parameter type, schema, and defaults.
  • Added Assistant Reasoning Prefill beside Assistant Prefill in connection and chat generation settings.
  • Appended reasoning prefill as provider metadata on the initial final assistant message.
  • Updated the OpenAI-compatible serializer to send:
    • reasoning_content containing the reasoning prefill.
    • partial: true when reasoning prefill is present.
  • Preserved the existing visible-only Assistant Prefill request shape.
  • Supported reasoning-only prefill with an empty visible content.
  • Suppressed both prefills during follow-up passes and impersonation.
  • Preserved Gemini regeneration message ordering.
  • Added focused provider compatibility regression coverage.
  • Added English documentation and an [Unreleased] changelog entry.

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

  • pnpm check, pnpm version:check, and all 124 Node regressions passed.
  • Focused coverage passed for combined, reasoning-only, and visible-only prefills, plus follow-up and impersonation suppression.
  • A saved Custom OAI-Compatible connection was sent through a local capture endpoint. Its final message was:
{
  "role": "assistant",
  "content": "Visible prefix:",
  "reasoning_content": "I should reason from this exact prefix.",
  "partial": true
}
  • A mock streamed response rendered Visible prefix:final response in the UI.
  • The broad UI lane completed with 213 passed, 106 skipped, and 21 unrelated failures; its custom-generation-parameters test passed.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

English documentation and CHANGELOG.md were updated. No version bump is included.

Translated documentation: #5175

Summary by CodeRabbit

  • New Features

    • Added optional Assistant Reasoning Prefill support for compatible OpenAI-style endpoints.
    • Continue hidden reasoning from partial assistant messages while preserving visible assistant prefills.
    • Added an editor field with localized guidance across chat and roleplay settings.
    • Reasoning prefills are preserved in saved generation parameters and provider requests.
  • Documentation

    • Documented supported models, usage, and coexistence with Assistant Prefill.
  • Tests

    • Added coverage for visible-only, reasoning-only, streaming, and follow-up scenarios.

Maintainer follow-up: CodeRabbit findings were applied and the reasoning-prefill fallback paths were revalidated before merge.


🔄 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/5174 **Author:** [@kaldigo](https://github.com/kaldigo) **Created:** 8/17/2026 **Status:** ✅ Merged **Merged:** 8/17/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/assistant-reasoning-prefill` --- ### 📝 Commits (8) - [`8042577`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8042577dd68a67482e121e1a196caec313b87d37) Add assistant reasoning prefill - [`87940e1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/87940e12ede00b193979f44b142513617f3f6510) fix: preserve assistant reasoning prefill metadata - [`8a46015`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8a46015a83a2553e0c741747dbdab9562b46e9dc) fix(generation): gate reasoning prefills by provider - [`05edf03`](https://github.com/Pasta-Devs/Marinara-Engine/commit/05edf03a62a6bc4c2b3b93217c598fdd004a9e64) Merge remote-tracking branch 'origin/staging' into review/pr-5174 - [`d92a9b7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d92a9b7bd2504b5f2dcadd178fe350b2f7a288e9) fix(generation): preserve reasoning prefill fallbacks - [`fd2beb1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fd2beb1b02f224fae0be5b299a7e282ff0b3f60d) test(provider): terminate mock SSE events - [`230d37c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/230d37c98748d8cb57b06bbcd051c53f0af1fa59) fix(generation): align fallback prefill handling - [`f87c7db`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f87c7db084cec01b1910f2381625965639c18115) Merge branch 'staging' into feat/assistant-reasoning-prefill ### 📊 Changes **15 files changed** (+399 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/prompts/generation-parameters.md` (+6 -0) 📝 `packages/client/src/components/ui/GenerationParametersEditor.tsx` (+21 -0) 📝 `packages/client/src/features/chat-settings/sections/AdvancedParametersSection.tsx` (+1 -0) 📝 `packages/client/src/localization/locales/en.json` (+2 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+36 -6) 📝 `packages/server/src/routes/generate/generate-route-utils.ts` (+42 -2) 📝 `packages/server/src/services/generation/generation-parameters.ts` (+7 -0) 📝 `packages/server/src/services/generation/provider-generation-runtime.ts` (+22 -1) 📝 `packages/server/src/services/llm/connection-fallback-provider.ts` (+61 -10) 📝 `packages/server/src/services/llm/providers/openai.provider.ts` (+4 -0) 📝 `packages/shared/src/constants/defaults.ts` (+1 -0) 📝 `packages/shared/src/schemas/prompt.schema.ts` (+1 -0) 📝 `packages/shared/src/types/prompt.ts` (+2 -0) 📝 `scripts/regressions/provider-compat.regression.ts` (+191 -2) </details> ### 📄 Description ## Linked issue Closes #5173 ## Why this change - Marinara supports visible Assistant Prefill text but cannot prefill a compatible model's separate reasoning channel. - Providers such as Kimi K3 support continuing a partial assistant message using `reasoning_content`. - Users need to configure visible answer continuation and hidden reasoning continuation independently. ## What changed - Added `assistantReasoningPrefill` to the shared generation-parameter type, schema, and defaults. - Added **Assistant Reasoning Prefill** beside **Assistant Prefill** in connection and chat generation settings. - Appended reasoning prefill as provider metadata on the initial final assistant message. - Updated the OpenAI-compatible serializer to send: - `reasoning_content` containing the reasoning prefill. - `partial: true` when reasoning prefill is present. - Preserved the existing visible-only Assistant Prefill request shape. - Supported reasoning-only prefill with an empty visible `content`. - Suppressed both prefills during follow-up passes and impersonation. - Preserved Gemini regeneration message ordering. - Added focused provider compatibility regression coverage. - Added English documentation and an `[Unreleased]` changelog entry. ## Validation - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - `pnpm check`, `pnpm version:check`, and all 124 Node regressions passed. - Focused coverage passed for combined, reasoning-only, and visible-only prefills, plus follow-up and impersonation suppression. - A saved Custom OAI-Compatible connection was sent through a local capture endpoint. Its final message was: ```json { "role": "assistant", "content": "Visible prefix:", "reasoning_content": "I should reason from this exact prefix.", "partial": true } ``` - A mock streamed response rendered `Visible prefix:final response` in the UI. - The broad UI lane completed with 213 passed, 106 skipped, and 21 unrelated failures; its custom-generation-parameters test passed. ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [x] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) English documentation and `CHANGELOG.md` were updated. No version bump is included. Translated documentation: #5175 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added optional Assistant Reasoning Prefill support for compatible OpenAI-style endpoints. * Continue hidden reasoning from partial assistant messages while preserving visible assistant prefills. * Added an editor field with localized guidance across chat and roleplay settings. * Reasoning prefills are preserved in saved generation parameters and provider requests. * **Documentation** * Documented supported models, usage, and coexistence with Assistant Prefill. * **Tests** * Added coverage for visible-only, reasoning-only, streaming, and follow-up scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Maintainer follow-up: CodeRabbit findings were applied and the reasoning-prefill fallback paths were revalidated before merge. <!-- owner-approval-refresh: 230d37c --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:12:29 +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#6657
No description provided.