[PR #7523] [MERGED] Professor Mari: experimental pi runtime, switchable in her settings #7774

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7523
Author: @Gunterlie
Created: 10/13/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @Gunterlie

Base: feat/mari-pi-runtime ← Head: feat/mari-pi-runtime-2-pi


📝 Commits (10+)

  • b999a87 Add pi-coding-agent 1.1.0 to the server
  • 234ddae Add the mariRuntime setting, status fields and route
  • 8cba364 Pin pi 1.2.0 and split the workspace knowledge prompt from the JSON protocol
  • de61130 Add the pi runtime loop and branch Professor Mari's prompt to it
  • 3ef8245 Add the pi runtime regression
  • d0c89fd Keep the classic loop header and the Permissions Mode floor text intact
  • a0bba05 Format the pi runtime changes
  • 86c3c88 Add the Professor Mari runtime switch to the omnibar settings
  • 6100eb9 Review each pi turn on turn_end, replay provider metadata, end chip-only turns, fail closed on the tool set
  • 0cdd3f5 End chip-only pi turns only when they carry text; reset the understood-request record before the prompt

📊 Changes

15 files changed (+2649 additions, -82 deletions)

View changed files

📝 docs/home/professor-mari.md (+8 -0)
📝 packages/client/src/components/layout/omnibar/OmnibarSettingsMenu.tsx (+88 -0)
📝 packages/client/src/lib/settings-registry.ts (+8 -0)
📝 packages/client/src/localization/locales/en.json (+6 -0)
📝 packages/server/package.json (+2 -0)
📝 packages/server/src/routes/professor-mari-workspace.routes.ts (+22 -1)
📝 packages/server/src/services/mari-db/mari-db.service.ts (+10 -0)
➕ packages/server/src/services/professor-mari/pi-runtime.ts (+673 -0)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+258 -67)
📝 packages/server/src/services/professor-mari/workspace-round-review.ts (+2 -2)
➕ packages/shared/src/constants/mari-runtime.ts (+15 -0)
📝 packages/shared/src/index.ts (+1 -0)
📝 packages/shared/src/types/professor-mari-workspace.ts (+7 -0)
📝 pnpm-lock.yaml (+925 -12)
➕ scripts/regressions/professor-mari/pi-runtime.regression.ts (+624 -0)

📄 Description

Linked issue

No linked issue. This is planned work: slice 2 of 2 on the integration branch feat/mari-pi-runtime. It is stacked on slice 1 (#7520) and targets that branch, so the diff shows only this slice; retarget to feat/mari-pi-runtime once #7520 is merged.

Why this change

  • Professor Mari's runtime sends tools as a JSON text protocol. Because of that it turns reasoning off on most connections, stops after 12 command rounds and keeps only the last 40 messages. Strong models work below their level.
  • Pi was Professor Mari's first runtime (#2557) and was replaced in #2805 because pi needs native tool calls. Since then the provider layer learned native tool calls, and pi reached 1.x.
  • This slice adds pi back as a second, experimental runtime that the user can switch on, so the two can be compared on real use. Classic stays the default and is untouched.

What changed

  • Setting. Global mariRuntime: classic (default) or pi. GET/PUT /runtime next to /permissions-mode, same privileged gate. The workspace status reports runtimeSelected, runtimeActive, runtimeNote. Professor Mari cannot change the key through raw DB writes.
  • Settings UI. A "Runtime" row below "Permissions mode" in Search and Professor Mari settings, with a help line and a fallback line. English locale keys only.
  • Pi runtime (pi-runtime.ts). pi's agent loop drives the run. Model requests go through Marinara's own provider layer; no pi auth, no pi model registry, nothing read from or written to ~/.pi. pi's built-in tools are off; the only tools are Marinara's, executed through WorkspaceCommands from slice 1. Session creation fails closed if any active tool is not Marinara's. No extensions, skills, context files or MCP config are loaded.
  • Same guards. Permissions Mode floors live in the shared executor. The per-round review from slice 1 runs on every pi turn. Manual holds every un-approved change, with or without visible text. The run after an Accept applies only its first round with a change. Messages are stored through the shared message store, so cards, Undo and history match classic.
  • Reasoning. Pi passes the connection's own reasoning settings, as normal chat generation does. Classic still sends none.
  • Fallback. The local sidecar, claude_subscription, grok_subscription and providers without native tool calls run classic; the status and the settings row say so.
  • Limits. No 12-round cap (safety cap MAX_PI_TOOL_ROUNDS = 400). pi compacts context inside a long run.
  • Prompt. The app-data reference and authoring guides were inside the JSON protocol prompt; they are now a shared block used by both runtimes. The classic prompt is byte-identical.
  • Dependency. @earendil-works/pi-coding-agent and pi-ai pinned at exact 1.2.0 (91 packages in the lockfile, no install scripts, no native binaries).
  • Docs. docs/home/professor-mari.md has a short section on the Pi runtime.

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

Not done by a person yet. To verify by hand:

  • Manually verify the Runtime row in Search and Professor Mari settings: switch to Pi, ask Professor Mari to create and then edit a character, check the change card and Undo.
  • Manually verify Manual mode on Pi: a change is held, Accept applies it, a second change in the same chat is held again.
  • Manually verify Plan mode on Pi refuses a change.
  • Manually verify Stop ends a Pi run at once.
  • Manually verify a connection through the native Anthropic provider with thinking on, and one through the Gemini provider, over several tool rounds on Pi. No agent tested these (see Proof).
  • Manually verify the fallback line with the local model selected, and with a remote connection that has no tool calls.
  • Manually verify the row in light mode, the sillytavern theme and with a screen reader.
  • Manually verify a fresh install on Android (Termux): pnpm install must succeed with the pi packages.
  • Manually verify the shell sandbox on a host with bwrap.

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)

docs/home/professor-mari.md changed. The docs-i18n follow-up is still owed; it belongs with the final PR from feat/mari-pi-runtime into staging.

UI evidence (if applicable)

Screenshots at 390 / 768 / 1440 px (classic, Pi, Pi with fallback) were taken by an agent on a local build and are not uploaded here. A person should attach fresh ones.

Proof

Run by agents on commit cfabb606a (the docs commit on top changes no code):

  • pnpm check: exit 0. Server typecheck clean.
  • node ./scripts/run-regressions.mjs --filter mari: 50/50 passed.
  • scripts/regressions/professor-mari/pi-runtime.regression.ts (new, scripted fake provider, no network): passed. It covers tool execution through WorkspaceCommands, Manual hold with and without text, the Accept run, Plan, Bypass, abort, the classic fallback, the closed tool set, provider-metadata replay, invalid tool calls, the round cap, chips, reasoning options and false "held" claims.
  • pnpm localization:check: passed.
  • Read-only adversarial review (Opus), three passes. Sound: sandbox boundary, Permissions Mode floors, abort and cleanup, the route gate, byte-identical classic prompt. Every finding from the three passes is fixed in this branch.
  • Local CodeRabbit, three runs: 6 findings (1 major, 4 minor, 1 trivial), all fixed.

Real models, through an OpenAI-compatible gateway on a private data copy (Claude Sonnet 5.5 with thinking, MiniMax M3, DeepSeek V4 Flash with thinking), results judged from stored data:

  • First pass, 8 tasks per runtime: Pi matched classic on correctness, used fewer model requests on most tasks, logged no protocol-repair warnings (classic logged them in 6 runs) and finished one task in 13 requests, past classic's cap.
  • Reasoning: with effort medium on the connection the Pi request log shows Effort: medium; classic shows none.
  • Manual hold and Accept on Pi: passed on Sonnet and DeepSeek in every run.

Known failures and limits:

  • MiniMax M3, Manual Accept is unreliable on both runtimes. On the final build Pi failed 1 of 2 runs (the model answered "She goes by Pi Test Wolf now… The read-back verified it" with no tool call; the completion-claim audit did not match that wording), and classic failed 2 of 2 (it invented a character id, then held the change again). Nothing was applied without approval in any run. Root cause is shared: after Accept, the model has to issue the change again. Proposed follow-up for both runtimes: the server applies the stored held calls itself on Accept.
  • The Accept pass is tied to the turn, not to the exact held calls (marked ponytail: in pi-runtime.ts). Same trust model as classic's silent frames.
  • No run went through the native Anthropic or Gemini provider. Replay of thinking data across tool rounds on those providers is covered only by the scripted regression.
  • pi's compaction was not exercised by any test. Summaries do not persist across turns.
  • Several read calls in one round run one after another on Pi.
  • The false "held" claim detector matches English wording only.
  • Existing behavior, not changed here: openai.provider.ts (near lines 1913 and 2123) drops the visible text when it parses a tool call written as text, so a question next to such a call never reaches the approval checks. This affects both runtimes.
  • pi 1.2.0 was younger than the repo's 24 h minimumReleaseAge at install time. It was installed once with the age check off for @earendil-works/* on the command line; pnpm-workspace.yaml is unchanged. From 2026-10-13 23:03 UTC the versions pass the rule on their own.

🔄 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/7523 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `feat/mari-pi-runtime` ← **Head:** `feat/mari-pi-runtime-2-pi` --- ### 📝 Commits (10+) - [`b999a87`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b999a87d958b6087c91360c03a26ed6f6bb455f7) Add pi-coding-agent 1.1.0 to the server - [`234ddae`](https://github.com/Pasta-Devs/Marinara-Engine/commit/234ddaebcd30c9a709d7e9562c65da982abf1e4a) Add the mariRuntime setting, status fields and route - [`8cba364`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8cba364f0f08f35d63e6728ebd718d5c69edfd9d) Pin pi 1.2.0 and split the workspace knowledge prompt from the JSON protocol - [`de61130`](https://github.com/Pasta-Devs/Marinara-Engine/commit/de61130507dfe0662bcadebabb011d70d5b6e214) Add the pi runtime loop and branch Professor Mari's prompt to it - [`3ef8245`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3ef8245565bfff386b8d577c38422ac006e45ca1) Add the pi runtime regression - [`d0c89fd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d0c89fd17e7e5ee4dd19d9a816ee2c71358b1e29) Keep the classic loop header and the Permissions Mode floor text intact - [`a0bba05`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a0bba05e0508b0f2853a34e1018fdb37bbae1ffd) Format the pi runtime changes - [`86c3c88`](https://github.com/Pasta-Devs/Marinara-Engine/commit/86c3c88b4c19768bb0d297661b3d94e2ff39de83) Add the Professor Mari runtime switch to the omnibar settings - [`6100eb9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6100eb997b5e007cf347369fcddb129e0a4a04ae) Review each pi turn on turn_end, replay provider metadata, end chip-only turns, fail closed on the tool set - [`0cdd3f5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0cdd3f5c97a8d1b823c84ef4408d78e47c11407a) End chip-only pi turns only when they carry text; reset the understood-request record before the prompt ### 📊 Changes **15 files changed** (+2649 additions, -82 deletions) <details> <summary>View changed files</summary> 📝 `docs/home/professor-mari.md` (+8 -0) 📝 `packages/client/src/components/layout/omnibar/OmnibarSettingsMenu.tsx` (+88 -0) 📝 `packages/client/src/lib/settings-registry.ts` (+8 -0) 📝 `packages/client/src/localization/locales/en.json` (+6 -0) 📝 `packages/server/package.json` (+2 -0) 📝 `packages/server/src/routes/professor-mari-workspace.routes.ts` (+22 -1) 📝 `packages/server/src/services/mari-db/mari-db.service.ts` (+10 -0) ➕ `packages/server/src/services/professor-mari/pi-runtime.ts` (+673 -0) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+258 -67) 📝 `packages/server/src/services/professor-mari/workspace-round-review.ts` (+2 -2) ➕ `packages/shared/src/constants/mari-runtime.ts` (+15 -0) 📝 `packages/shared/src/index.ts` (+1 -0) 📝 `packages/shared/src/types/professor-mari-workspace.ts` (+7 -0) 📝 `pnpm-lock.yaml` (+925 -12) ➕ `scripts/regressions/professor-mari/pi-runtime.regression.ts` (+624 -0) </details> ### 📄 Description ## Linked issue No linked issue. This is planned work: slice 2 of 2 on the integration branch `feat/mari-pi-runtime`. It is stacked on slice 1 (#7520) and targets that branch, so the diff shows only this slice; retarget to `feat/mari-pi-runtime` once #7520 is merged. ## Why this change - Professor Mari's runtime sends tools as a JSON text protocol. Because of that it turns reasoning off on most connections, stops after 12 command rounds and keeps only the last 40 messages. Strong models work below their level. - Pi was Professor Mari's first runtime (#2557) and was replaced in #2805 because pi needs native tool calls. Since then the provider layer learned native tool calls, and pi reached 1.x. - This slice adds pi back as a second, experimental runtime that the user can switch on, so the two can be compared on real use. Classic stays the default and is untouched. ## What changed - **Setting.** Global `mariRuntime`: `classic` (default) or `pi`. `GET`/`PUT /runtime` next to `/permissions-mode`, same privileged gate. The workspace status reports `runtimeSelected`, `runtimeActive`, `runtimeNote`. Professor Mari cannot change the key through raw DB writes. - **Settings UI.** A "Runtime" row below "Permissions mode" in Search and Professor Mari settings, with a help line and a fallback line. English locale keys only. - **Pi runtime** (`pi-runtime.ts`). pi's agent loop drives the run. Model requests go through Marinara's own provider layer; no pi auth, no pi model registry, nothing read from or written to `~/.pi`. pi's built-in tools are off; the only tools are Marinara's, executed through `WorkspaceCommands` from slice 1. Session creation fails closed if any active tool is not Marinara's. No extensions, skills, context files or MCP config are loaded. - **Same guards.** Permissions Mode floors live in the shared executor. The per-round review from slice 1 runs on every pi turn. Manual holds every un-approved change, with or without visible text. The run after an Accept applies only its first round with a change. Messages are stored through the shared message store, so cards, Undo and history match classic. - **Reasoning.** Pi passes the connection's own reasoning settings, as normal chat generation does. Classic still sends `none`. - **Fallback.** The local sidecar, `claude_subscription`, `grok_subscription` and providers without native tool calls run classic; the status and the settings row say so. - **Limits.** No 12-round cap (safety cap `MAX_PI_TOOL_ROUNDS` = 400). pi compacts context inside a long run. - **Prompt.** The app-data reference and authoring guides were inside the JSON protocol prompt; they are now a shared block used by both runtimes. The classic prompt is byte-identical. - **Dependency.** `@earendil-works/pi-coding-agent` and `pi-ai` pinned at exact `1.2.0` (91 packages in the lockfile, no install scripts, no native binaries). - **Docs.** `docs/home/professor-mari.md` has a short section on the Pi runtime. ## 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 Not done by a person yet. To verify by hand: - Manually verify the Runtime row in Search and Professor Mari settings: switch to Pi, ask Professor Mari to create and then edit a character, check the change card and Undo. - Manually verify Manual mode on Pi: a change is held, Accept applies it, a second change in the same chat is held again. - Manually verify Plan mode on Pi refuses a change. - Manually verify Stop ends a Pi run at once. - Manually verify a connection through the native Anthropic provider with thinking on, and one through the Gemini provider, over several tool rounds on Pi. No agent tested these (see Proof). - Manually verify the fallback line with the local model selected, and with a remote connection that has no tool calls. - Manually verify the row in light mode, the `sillytavern` theme and with a screen reader. - Manually verify a fresh install on Android (Termux): `pnpm install` must succeed with the pi packages. - Manually verify the shell sandbox on a host with `bwrap`. ## 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) `docs/home/professor-mari.md` changed. The `docs-i18n` follow-up is still owed; it belongs with the final PR from `feat/mari-pi-runtime` into `staging`. ## UI evidence (if applicable) Screenshots at 390 / 768 / 1440 px (classic, Pi, Pi with fallback) were taken by an agent on a local build and are not uploaded here. A person should attach fresh ones. ## Proof Run by agents on commit `cfabb606a` (the docs commit on top changes no code): - `pnpm check`: exit 0. Server typecheck clean. - `node ./scripts/run-regressions.mjs --filter mari`: 50/50 passed. - `scripts/regressions/professor-mari/pi-runtime.regression.ts` (new, scripted fake provider, no network): passed. It covers tool execution through `WorkspaceCommands`, Manual hold with and without text, the Accept run, Plan, Bypass, abort, the classic fallback, the closed tool set, provider-metadata replay, invalid tool calls, the round cap, chips, reasoning options and false "held" claims. - `pnpm localization:check`: passed. - Read-only adversarial review (Opus), three passes. Sound: sandbox boundary, Permissions Mode floors, abort and cleanup, the route gate, byte-identical classic prompt. Every finding from the three passes is fixed in this branch. - Local CodeRabbit, three runs: 6 findings (1 major, 4 minor, 1 trivial), all fixed. Real models, through an OpenAI-compatible gateway on a private data copy (Claude Sonnet 5.5 with thinking, MiniMax M3, DeepSeek V4 Flash with thinking), results judged from stored data: - First pass, 8 tasks per runtime: Pi matched classic on correctness, used fewer model requests on most tasks, logged no protocol-repair warnings (classic logged them in 6 runs) and finished one task in 13 requests, past classic's cap. - Reasoning: with effort `medium` on the connection the Pi request log shows `Effort: medium`; classic shows `none`. - Manual hold and Accept on Pi: passed on Sonnet and DeepSeek in every run. Known failures and limits: - **MiniMax M3, Manual Accept is unreliable on both runtimes.** On the final build Pi failed 1 of 2 runs (the model answered "She goes by Pi Test Wolf now… The read-back verified it" with no tool call; the completion-claim audit did not match that wording), and classic failed 2 of 2 (it invented a character id, then held the change again). Nothing was applied without approval in any run. Root cause is shared: after Accept, the model has to issue the change again. Proposed follow-up for both runtimes: the server applies the stored held calls itself on Accept. - The Accept pass is tied to the turn, not to the exact held calls (marked `ponytail:` in `pi-runtime.ts`). Same trust model as classic's silent frames. - No run went through the native Anthropic or Gemini provider. Replay of thinking data across tool rounds on those providers is covered only by the scripted regression. - pi's compaction was not exercised by any test. Summaries do not persist across turns. - Several read calls in one round run one after another on Pi. - The false "held" claim detector matches English wording only. - Existing behavior, not changed here: `openai.provider.ts` (near lines 1913 and 2123) drops the visible text when it parses a tool call written as text, so a question next to such a call never reaches the approval checks. This affects both runtimes. - pi 1.2.0 was younger than the repo's 24 h `minimumReleaseAge` at install time. It was installed once with the age check off for `@earendil-works/*` on the command line; `pnpm-workspace.yaml` is unchanged. From 2026-10-13 23:03 UTC the versions pass the rule on their own. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:07:24 +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#7774
No description provided.