[PR #8100] [MERGED] feat(mari): split big writes up front on a small output limit #8102

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8100
Author: @ylli-selmani
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @ylli-selmani

Base: staging ← Head: feat/mari-output-limit-handbooks


📝 Commits (7)

  • a46c89b feat(mari): ask for split writes up front when the output limit is small
  • ba53c89 docs(mari): tell the handbooks how to split writes on a small output limit
  • 477a166 test(mari): a cut claim after a dry run is redone smaller, not dry-run repaired
  • f2346fd fix(mari): ignore a Max Output Tokens the send map switches off
  • 0a0c9ba docs(mari): split lorebook creates on a small output limit too
  • 816d036 test(mari): pin the small-limit clause on the permanent lorebook line
  • 037b02d fix(mari): state a small output limit in the classic prompt too

📊 Changes

9 files changed (+107 additions, -9 deletions)

View changed files

📝 packages/server/src/assets/mari-skills/characters.md (+1 -0)
📝 packages/server/src/assets/mari-skills/extensions.md (+1 -0)
📝 packages/server/src/assets/mari-skills/lorebook.md (+1 -0)
📝 packages/server/src/assets/mari-skills/onboarding.md (+3 -0)
📝 packages/server/src/assets/mari-skills/presets.md (+1 -0)
📝 packages/server/src/assets/mari-skills/themes.md (+1 -0)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+32 -7)
📝 scripts/regressions/professor-mari/builtin-skills.regression.ts (+47 -2)
📝 scripts/regressions/professor-mari/pi-runtime.regression.ts (+20 -0)

📄 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

Part of #8096 (part 2 of the output-limit work; part 1 was #8090). Not Closes: theme partial-CSS edits still need their own Engine action, a separate follow-up PR.

Why this change

  • #8090 made Professor Mari recover after a reply hits the output limit. On a small limit (e.g. Gemma 3 12b with Max Output Tokens 1024–4096) it is better if she never gets cut in the first place.
  • The built-in handbooks told her to do big writes in one call ("a new character is one character.create with the full card", "create the whole payload in one call"). On a small limit that one call is exactly what gets cut.

What changed

Prompt (visible to the model only on small limits)

  • Both runtime prompts (pi and classic) add one line when the connection's output limit is 4096 tokens or less: split a large write into several calls, one per reply. Larger or unknown limits get nothing, so strong models are not told to fragment.
  • The line sits outside the capped knowledge block: the permanent prompt does not grow from it (15,714 characters before the lorebook clause below).
  • New mariMaxOutputTokens() resolves the limit for both the prompt and the request options, so they cannot disagree. A Max Output Tokens switched off in the connection's send map is never sent, so it no longer counts as the limit (the connection override or the model's known limit does).

Handbooks (assets/mari-skills/)
Each one that pushed a single big call now says what to do "when the output limit is small (your workspace rules say so, or a reply was cut at it)":

  • characters: create with name, description and personality, then one character.update per reply. This is an explicit exception to the "no placeholder" rule.
  • lorebook: create the book with its first entries, then one lorebook.addEntry per reply (never an empty book). The permanent-prompt lorebook line says the same in a short clause: the prompt is now 15,799 characters, still under the 15,850 cap.
  • presets: create with the markers and the first section, then one addSection/addChoiceBlock per reply, in prompt order. It builds on #8091's text, where preset.update refuses sections.
  • extensions: create with css or js, then add the other in an update (updates merge). serverJs cannot be split.
  • onboarding: send the card patch and the block in separate replies. The block goes only once the patch has applied (its readBack, or the user's Accept when held). The block itself cannot be split: each question list replaces the whole list.
  • themes: a stylesheet cannot be split, because every update replaces all of it. Keep it small and never send a cut one.
  • Home widgets are left alone: a whole create is under 600 characters.

Regressions

  • builtin-skills.regression.ts: the hint appears at 1024 and 4096, not at 8192 or with no limit, in both the pi and the classic prompt; a send-map-disabled 1024 does not count as the limit. Each of the six handbooks carries the small-limit line; with the themes line reverted, this check fails.
  • pi-runtime.regression.ts: after a dry-run write, an uncut "it is saved" claim draws the dry-run repair (control). The same claim cut at the limit gets the engine note instead.

Slices

  • B1: theme partial edit. Checked: css replaces the whole stylesheet and theme.update reads only name/css. Out of scope here: the Engine action is a separate PR.
  • B2: up-front hint (a46c89b0a)
  • B3: handbook lines (ba53c89d7)
  • B4: cut claim vs dry-run repair (477a166bd)
  • Local CodeRabbit: 1 finding, fixed in f2346fd76 (a Max Output Tokens switched off in the send map still counted as the limit; regression fails on the old code). The rerun hit the 3/hour quota, so the GitHub review covers the final push.
  • Dottore round 1: lorebooks kept the one-call rule. Fixed in 0a0c9baf5; the permanent-prompt clause is pinned by a regression in 816d036eb
  • Dottore round 2: the classic prompt carried the "small output limit" clause without stating the limit. Fixed in 037b02d77: one shared rule line, fed to both prompts

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

Agent-run results: pnpm check passed. node ./scripts/run-regressions.mjs --filter regressions/professor-mari/ (20/20) and --filter regressions/mari/ (35/35) passed, as did mari-package-service and professor-mari-onboarding-guidance (classic-prompt callers). No live run against a small-output model yet.

Manual verification notes

  • Manually verify: with Max Output Tokens at 2048, ask Mari for a full character and check she creates the card with the core fields, then adds the rest in follow-up updates instead of getting cut.
  • Manually verify: with Max Output Tokens at 8192 or unset, the same request still makes one character.create with the full card.
  • Manually verify: at 2048, onboarding with a character question sends the card patch first and the block in a later reply, and the block validates with no "unused" warnings (try Manual mode too).
  • Manually verify: at 2048, a theme request stays small and Mari does not send a partial stylesheet.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) 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)

The handbooks are Mari's own prompt assets, not user docs under docs/, so no translation follow-up.

UI evidence (if applicable)

None: nothing on screen changes. The effect is in what Mari sends on a small-limit connection.

@SpicyMarinara

🤖 Generated with Claude Code


🔄 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/8100 **Author:** [@ylli-selmani](https://github.com/ylli-selmani) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@ylli-selmani](https://github.com/ylli-selmani) **Base:** `staging` ← **Head:** `feat/mari-output-limit-handbooks` --- ### 📝 Commits (7) - [`a46c89b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a46c89b0a8a859a85c37006aa7b454f5730306b9) feat(mari): ask for split writes up front when the output limit is small - [`ba53c89`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ba53c89d7a1d926aeff33a5cbed9db78483cffd1) docs(mari): tell the handbooks how to split writes on a small output limit - [`477a166`](https://github.com/Pasta-Devs/Marinara-Engine/commit/477a166bd1bec2f744885578506eaadcc9e6e9ad) test(mari): a cut claim after a dry run is redone smaller, not dry-run repaired - [`f2346fd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f2346fd7660b855dad9e3379128b3b29a21ff52a) fix(mari): ignore a Max Output Tokens the send map switches off - [`0a0c9ba`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0a0c9baf52f8320b0a255fe97663e635241dfce8) docs(mari): split lorebook creates on a small output limit too - [`816d036`](https://github.com/Pasta-Devs/Marinara-Engine/commit/816d036eb47f89d7ae85bcd45ff6e06ce7bb2341) test(mari): pin the small-limit clause on the permanent lorebook line - [`037b02d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/037b02d777106e47996b12a00c7147d148249339) fix(mari): state a small output limit in the classic prompt too ### 📊 Changes **9 files changed** (+107 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/assets/mari-skills/characters.md` (+1 -0) 📝 `packages/server/src/assets/mari-skills/extensions.md` (+1 -0) 📝 `packages/server/src/assets/mari-skills/lorebook.md` (+1 -0) 📝 `packages/server/src/assets/mari-skills/onboarding.md` (+3 -0) 📝 `packages/server/src/assets/mari-skills/presets.md` (+1 -0) 📝 `packages/server/src/assets/mari-skills/themes.md` (+1 -0) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+32 -7) 📝 `scripts/regressions/professor-mari/builtin-skills.regression.ts` (+47 -2) 📝 `scripts/regressions/professor-mari/pi-runtime.regression.ts` (+20 -0) </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 Part of #8096 (part 2 of the output-limit work; part 1 was #8090). Not `Closes`: theme partial-CSS edits still need their own Engine action, a separate follow-up PR. ## Why this change - #8090 made Professor Mari recover after a reply hits the output limit. On a small limit (e.g. Gemma 3 12b with Max Output Tokens 1024–4096) it is better if she never gets cut in the first place. - The built-in handbooks told her to do big writes in one call ("a new character is one `character.create` with the full card", "create the whole payload in one call"). On a small limit that one call is exactly what gets cut. ## What changed **Prompt (visible to the model only on small limits)** - Both runtime prompts (pi and classic) add one line when the connection's output limit is 4096 tokens or less: split a large write into several calls, one per reply. Larger or unknown limits get nothing, so strong models are not told to fragment. - The line sits outside the capped knowledge block: the permanent prompt does not grow from it (15,714 characters before the lorebook clause below). - New `mariMaxOutputTokens()` resolves the limit for both the prompt and the request options, so they cannot disagree. A Max Output Tokens switched off in the connection's send map is never sent, so it no longer counts as the limit (the connection override or the model's known limit does). **Handbooks (`assets/mari-skills/`)** Each one that pushed a single big call now says what to do "when the output limit is small (your workspace rules say so, or a reply was cut at it)": - characters: create with `name`, `description` and `personality`, then one `character.update` per reply. This is an explicit exception to the "no placeholder" rule. - lorebook: create the book with its first entries, then one `lorebook.addEntry` per reply (never an empty book). The permanent-prompt lorebook line says the same in a short clause: the prompt is now 15,799 characters, still under the 15,850 cap. - presets: create with the markers and the first section, then one `addSection`/`addChoiceBlock` per reply, in prompt order. It builds on #8091's text, where `preset.update` refuses `sections`. - extensions: create with `css` or `js`, then add the other in an update (updates merge). `serverJs` cannot be split. - onboarding: send the card patch and the block in separate replies. The block goes only once the patch has applied (its `readBack`, or the user's Accept when held). The block itself cannot be split: each question list replaces the whole list. - themes: a stylesheet cannot be split, because every update replaces all of it. Keep it small and never send a cut one. - Home widgets are left alone: a whole create is under 600 characters. **Regressions** - `builtin-skills.regression.ts`: the hint appears at 1024 and 4096, not at 8192 or with no limit, in both the pi and the classic prompt; a send-map-disabled 1024 does not count as the limit. Each of the six handbooks carries the small-limit line; with the themes line reverted, this check fails. - `pi-runtime.regression.ts`: after a dry-run write, an uncut "it is saved" claim draws the dry-run repair (control). The same claim cut at the limit gets the engine note instead. **Slices** - [x] B1: theme partial edit. Checked: `css` replaces the whole stylesheet and `theme.update` reads only `name`/`css`. Out of scope here: the Engine action is a separate PR. - [x] B2: up-front hint (`a46c89b0a`) - [x] B3: handbook lines (`ba53c89d7`) - [x] B4: cut claim vs dry-run repair (`477a166bd`) - [x] Local CodeRabbit: 1 finding, fixed in `f2346fd76` (a Max Output Tokens switched off in the send map still counted as the limit; regression fails on the old code). The rerun hit the 3/hour quota, so the GitHub review covers the final push. - [x] Dottore round 1: lorebooks kept the one-call rule. Fixed in `0a0c9baf5`; the permanent-prompt clause is pinned by a regression in `816d036eb` - [x] Dottore round 2: the classic prompt carried the "small output limit" clause without stating the limit. Fixed in `037b02d77`: one shared rule line, fed to both prompts ## 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` Agent-run results: `pnpm check` passed. `node ./scripts/run-regressions.mjs --filter regressions/professor-mari/` (20/20) and `--filter regressions/mari/` (35/35) passed, as did `mari-package-service` and `professor-mari-onboarding-guidance` (classic-prompt callers). No live run against a small-output model yet. ### Manual verification notes - Manually verify: with Max Output Tokens at 2048, ask Mari for a full character and check she creates the card with the core fields, then adds the rest in follow-up updates instead of getting cut. - Manually verify: with Max Output Tokens at 8192 or unset, the same request still makes one `character.create` with the full card. - Manually verify: at 2048, onboarding with a character question sends the card patch first and the block in a later reply, and the block validates with no "unused" warnings (try Manual mode too). - Manually verify: at 2048, a theme request stays small and Mari does not send a partial stylesheet. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) 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) The handbooks are Mari's own prompt assets, not user docs under `docs/`, so no translation follow-up. ## UI evidence (if applicable) None: nothing on screen changes. The effect is in what Mari sends on a small-limit connection. @SpicyMarinara 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:10:23 +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#8102
No description provided.