mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #8376] [MERGED] perf(mari): smaller write results and a cache-stable system prompt #8323
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#8323
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/8376
Author: @ylli-selmani
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ylli-selmani
Base:
staging← Head:perf/prompt-diet📝 Commits (4)
6a5a5daperf(mari): stop re-sending what a write's tool call already carried5373c27perf(mari): put the per-turn context lines last in her system prompt6e60ebdperf(mari): keep the text tool block in the cached prompt prefix1277e0afix(mari): find the per-turn prompt block by message, not by text📊 Changes
5 files changed (+151 additions, -20 deletions)
View changed files
📝
packages/server/src/services/professor-mari/pi-runtime.ts(+20 -6)📝
packages/server/src/services/professor-mari/workspace-agent.service.ts(+35 -12)📝
packages/server/src/services/professor-mari/workspace-commands.ts(+1 -1)📝
scripts/regressions/mari-write-readback.regression.ts(+56 -0)📝
scripts/regressions/professor-mari/pi-runtime.regression.ts(+39 -1)📄 Description
Linked issue
Closes #8375
Why this change
On a small-context model (12b, 16k), Professor Mari runs out of room partway through a task. The permanent prompt is large, but the faster drain is how much each tool turn adds: about 12k chars per turn in a measured Gemma 4 31b run. Much of that is text the model already has:
character.createresult was 8,581 chars. Of those, 2,934 were the call's arguments echoed back in an<input>block, and 515 were the same arguments again as thecommandstring.changedFieldsOnlycompared fields only one level deep, so a description-onlycharacter.updatereturned the wholedata.extensionsobject (where onboarding lives) whenever anything inside it differed. Mari hit the 32,000-char result cut this way.<workspace_context>block (withcurrentTimeand this turn's message id) sat third in the system prompt, so everything after it, including the skill index and the memories, changed on every turn.What changed
Write results (
workspace-agent.service.ts,pi-runtime.ts)changedFieldsOnlydiffs nested records at any depth (capped at 8 levels). Arrays are still compared and shown whole.<input>block, since the native tool call already carries the arguments. The opening tag keeps the tool name and gains the action, e.g.<workspace_command_result name="app_data" action="character.create" success="true">. The classic JSON runtime is unchanged, because its model has no separate tool call to look back at.app_datamutation result drops itscommandstring.mariCLI commands keep it. The raw result, which the change card, receipts and keep/undo read, is untouched.Prompt order (
workspace-agent.service.ts)<workspace_context>is now the last of the prompt blocks, after the skill index, memories, permissions mode and understood-request record. Nothing in it is removed or reworded;decisionAuthoringstays JSON because it carries pending Decision questions and consent records.pi-runtime.ts), the<text_tool_calls>block now goes just before<workspace_context>instead of after the whole prompt, so it stays in the cached part too.Regressions (
mari-write-readback,pi-runtime)extensions.onboarding, with no sibling keys and no unchangeddatafields. Proven to bite: it fails with the old one-level diff.app_dataresults have nocommand; amari db patchresult keeps it.echoInput: falsedrops<input>and names the action; the default still echoes it.<workspace_context>follows the tool rules and the skill index, and only pi's own<cwd>line comes after it. Proven to bite: it fails with the old order.<text_tool_calls>before<workspace_context>. Proven to bite: it fails with the old append.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Agent-run checks:
pnpm checkexits 0.node scripts/run-regressions.mjs --filterpasses formari-write-readback,professor-mari(23/23),mari-(18/18),scripts/regressions/mari/(35/35) andpi-runtime.Still to check by hand:
<input>block.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)UI evidence (if applicable)
No UI changes. The change is in what Mari's model receives.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
[PR #8376] perf(mari): smaller write results and a cache-stable system promptto [PR #8376] [MERGED] perf(mari): smaller write results and a cache-stable system prompt