mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6705] [Feature]: Make semantic summary retrieval parameters configurable per chat #3755
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#3755
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?
Originally created by @boricha417 on GitHub (Sep 26, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6705
Originally assigned to: @SpicyMarinara on GitHub.
Follow-up to #5240 / #5246, which introduced semantic summary retrieval with these fixed values.
What problem does this solve?
When Semantic summary retrieval is enabled for a Roleplay chat, the number of summaries that reach the prompt is fixed by hard-coded constants in
packages/server/src/services/generation/roleplay-summary-retrieval.ts:SEMANTIC_SUMMARY_RECENT_ENTRY_COUNTSEMANTIC_SUMMARY_TOP_KSEMANTIC_SUMMARY_MIN_SIMILARITY.slice(-4))There is no way to change these from the UI, chat metadata, or app settings. In practice the right amount varies by scene: a long, slow-burn story benefits from keeping more recent summaries verbatim, while a fast-moving plot needs fewer. Likewise, some chats want older memories recalled more aggressively and others want them recalled only when clearly relevant.
For comparison,
summaryTailMessages(the raw recent-message tail) is already user-adjustable, so the summary side is the only part of this system that cannot be tuned.Proposed solution
Read the values from
ChatMetadatawith the current constants as defaults, so existing chats behave exactly as they do today:semanticSummaryRecentEntryCount(default 2)semanticSummaryTopK(default 3)semanticSummaryMinSimilarity(default 0.15)Expose them in the Chat Settings drawer next to the existing Semantic summary retrieval toggle (
ChatSettingsDrawer.tsx), shown only while the toggle is on. Numeric inputs are enough; a single "long-term memory strength" slider that maps to top-K and threshold together would also work if a simpler UI is preferred.The query message count could stay internal, since it affects retrieval accuracy rather than prompt size.
Alternatives considered
enabledflag from an extension before each generation. Technically possible but it rewrites user-visible summary state on every turn, so it was rejected.Additional context
Related observation while reading the code: older summaries are re-embedded on every generation (
embedMemoryRecallTexts(olderEntries.map(...))), with no cache keyed by entry ID or content hash. With a remote embedding provider this means one embedding request per older summary per generation. Caching embeddings alongside the entries would reduce cost, and would matter more once users can raise top-K. Happy to split that into a separate issue if preferred.Call sites that would receive the new options:
generate.routes.ts,generate/dry-run-route.ts,generate/retry-agents-route.ts(all callresolveRoleplayChatSummaryForPrompt).Template check
@SirAdoni commented on GitHub (Sep 26, 2026):
I'm working on this in a clean sandbox based on current staging. I'll add per-chat controls for recent summaries, older-summary count, and the relevance threshold while preserving the current defaults, with regression coverage. I'll keep this in a focused PR; embedding-cache changes will stay outside this scope.
@boricha417 commented on GitHub (Sep 27, 2026):
Thanks for picking this up so quickly! The three controls and preserved defaults are exactly what I was hoping for, and the summary vector cache is a welcome bonus.
One request about placement, and this is my fault: the issue pointed at
ChatSettingsDrawer.tsx, but the semantic retrieval switch lives in a different place per mode:SummaryPopover.tsx)The server side of #6744 already reads the new settings in both modes, but the controls only render for Roleplay, in a new drawer section with a second copy of the switch. So Roleplay gets a duplicate toggle away from the one people actually use, and Conversation has no way to set the values.
Could the three controls go directly under the existing switch in each mode, shown only while it is on, and the new Roleplay drawer section be dropped? A small shared component would cover both.
Minor: in Conversation the "recent" count applies to week summaries, so a label like "Recent weeks" would be clearer there.
If the popover is too tight on mobile, a collapsed "Advanced" row under the switch would work too.