mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6559] [Feature]: Route Smart response order (and group card relevance) through the decision-model endpoint #3675
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#3675
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 @kevin-ho on GitHub (Sep 23, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6559
Originally assigned to: @kolacheee on GitHub.
What problem does this solve?
Two prompt-cost hotspots in individual-mode group chats currently pay a
regular chat-model round trip for what is essentially a classification job,
while #6555 introduces an endpoint built for exactly this shape of decision.
Smart response order —
selectSmartGroupResponders()inpackages/server/src/routes/generate.routes.ts(staging, ~L6416–6566)sends every candidate's summary
(
formatSmartGroupCandidates(),services/generation/conversation-context-utils.ts)plus a 5-message transcript to a chat completion and asks for a JSON array
of character IDs (~L6530–6547), parsed tolerantly at
parseSmartGroupSelectionIds()(~L6372). One full generation call perturn to pick a speaker.
Group card scoping —
scopeIndividualGroupMessagesForTarget()inpackages/server/src/services/generation/prompt-message-scope.ts(~L319)strips non-responder profile blocks after assembly. The base prompt still
assembles every active roster card first, and the stripper depends on
recognizable XML/markdown wrappers or exact field-text matches. Nothing
scores relevance: a 2000-token card for a character who hasn't been on
screen in 40 messages is either assembled-then-stripped or sent intact in
merged mode.
#6555's endpoint already supports batched Noul questions (see the
grouping-by-depth batching in
services/generation/agent-activation-questions.ts),which maps onto both surfaces.
Proposed solution
For Smart order: per-candidate Noul questions — "should
respond to this state?" — compared against a threshold, mirroring the
existing activation-question pattern (including per-model calibration).
The orchestrator rules in the current system prompt are multi-candidate
(usually one speaker, never the same character twice in a row, ~L6450–6465).
Those would stay as a small deterministic rule layer over the per-candidate
verdicts — ≥1 must pass, avoid the last speaker — or a single Choice
question over the candidate set. The existing fail-open fallback (first
available character who isn't the last speaker, ~L6568) already tolerates
endpoint failure, and a 1.5s budget fits inside the current generation
timeout shape.
For card relevance: score each roster card's confidence against the
recent transcript with the same Noul call, and skip assembling cards below
a threshold in the first place — in both group modes — instead of assembling
then stripping.
Alternatives considered
Keeping the chat call for its native multi-candidate reasoning is the
strongest counterargument: it understands the "don't repeat the same
speaker" instructions directly rather than needing a rule layer. The batched
verdicts + rules approach is proposed on cost and latency grounds, not
correctness — on eight roleplay cases a purpose-built model being worse at
the same job (#6555) should be expected to apply here too, so this is opt-in
with the same off-by-default shape as activation questions.
For card relevance specifically, an embedding-similarity pre-filter (like
lorebook vector scoring) was considered; the decision endpoint keeps the
mechanism consistent with activation questions and avoids a second
dependency, though embedding-based scoring may well be the cheaper option
if latency per turn matters more than per-call simplicity.
Additional context
Both surfaces are reachable from code that already exists on
staging;nothing here assumes a new runtime beyond #6555's managed sidecar.
Sequential and Merged modes would keep their current behavior with no calls.
Template check
@kolacheee commented on GitHub (Sep 23, 2026):
#6572 takes the Smart order half of this: one batched yes/no per candidate against the Decision model, the model's own threshold, a small rule layer (the last speaker yields), and the existing chat-model selector as the fallback whenever the switch is off or the Decision model does not answer.
Card relevance is left out on purpose. The reasons, with where to look:
scopeIndividualGroupMessagesForTarget()inpackages/server/src/services/generation/prompt-message-scope.tsremoves the other roster cards per target before the request goes out (called wherescopedMessagesForGenis built inpackages/server/src/routes/generate.routes.ts). Skipping assembly earlier would save server work, not tokens sent to the provider.charactermarker inpackages/server/src/services/prompt/marker-expander.ts). A card set that changes from turn to turn changes everything after it, so a caching provider re-bills the whole prompt. On those providers it would cost more than it saves.A card author who wants this for one character can already do it in the card's own text with a decision statement from #6569, for example trimming a long section with
{{#if decision:"Kaelen is present in the latest message"}}...{{/if}}. That keeps the choice with the author and the cost visible.