mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #6586] [MERGED] fix(decision): ask only the decision statements a turn can reach #7237
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#7237
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/6586
Author: @kolacheee
Created: 9/23/2026
Status: ✅ Merged
Merged: 9/24/2026
Merged by: @kolacheee
Base:
staging← Head:fix/decision-reachable-statements📝 Commits (10+)
9976ee2fix(decision): ask only the decision statements a turn can reach2d8c723fix(decision): share probability rolls with the entry-text pre-scan, and filter agent plans the same waye23957dfix(decision): follow a lorebook decision branch only once it is decided84594baperf(decision): resolve discovery text once for entries without decisions3313d08feat(decision): sticky and cooldown on decision statements, and review fixes75ee90cfix(decision): held statements leave the lorebook's share, timer saves never cost answers, and prompt parts plan their own textd03f558Merge remote-tracking branch 'origin/staging' into fix/decision-reachable-statements8cd2b56fix(decision): plan prompt parts' extension blocks, and give held statements their answer on a Decision fielda4731edfix(decision): plan only the extension blocks the dry run assembles6e9a8beperf(decision): read preset parts in parallel again📊 Changes
21 files changed (+1784 additions, -167 deletions)
View changed files
📝
CHANGELOG.md(+6 -0)📝
docs/connections/decision-models.md(+1 -1)📝
docs/lorebooks/entries.md(+3 -1)📝
docs/prompts/conditional-prompts.md(+29 -1)📝
docs/prompts/macros.md(+1 -1)📝
docs/prompts/preset-variables.md(+6 -0)📝
docs/prompts/presets.md(+8 -0)➕
e2e/decision-peek-report.e2e.ts(+93 -0)📝
packages/client/src/components/chat/PeekPromptModal.tsx(+16 -1)📝
packages/client/src/components/chat/chat-area.types.ts(+1 -1)📝
packages/client/src/hooks/use-chats.ts(+1 -1)📝
packages/client/src/localization/locales/en.json(+1 -0)📝
packages/server/src/routes/chats.routes.ts(+53 -25)📝
packages/server/src/routes/generate.routes.ts(+83 -23)📝
packages/server/src/routes/generate/dry-run-route.ts(+66 -26)➕
packages/server/src/services/decision/decision-timers.ts(+113 -0)📝
packages/server/src/services/decision/prompt-decisions.ts(+193 -40)📝
packages/server/src/services/lorebook/index.ts(+104 -39)📝
packages/shared/src/schemas/gm-verb-table.schema.ts(+1 -0)📝
packages/shared/src/utils/macro-engine.ts(+283 -7)...and 1 more files
📄 Description
Linked issue
Closes #6582
Why this change
char == "Dottore" && decision:"..."while the character is Mira) all took slots. Past the limit the rest read as no, so live statements lost their slots to dead ones.\"Mira is angry...\"). The prompt looks it up under the clean key, so it read as no on every turn and still took a slot.What changed
planDecisionStatements). It resolves a text with decisions unknown rather than false, keeps every branch that could be taken, and records a statement only where its answer could change the result. Values fixed for the turn (the character, persona, model, card fields, literals) still decide conditions, so a block they rule out is not asked about. Anything that can change while the prompt is built, such as a variable written by an earlier section, reads as unknown, so nothing that matters is missed. In a group chat, character conditions read as unknown because they differ per character. Answers the turn already has count. Nothing is written back.processLorebooksruns its pure pre-scan in rounds. Each round follows only branches already settled, asks newly pending Require/Trigger statements and the statements in the text of newly activating entries, and stops when nothing new comes in. An entry reached only through an undecided branch is asked about only once that branch is a yes. Pre-scan and real scan now share probability rolls whenever entry text holds statements, not only when an entry has a Decision field. Answers are merged in place into the turn's answers object, which generation now always creates, so the preset's lorebook marker and the agents see them.{{#if decision:"..." sticky:3 cooldown:5}}keeps a yes for 3 turns without asking, then reads as no for 5, then asks again. Cooldown starts when sticky ends, like a lorebook entry's. A turn is each new message the Decision model reads; a regeneration or swipe is the same turn. A held statement is planned so its held answer reaches the prompt, but it is never sent to the model and takes no statement slot. Fordecision_choice:, sticky keeps the chosen option and cooldown reads every comparison as no. Timers live in chat metadata under a new engine-owneddecisionnamespace, and previews read them without moving them on. Unknown modifiers are ignored, so a later one (such as priority) does not break older builds. A lorebook entry's Decision field already works with the entry's own Sticky and Cooldown, and the docs say so.docs/prompts/presets.mdgains a "Decision blocks and prompt caching" section that tells preset makers to be very careful and purposeful with decision blocks near the top.docs/prompts/preset-variables.mdcovers decision blocks in options. The Conditional Prompts limits note lists what counts and has a stronger caching warning. The lorebook and Decision Models guides say what counts toward the limit. Conditional Prompts gains a "Sticky and cooldown" section, and the macro reference lists the modifiers. CHANGELOG entries are included.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Run by the agent:
pnpm check,pnpm localization:checkandpnpm regression:node(365 of 365, on the branch rebased onto staging7e0f2e582).scripts/regressions/decision-reachable-statements.regression.ts:&&counts, nested blocks, a settled chain stops, a variable rules nothing out, a group character condition stays unknown,{{char}}statements, known answers settle their block, settled-only text, and nothing is written.processLorebooks: only the activating entry's statement is asked and its answer reaches the text; a zero budget reports it as dropped and reads as no; shared probability rolls in both roll orders; an entry behind a decision branch is found once that branch is a yes and never asked behind a no.e2e/decision-peek-report.e2e.ts, passing locally on desktop-chromium and mobile-chromium (mobile-webkit cannot launch on the agent's machine, so CI covers it). With 33 statements (one past the default limit), a{{prompt}}preview shows 32 unanswered and 1 dropped in separate notices, and never the disabled section's statement. It changes no global setting, so projects sharing a server cannot disturb each other.60b50048f: conversation fields (char_aboutand the rest) are filled in after planning, so they no longer rule statements out; settled-only planning reads every non-decision operand as the real pass does, so lorebook discovery follows a branch a variable decides; the Peek e2e no longer changes global settings; and #6532 now lists every batched docs path. The sticky and cooldown commit reviewed clean locally.75ee90c0e: held statements no longer shrink the lorebook resolver's share of the limit (generation, Peek Prompt and the dry run); a failed timer save is caught and logged instead of discarding the turn's answers; and the dry run with prompt parts planspromptParts.presetTextinstead of the preset sections it does not assemble. Each has a regression that fails when the fix is reverted, except the save error path, which the regression harness cannot make fail. Reviewed clean locally.Please verify manually:
{{prompt}}) does not list it.{{#if decision:"..."}}...{{/if}}, select that option, and with a Decision model set, confirm the block's yes branch appears in the prompt when the statement is true.[decision] Prompt statement).Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)Changed user docs for the batched
[docs-i18n]follow-up (#6532, which now lists every batched path):docs/prompts/macros.md(one sentence),docs/prompts/presets.md(new "Decision blocks and prompt caching" section),docs/prompts/preset-variables.md(new "Decision blocks in options" section),docs/prompts/conditional-prompts.md(limits list, a caching paragraph, and a new "Sticky and cooldown" section),docs/lorebooks/entries.md(one sentence),docs/connections/decision-models.md(one sentence).UI evidence (if applicable)
The new e2e attaches a screenshot of Peek Prompt with both notices: "Decision statements without an answer for this turn yet: 1" listing the first statement, and "Decision statements past the per-turn limit, read as no: 1" listing the second, in the same amber style.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.