mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #910] [MERGED] fix(commands): keep Professor Mari going after fetch + parse bracketed params #4832
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4832
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/910
Author: @Romuromylus
Created: 5/16/2026
Status: ✅ Merged
Merged: 5/16/2026
Merged by: @Romuromylus
Base:
staging← Head:fix/professor-mari-tool-completion📝 Commits (2)
7e7d3e4fix(commands): keep Professor Mari going after fetch + parse bracketed paramsffe6455fix(commands): address CodeRabbit findings on #910📊 Changes
2 files changed (+162 additions, -51 deletions)
View changed files
📝
packages/server/src/routes/generate.routes.ts(+141 -38)📝
packages/server/src/services/conversation/character-commands.ts(+21 -13)📄 Description
Linked issue
Closes #898
Why this change
Two related Professor Mari regressions filed in #898:
]inside a quoted parameter value (e.g.[update_character: name="X", description="Status: [VIP] ..."]) silently failed to parse and landed in the conversation as plain text.[fetch:...], the fetched payload was persisted tochatMeta.mariContextbut mariContext is only injected at the START of a generation pass. Mari went silent right after the fetch snackbar and the user had to send another message before getting a response that used the freshly-fetched data.What changed
Parser fix —
packages/server/src/services/conversation/character-commands.tsThe catch-all
[^\]]+capture group in the command regexes terminated at the first], so a]inside a quoted parameter value cut the match short. Replaced the catch-all with aQUOTED_PARAM_BLOCKsnippet that matches either a non-quote/non-]char OR a complete double-quoted string (with\"-style escapes). Applied to every[command: ...]-shape regex that takes free-form params (schedule_update,scene,haptic,spotify,dm,create_persona,create_character,update_character,update_persona,create_lorebook,create_chat,navigate,fetch). Leavingselfie,cross_post,memory, and the XML-style block regexes untouched since they already use field-specific patterns. Same bug shape as PR #231's GM tag stripper fix.Follow-up loop —
packages/server/src/routes/generate.routes.tsWrapped the conversation-mode generation flow in a
whileloop capped atMAX_FOLLOW_UP_ITERATIONS = 2extra iterations. When Professor Mari (PROFESSOR_MARI_ID) executes a[fetch:]during an iteration, the loop:runningMessagesForFollowUpso the next pass sees her prior message.chats.getByIdso the freshly-persistedmariContextreaches the next prompt.collectedCommands/collectedOocMessages(hoisted, accumulators) before continuing.impersonateandassistantPrefillinjections to iteration 0 only, so a follow-up turn isn't re-shaped as a fresh user turn.Variables that need to survive across iterations (
firstSavedMsg,lastSavedMsg,pendingIllustration,collectedCommands,collectedOocMessages) are hoisted above the loop so the end-of-stream OOC posting, illustration await, and SSEdoneevent see state from the latest iteration. The background memory-recall chunking call was moved to live inside the loop body socharInfostays in scope; it runs exactly once on the final iteration (beforebreak).The follow-up only triggers when:
chatMode === "conversation"(Game/Roleplay modes are unaffected),regenerateMessageIdregen,characterId === PROFESSOR_MARI_ID, orcharacterId === nullin a chat that includes Mari).Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Tested on a fork build deployed to my private EasyPanel instance (NanoGPT - GLM connection, fresh Conversation chat with Professor Mari).
[STATUS: TRAVELLING](with square brackets) at the start of her description so I can grep for it later. Keep the rest intact." Mari ran the update; querying/api/charactersdirectly confirmed Lumine'sdescriptionnow starts with the literal string[STATUS: TRAVELLING] "The world is so vast..."— the bracketed value made it through the parser cleanly. Before the fix this command would have failed to match the regex (terminated at the first]) and leaked as plain text.Things I'd appreciate the maintainers double-checking:
firstSavedMsg/lastSavedMsg/pendingIllustrationout of the inner block — they now share state across iterations.firstSavedMsgis intentionally "first across the whole turn" rather than "first per iteration";pendingIllustrationwill only await the most recent iteration's job (older illustration promises are fire-and-forget anyway). If anyone sees a case where iteration 1 needs a freshfirstSavedMsg, I'm happy to gate that.else ifchain branching on Mari's fetch result (characterId === PROFESSOR_MARI_ID || (characterId === null && characterIds.includes(PROFESSOR_MARI_ID))) — this matches the same heuristic used elsewhere in the file (e.g. line ~2239isMariChat), but I haven't audited every legacy chat to confirmnullcharacterId always lines up with Mari being the speaker in a Mari-included chat.Docs and release impact
UI evidence (if applicable)
Not a UI change. The user-visible effect is that Mari now actually keeps talking after
[fetch:]and update commands with brackets-in-quotes land cleanly instead of dumping as plain text.Credit
The shape of both fixes follows a patch shared by @timwu in the Discord thread linked from #898 (fork commit). I ported it forward to current
staging, dropped an unrelatedcharNameMaprefactor that was in the original patch, and verified end-to-end against the live deploy.Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.