[PR #6572] [MERGED] feat(agents): prompt decision statements, Smart order by Decision model, Open-Jev 9B #7230

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6572
Author: @kolacheee
Created: 9/23/2026
Status: ✅ Merged
Merged: 9/23/2026
Merged by: @kolacheee

Base: staging ← Head: feat/decision-open-jev-9b


📝 Commits (10+)

  • 5e5e42d feat(agents): let the decision model pick who speaks in Smart order
  • 5927fd3 fix(agents): resume a decision model install instead of starting over
  • 6a4f9e8 test(agents): cover Smart order with the switch on and no decision model
  • 1a29e98 docs(agents): say which Decision model to pick, including on Android
  • 5e41348 feat(agents): offer Open-Jev 9B as a measured decision model
  • bc2c271 feat(prompts): let prompt conditionals ask the Decision model
  • 4a41775 docs: add a Decision Models guide and decision statement docs
  • 4e48ae1 docs: say post-processing decisions are asked once per reply, name real re-run controls
  • 90840d2 docs: say where a decision block keeps or loses the prompt cache
  • 18d69ea fix(prompts): ask decisions only for agents that run, and never fail a turn on them

📊 Changes

48 files changed (+3281 additions, -116 deletions)

View changed files

📝 CHANGELOG.md (+10 -0)
📝 docs/agents/custom-agents.md (+28 -56)
📝 docs/chats/group-chats.md (+2 -0)
➕ docs/connections/decision-models.md (+141 -0)
📝 docs/connections/local-model.md (+2 -0)
📝 docs/development/optional-agent-packages.md (+16 -0)
📝 docs/prompts/conditional-prompts.md (+120 -0)
📝 docs/prompts/macros.md (+2 -0)
📝 e2e/agent-activation-questions.e2e.ts (+9 -0)
📝 packages/client/src/components/chat/PeekPromptModal.tsx (+23 -0)
📝 packages/client/src/components/chat/chat-area.types.ts (+2 -0)
📝 packages/client/src/components/connections/DecisionDefaultControl.tsx (+77 -1)
📝 packages/client/src/components/modals/ImportCharacterModal.tsx (+13 -4)
📝 packages/client/src/components/modals/ImportLorebookModal.tsx (+5 -0)
📝 packages/client/src/components/modals/ImportPersonaModal.tsx (+12 -4)
📝 packages/client/src/components/modals/ImportPresetModal.tsx (+8 -0)
➕ packages/client/src/components/ui/DecisionStatementNote.tsx (+32 -0)
📝 packages/client/src/components/ui/MacroTextarea.tsx (+2 -0)
📝 packages/client/src/hooks/use-chats.ts (+1 -0)
📝 packages/client/src/hooks/use-decision-model.ts (+37 -1)

...and 28 more files

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #6569
Closes #6559 (Smart order; group card relevance is left out on purpose, reasons in a comment on the issue)
Follow-up to #6555 (the Open-Jev 9B entry and install resume left over from #6556)

Why this change

  • Prompt authors could not use the Decision model. Presets, cards, lorebooks and agent prompts had to send "if X happens, do Y" on every turn. {{#if decision:"..."}} and {{#if decision_choice:"..." == "option"}} let them send an instruction only on the turns where it applies, using whatever Decision model the user picked (their own local model, a hosted connection, or Open-Jev).
  • Smart response order paid for a full chat-model call per turn to pick a speaker. With the Decision model it becomes one batched yes/no per character, and it falls back to the old call when the model is off or fails.
  • Open-Jev 9B was measured as more accurate than 2B, and an interrupted install started from zero every time.
  • Decision models had no guide of their own. Setup was buried in the custom agents page, so prompt makers, agent authors and Termux users had nowhere to start.

What changed

  • Decision statements in prompts (#6569). New decision: and decision_choice: operands in the macro engine. The engine is synchronous, so each turn's statements are found in the raw sources first (preset sections, groups and choice blocks, character and persona fields, chat summary, group scenario, active lorebook entries, agent prompt templates), asked in one batch, cached for the turn, and handed to every place a condition is evaluated. A group block asks once per character. Unanswered reads as no, so a user with no Decision model gets the {{else}} branch.
    • Choice goes to System One as a real choice question with a "none of these" option; a local chat model answers it as one yes/no per option.
    • Agent prompt templates are covered too, but only for agents this chat actually runs. Post-processing agents are asked with the finished reply, and a regenerated swipe is asked again (the cache key includes the reply text). Re-running an agent (tracker refresh, retrying a failed agent, Re-run on an injection) reuses the turn's answers.
    • Conversation mode's system prompt (the chat's custom prompt or the preset's conversation prompt) is planned too.
    • A Decision model that cannot start or answer never fails a turn or a retry: its statements read as no.
    • A reasoning local model is skipped in front of the reply unless the user opted in, but is still asked after it.
    • New Decision statements per turn setting (default 32, max 255).
    • Peek Prompt and the dry-run route never ask; they report statements with no answer yet.
    • Fields that use a statement warn when no Decision model is set. Imports that contain statements say so, including PNG, .charx and .marinara files, which the server reports because only it reads them.
  • Smart response order (#6559). Optional switch under Decision model. One batched yes/no per candidate, the model's own threshold, and simple rules on top (the last speaker yields). Falls back to the chat-model selector on any failure.
  • Open-Jev 9B catalog entry with measured size, VRAM and calibration. Its time limit grows with the work in a request (perQuestionMs per statement and per Choice option, capped at 20 s). Measured on 9B: one yes/no takes about 0.5 s, and each Choice option adds about as much as another statement (a 10-option Choice took 3.3 s).
  • Install resume. Files that already finished are checked against their published size and checksum and kept, instead of downloading everything again.
  • Docs. New docs/connections/decision-models.md covering what a decision model is, the three ways to get one, which to pick (including Termux), thresholds, time limits, cost and troubleshooting. Setup moved there from custom-agents.md, which now covers decision statements in an agent's prompt. conditional-prompts.md gains the syntax, design rules, measured wording advice and "as designed" troubleshooting for prompt makers. optional-agent-packages.md gains notes for package and Game Mode Experience authors. The Local Model and group chat guides link to the new page.
  • UI strings that still said the Decision model only served activation questions now say what it does.

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

Run by the agent:

  • pnpm check, pnpm localization:check and pnpm regression:node (361 of 361 regressions pass) on the branch rebased onto staging 43f99a59e.
  • Local CodeRabbit review of the whole branch (run once the CodeRabbit outage eased): 6 findings plus 2 on the docs, all fixed; the fixes drew 1 more, fixed, and the final commit reviewed clean. The two containment fixes (a Decision model that throws while starting) have no route test, because making backend resolution throw from a route test would mean patching internals; everything else has one.
  • New scripts/regressions/decision-conditionals.regression.ts, driven through the real generate, Peek Prompt, dry-run, retry-agents, import and decision routes against a fake System One server. It covers yes/no, Choice with its options on the wire, the per-turn cache on regenerate, a failing model, the limit setting, no model, pre-reply and post-processing agent templates, agents the chat does not run never being asked, a regenerated swipe being asked again, re-running agents reusing answers, Conversation mode's system prompt, Peek Prompt's report in Conversation mode, and the import flag for card and .marinara files. Each wiring point was mutation-checked: reverting it makes the regression fail.
  • Live Choice check through the engine's own client code: Open-Jev 9B (real System One choice questions) and Gemma 4 E4B as a local model (one yes/no per option) each chose correctly on 10 of 10 turns (mood: angry, sad or neither; scene: combat, travel or conversation).
  • Earlier on this branch: a complete real Open-Jev 9B install under the allowlisted uv env (about 25 GB on disk), then the model answering through Test. The laptop slept during the second weight shard; restarting the install kept the verified first shard and only downloaded the rest. The resume logic is also covered by decision-sidecar-runtime.regression.ts.

Please verify manually:

  • In Connections > Connection defaults, the Decision model dropdown shows "None (decisions off)", and Decision statements per turn accepts 1 to 255 and saves on blur or Enter.
  • In a preset section, type {{#if decision:"The latest message moves the scene to a new place"}}MOVED{{/if}} with Decision model set to None, and confirm the warning appears under the field.
  • With a Decision model selected, send a message that moves the scene, and check in Peek Prompt that MOVED was sent. Regenerate and confirm the same branch is sent.
  • Import a preset or lorebook that contains a decision statement, and a PNG character card whose description contains one, and confirm the notice toast for each.
  • In a group chat set to Individual and Smart order, turn on Also use it to pick who speaks in Smart response order and confirm speakers are chosen without a visible delay.
  • Open Docs > Connections > Decision Models in the app and check the links to the agent, conditional prompt and group chat pages.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Changed user docs for the batched [docs-i18n] follow-up: docs/connections/decision-models.md (new), docs/agents/custom-agents.md (setup moved out), docs/prompts/conditional-prompts.md, docs/prompts/macros.md, docs/chats/group-chats.md, docs/connections/local-model.md.

UI evidence (if applicable)

Not captured by the agent. The UI changes are one checkbox, one number field, a warning line under macro fields, an import toast and a notice in Peek Prompt.

Summary by CodeRabbit

  • New Features
    • Added Decision model support for yes/no and choice-based prompt conditions. If a decision is unavailable, the condition evaluates as no.
    • Added controls for the number of decision questions per turn and for using the Decision model to choose speakers in Smart group chats.
    • Added Open-Jev 9B as an installable Decision model, with interrupted downloads able to resume.
    • Prompt previews and imports now flag decision statements when no Decision model is configured.
  • Documentation
    • Added guides to help configure Decision models and use decision statements in prompts and Smart response order.

🔄 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/6572 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/23/2026 **Status:** ✅ Merged **Merged:** 9/23/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/decision-open-jev-9b` --- ### 📝 Commits (10+) - [`5e5e42d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5e5e42db88c1b13b941ea2ba3d770de370755451) feat(agents): let the decision model pick who speaks in Smart order - [`5927fd3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5927fd3576d08610bbbd9dc5a48e8a85d1f35e2a) fix(agents): resume a decision model install instead of starting over - [`6a4f9e8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6a4f9e86ecad6fa53fc4b365602fd5843a130ee0) test(agents): cover Smart order with the switch on and no decision model - [`1a29e98`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1a29e986519414e2b8fe082f2ec4c0be374fe22a) docs(agents): say which Decision model to pick, including on Android - [`5e41348`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5e4134832770c17d6667b10d78d6953e4d81ecb8) feat(agents): offer Open-Jev 9B as a measured decision model - [`bc2c271`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bc2c27144a576a2374a425f5c16b1f0989d176df) feat(prompts): let prompt conditionals ask the Decision model - [`4a41775`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4a41775447093068a90b6d6fa89a32374f42ec1b) docs: add a Decision Models guide and decision statement docs - [`4e48ae1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4e48ae1eb80641075809e876264c7fca4c55d76a) docs: say post-processing decisions are asked once per reply, name real re-run controls - [`90840d2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/90840d2cd05e28532eff960cf4a84fafdec81ed2) docs: say where a decision block keeps or loses the prompt cache - [`18d69ea`](https://github.com/Pasta-Devs/Marinara-Engine/commit/18d69ea5d7a7cf1e6d7e3b42794f6d4c45ae5fdd) fix(prompts): ask decisions only for agents that run, and never fail a turn on them ### 📊 Changes **48 files changed** (+3281 additions, -116 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+10 -0) 📝 `docs/agents/custom-agents.md` (+28 -56) 📝 `docs/chats/group-chats.md` (+2 -0) ➕ `docs/connections/decision-models.md` (+141 -0) 📝 `docs/connections/local-model.md` (+2 -0) 📝 `docs/development/optional-agent-packages.md` (+16 -0) 📝 `docs/prompts/conditional-prompts.md` (+120 -0) 📝 `docs/prompts/macros.md` (+2 -0) 📝 `e2e/agent-activation-questions.e2e.ts` (+9 -0) 📝 `packages/client/src/components/chat/PeekPromptModal.tsx` (+23 -0) 📝 `packages/client/src/components/chat/chat-area.types.ts` (+2 -0) 📝 `packages/client/src/components/connections/DecisionDefaultControl.tsx` (+77 -1) 📝 `packages/client/src/components/modals/ImportCharacterModal.tsx` (+13 -4) 📝 `packages/client/src/components/modals/ImportLorebookModal.tsx` (+5 -0) 📝 `packages/client/src/components/modals/ImportPersonaModal.tsx` (+12 -4) 📝 `packages/client/src/components/modals/ImportPresetModal.tsx` (+8 -0) ➕ `packages/client/src/components/ui/DecisionStatementNote.tsx` (+32 -0) 📝 `packages/client/src/components/ui/MacroTextarea.tsx` (+2 -0) 📝 `packages/client/src/hooks/use-chats.ts` (+1 -0) 📝 `packages/client/src/hooks/use-decision-model.ts` (+37 -1) _...and 28 more files_ </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #6569 Closes #6559 (Smart order; group card relevance is left out on purpose, reasons in a comment on the issue) Follow-up to #6555 (the Open-Jev 9B entry and install resume left over from #6556) ## Why this change - **Prompt authors could not use the Decision model.** Presets, cards, lorebooks and agent prompts had to send "if X happens, do Y" on every turn. `{{#if decision:"..."}}` and `{{#if decision_choice:"..." == "option"}}` let them send an instruction only on the turns where it applies, using whatever Decision model the user picked (their own local model, a hosted connection, or Open-Jev). - **Smart response order paid for a full chat-model call per turn** to pick a speaker. With the Decision model it becomes one batched yes/no per character, and it falls back to the old call when the model is off or fails. - **Open-Jev 9B** was measured as more accurate than 2B, and an interrupted install started from zero every time. - **Decision models had no guide of their own.** Setup was buried in the custom agents page, so prompt makers, agent authors and Termux users had nowhere to start. ## What changed - **Decision statements in prompts (#6569).** New `decision:` and `decision_choice:` operands in the macro engine. The engine is synchronous, so each turn's statements are found in the raw sources first (preset sections, groups and choice blocks, character and persona fields, chat summary, group scenario, active lorebook entries, agent prompt templates), asked in one batch, cached for the turn, and handed to every place a condition is evaluated. A group block asks once per character. Unanswered reads as no, so a user with no Decision model gets the `{{else}}` branch. - Choice goes to System One as a real `choice` question with a "none of these" option; a local chat model answers it as one yes/no per option. - Agent prompt templates are covered too, but only for agents this chat actually runs. Post-processing agents are asked with the finished reply, and a regenerated swipe is asked again (the cache key includes the reply text). Re-running an agent (tracker refresh, retrying a failed agent, Re-run on an injection) reuses the turn's answers. - Conversation mode's system prompt (the chat's custom prompt or the preset's conversation prompt) is planned too. - A Decision model that cannot start or answer never fails a turn or a retry: its statements read as no. - A reasoning local model is skipped in front of the reply unless the user opted in, but is still asked after it. - New **Decision statements per turn** setting (default 32, max 255). - Peek Prompt and the dry-run route never ask; they report statements with no answer yet. - Fields that use a statement warn when no Decision model is set. Imports that contain statements say so, including PNG, `.charx` and `.marinara` files, which the server reports because only it reads them. - **Smart response order (#6559).** Optional switch under **Decision model**. One batched yes/no per candidate, the model's own threshold, and simple rules on top (the last speaker yields). Falls back to the chat-model selector on any failure. - **Open-Jev 9B** catalog entry with measured size, VRAM and calibration. Its time limit grows with the work in a request (`perQuestionMs` per statement and per Choice option, capped at 20 s). Measured on 9B: one yes/no takes about 0.5 s, and each Choice option adds about as much as another statement (a 10-option Choice took 3.3 s). - **Install resume.** Files that already finished are checked against their published size and checksum and kept, instead of downloading everything again. - **Docs.** New `docs/connections/decision-models.md` covering what a decision model is, the three ways to get one, which to pick (including Termux), thresholds, time limits, cost and troubleshooting. Setup moved there from `custom-agents.md`, which now covers decision statements in an agent's prompt. `conditional-prompts.md` gains the syntax, design rules, measured wording advice and "as designed" troubleshooting for prompt makers. `optional-agent-packages.md` gains notes for package and Game Mode Experience authors. The Local Model and group chat guides link to the new page. - UI strings that still said the Decision model only served activation questions now say what it does. ## 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 Run by the agent: - `pnpm check`, `pnpm localization:check` and `pnpm regression:node` (361 of 361 regressions pass) on the branch rebased onto staging `43f99a59e`. - Local CodeRabbit review of the whole branch (run once the CodeRabbit outage eased): 6 findings plus 2 on the docs, all fixed; the fixes drew 1 more, fixed, and the final commit reviewed clean. The two containment fixes (a Decision model that throws while starting) have no route test, because making backend resolution throw from a route test would mean patching internals; everything else has one. - New `scripts/regressions/decision-conditionals.regression.ts`, driven through the real generate, Peek Prompt, dry-run, retry-agents, import and decision routes against a fake System One server. It covers yes/no, Choice with its options on the wire, the per-turn cache on regenerate, a failing model, the limit setting, no model, pre-reply and post-processing agent templates, agents the chat does not run never being asked, a regenerated swipe being asked again, re-running agents reusing answers, Conversation mode's system prompt, Peek Prompt's report in Conversation mode, and the import flag for card and `.marinara` files. Each wiring point was mutation-checked: reverting it makes the regression fail. - Live Choice check through the engine's own client code: Open-Jev 9B (real System One `choice` questions) and Gemma 4 E4B as a local model (one yes/no per option) each chose correctly on 10 of 10 turns (mood: angry, sad or neither; scene: combat, travel or conversation). - Earlier on this branch: a complete real Open-Jev 9B install under the allowlisted uv env (about 25 GB on disk), then the model answering through **Test**. The laptop slept during the second weight shard; restarting the install kept the verified first shard and only downloaded the rest. The resume logic is also covered by `decision-sidecar-runtime.regression.ts`. Please verify manually: - In **Connections > Connection defaults**, the **Decision model** dropdown shows "None (decisions off)", and **Decision statements per turn** accepts 1 to 255 and saves on blur or Enter. - In a preset section, type `{{#if decision:"The latest message moves the scene to a new place"}}MOVED{{/if}}` with **Decision model** set to **None**, and confirm the warning appears under the field. - With a Decision model selected, send a message that moves the scene, and check in **Peek Prompt** that `MOVED` was sent. Regenerate and confirm the same branch is sent. - Import a preset or lorebook that contains a decision statement, and a PNG character card whose description contains one, and confirm the notice toast for each. - In a group chat set to Individual and Smart order, turn on **Also use it to pick who speaks in Smart response order** and confirm speakers are chosen without a visible delay. - Open **Docs > Connections > Decision Models** in the app and check the links to the agent, conditional prompt and group chat pages. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Changed user docs for the batched `[docs-i18n]` follow-up: `docs/connections/decision-models.md` (new), `docs/agents/custom-agents.md` (setup moved out), `docs/prompts/conditional-prompts.md`, `docs/prompts/macros.md`, `docs/chats/group-chats.md`, `docs/connections/local-model.md`. ## UI evidence (if applicable) Not captured by the agent. The UI changes are one checkbox, one number field, a warning line under macro fields, an import toast and a notice in Peek Prompt. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added Decision model support for yes/no and choice-based prompt conditions. If a decision is unavailable, the condition evaluates as no. - Added controls for the number of decision questions per turn and for using the Decision model to choose speakers in Smart group chats. - Added Open-Jev 9B as an installable Decision model, with interrupted downloads able to resume. - Prompt previews and imports now flag decision statements when no Decision model is configured. - **Documentation** - Added guides to help configure Decision models and use decision statements in prompts and Smart response order. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:17:44 +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#7230
No description provided.