[PR #3334] [MERGED] Refactor generation route runtimes #5882

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3334
Author: @SpicyMarinara
Created: 7/7/2026
Status: ✅ Merged
Merged: 7/7/2026
Merged by: @SpicyMarinara

Base: staging ← Head: codex/split-generate-routes


📝 Commits (3)

  • 62648af Refactor generation route runtimes
  • 80cbad0 Fix guided roleplay targeting and first-turn lorebooks
  • 69fc9cb Apply CodeRabbit generation runtime suggestions

📊 Changes

37 files changed (+6379 additions, -4921 deletions)

View changed files

📝 CHANGELOG.md (+3 -0)
📝 packages/client/src/components/chat/ChatInput.tsx (+4 -0)
📝 packages/client/src/lib/slash-commands.ts (+87 -1)
📝 packages/server/src/routes/generate.routes.ts (+432 -4914)
➕ packages/server/src/routes/generate/agent-result-capabilities.ts (+53 -0)
➕ packages/server/src/routes/generate/connected-conversation-injections.ts (+108 -0)
➕ packages/server/src/routes/generate/conversation-connected-context.ts (+226 -0)
➕ packages/server/src/routes/generate/conversation-context-block.ts (+129 -0)
➕ packages/server/src/routes/generate/conversation-custom-assets.ts (+680 -0)
➕ packages/server/src/routes/generate/conversation-history-runtime.ts (+518 -0)
➕ packages/server/src/routes/generate/conversation-presence-runtime.ts (+324 -0)
➕ packages/server/src/routes/generate/conversation-prompt-formatting.ts (+76 -0)
➕ packages/server/src/routes/generate/image-captioning-runtime.ts (+294 -0)
➕ packages/server/src/routes/generate/lorebook-scan-snapshot.ts (+27 -0)
➕ packages/server/src/routes/generate/professor-mari-prompt-context.ts (+92 -0)
➕ packages/server/src/services/generation/agent-prompt-runtime.ts (+26 -0)
➕ packages/server/src/services/generation/conversation-call-command-runtime.ts (+117 -0)
➕ packages/server/src/services/generation/conversation-command-runtime.ts (+325 -0)
➕ packages/server/src/services/generation/conversation-cross-post-command-runtime.ts (+72 -0)
➕ packages/server/src/services/generation/conversation-music-command-runtime.ts (+114 -0)

...and 17 more files

📄 Description

Linked issue

Fixes #3332.

Also includes a maintainer-reported Roleplay /guided regression in individual group chats.

Why this change

packages/server/src/routes/generate.routes.ts had grown into a very large route file with prompt setup, provider runtime setup, conversation context building, agent handling, and command side effects all interleaved. This made v2.1.1 generation work harder to review and riskier to maintain.

While validating the branch, two Roleplay regressions surfaced:

  • Typed /guided in Individual-Manual group chats could no-op because no explicit responder was sent.
  • Smart group queues could make the queued (1) responder win over /guided respond for <character> intent.

Issue #3332 also showed that first-turn lorebook scans could miss opening group greetings once the recent-message scan window trimmed earlier starter messages.

What changed

  • Split provider setup, prompt patching, output token limits, roleplay summary helpers, Director Secret Plot helpers, and agent-result capability helpers out of generate.routes.ts.
  • Extracted Conversation prompt/context helpers for history formatting, current context, connected chat injections, presence, custom assets, image captioning, lorebook scan snapshots, and Professor Mari prompt context.
  • Extracted command/runtime handlers for Conversation calls, music, reactions, schedules, cross-posts, selfies, memory/influence/notes, scenes, haptics, turn games, Roleplay DMs, and Professor Mari workspace actions.
  • Fixed Roleplay /guided respond for <character> <direction> so it sends an explicit forCharacterId, clears that character's pending smart queue badge, and prompts for a target in Individual-Manual groups instead of silently doing nothing.
  • Fixed first-turn lorebook keyword activation by pinning opening chat messages during the first user generation when the normal recent scan depth would otherwise drop earlier group greetings.
  • Added v2.1.1 changelog notes for the generation route refactor and the follow-up fixes.

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

AI-run validation completed, boxes intentionally left unchecked for human verification:

  • pnpm --filter @marinara-engine/client exec tsc --noEmit
  • pnpm --filter @marinara-engine/client lint
  • pnpm --filter @marinara-engine/server exec tsc --noEmit
  • pnpm check
  • pnpm regression:prompt
  • git diff --check

No browser/manual UI pass was performed; the /guided change is client request routing and the lorebook fix is covered by a prompt regression.

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)

Updated CHANGELOG.md for v2.1.1. No version files changed.

UI evidence (if applicable)

N/A — no visual UI changes.


🔄 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/3334 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 7/7/2026 **Status:** ✅ Merged **Merged:** 7/7/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `codex/split-generate-routes` --- ### 📝 Commits (3) - [`62648af`](https://github.com/Pasta-Devs/Marinara-Engine/commit/62648afd9582faa12b2eb466d281262f96a4a30b) Refactor generation route runtimes - [`80cbad0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/80cbad055122ca9e6e943a14850d7e1e41628e35) Fix guided roleplay targeting and first-turn lorebooks - [`69fc9cb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/69fc9cbe9e8b9b9863b17c140782ea63942aa397) Apply CodeRabbit generation runtime suggestions ### 📊 Changes **37 files changed** (+6379 additions, -4921 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -0) 📝 `packages/client/src/components/chat/ChatInput.tsx` (+4 -0) 📝 `packages/client/src/lib/slash-commands.ts` (+87 -1) 📝 `packages/server/src/routes/generate.routes.ts` (+432 -4914) ➕ `packages/server/src/routes/generate/agent-result-capabilities.ts` (+53 -0) ➕ `packages/server/src/routes/generate/connected-conversation-injections.ts` (+108 -0) ➕ `packages/server/src/routes/generate/conversation-connected-context.ts` (+226 -0) ➕ `packages/server/src/routes/generate/conversation-context-block.ts` (+129 -0) ➕ `packages/server/src/routes/generate/conversation-custom-assets.ts` (+680 -0) ➕ `packages/server/src/routes/generate/conversation-history-runtime.ts` (+518 -0) ➕ `packages/server/src/routes/generate/conversation-presence-runtime.ts` (+324 -0) ➕ `packages/server/src/routes/generate/conversation-prompt-formatting.ts` (+76 -0) ➕ `packages/server/src/routes/generate/image-captioning-runtime.ts` (+294 -0) ➕ `packages/server/src/routes/generate/lorebook-scan-snapshot.ts` (+27 -0) ➕ `packages/server/src/routes/generate/professor-mari-prompt-context.ts` (+92 -0) ➕ `packages/server/src/services/generation/agent-prompt-runtime.ts` (+26 -0) ➕ `packages/server/src/services/generation/conversation-call-command-runtime.ts` (+117 -0) ➕ `packages/server/src/services/generation/conversation-command-runtime.ts` (+325 -0) ➕ `packages/server/src/services/generation/conversation-cross-post-command-runtime.ts` (+72 -0) ➕ `packages/server/src/services/generation/conversation-music-command-runtime.ts` (+114 -0) _...and 17 more files_ </details> ### 📄 Description ## Linked issue Fixes #3332. Also includes a maintainer-reported Roleplay `/guided` regression in individual group chats. ## Why this change `packages/server/src/routes/generate.routes.ts` had grown into a very large route file with prompt setup, provider runtime setup, conversation context building, agent handling, and command side effects all interleaved. This made v2.1.1 generation work harder to review and riskier to maintain. While validating the branch, two Roleplay regressions surfaced: - Typed `/guided` in Individual-Manual group chats could no-op because no explicit responder was sent. - Smart group queues could make the queued `(1)` responder win over `/guided respond for <character>` intent. Issue #3332 also showed that first-turn lorebook scans could miss opening group greetings once the recent-message scan window trimmed earlier starter messages. ## What changed - Split provider setup, prompt patching, output token limits, roleplay summary helpers, Director Secret Plot helpers, and agent-result capability helpers out of `generate.routes.ts`. - Extracted Conversation prompt/context helpers for history formatting, current context, connected chat injections, presence, custom assets, image captioning, lorebook scan snapshots, and Professor Mari prompt context. - Extracted command/runtime handlers for Conversation calls, music, reactions, schedules, cross-posts, selfies, memory/influence/notes, scenes, haptics, turn games, Roleplay DMs, and Professor Mari workspace actions. - Fixed Roleplay `/guided respond for <character> <direction>` so it sends an explicit `forCharacterId`, clears that character's pending smart queue badge, and prompts for a target in Individual-Manual groups instead of silently doing nothing. - Fixed first-turn lorebook keyword activation by pinning opening chat messages during the first user generation when the normal recent scan depth would otherwise drop earlier group greetings. - Added v2.1.1 changelog notes for the generation route refactor and the follow-up fixes. ## 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 AI-run validation completed, boxes intentionally left unchecked for human verification: - `pnpm --filter @marinara-engine/client exec tsc --noEmit` - `pnpm --filter @marinara-engine/client lint` - `pnpm --filter @marinara-engine/server exec tsc --noEmit` - `pnpm check` - `pnpm regression:prompt` - `git diff --check` No browser/manual UI pass was performed; the `/guided` change is client request routing and the lorebook fix is covered by a prompt regression. ## 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) Updated `CHANGELOG.md` for v2.1.1. No version files changed. ## UI evidence (if applicable) N/A — no visual UI changes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:04:47 +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#5882
No description provided.