[PR #7570] [MERGED] Add an experimental Pi runtime for Professor Mari #7806

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

📋 Pull Request Information

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

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


📝 Commits (10+)

  • d29a2df Move Mari's workspace tool commands into WorkspaceCommands
  • d2817ed Keep executeWorkspaceCommand delegate reachable for scripts
  • 466db9a Extract Mari's per-round safety review into workspace-round-review
  • 0ff8b5b Extract Mari's message storage into workspace-message-store
  • 11f7340 Pin the round-review call sites in the run loop and format touched regressions
  • 5985535 Mark type-only imports in workspace-commands
  • 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

📊 Changes

40 files changed (+5777 additions, -1434 deletions)

View changed files

📝 docs/home/professor-mari.md (+8 -0)
📝 packages/client/src/components/chat/mari/MariTranscript.tsx (+1 -0)
📝 packages/client/src/components/chat/mari/MariWorkTimeline.tsx (+33 -6)
📝 packages/client/src/components/chat/mari/use-mari-workspace-run.ts (+17 -1)
📝 packages/client/src/components/layout/omnibar/OmnibarSettingsMenu.tsx (+88 -0)
📝 packages/client/src/lib/mari-referenced-resources.ts (+20 -0)
📝 packages/client/src/lib/settings-registry.ts (+8 -0)
📝 packages/client/src/localization/locales/en.json (+8 -0)
📝 packages/client/src/stores/chat.store.ts (+13 -0)
📝 packages/client/src/styles/mari.css (+17 -0)
📝 packages/server/package.json (+2 -0)
📝 packages/server/src/routes/generate.routes.ts (+22 -7)
📝 packages/server/src/routes/professor-mari-workspace.routes.ts (+22 -1)
📝 packages/server/src/services/llm/providers/openai.provider.ts (+3 -3)
📝 packages/server/src/services/llm/textual-tool-call-parser.ts (+250 -23)
📝 packages/server/src/services/mari-db/mari-db.service.ts (+10 -0)
➕ packages/server/src/services/professor-mari/pi-runtime.ts (+946 -0)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+613 -1337)
➕ packages/server/src/services/professor-mari/workspace-commands.ts (+1090 -0)
➕ packages/server/src/services/professor-mari/workspace-message-store.ts (+115 -0)

...and 20 more files

📄 Description

Linked issue

No linked issue. This is planned work: the integration branch for the experimental Pi runtime for Professor Mari. It carries the five reviewed slices #7520, #7523, #7533, #7546 and #7567, plus a merge of current staging.

Why this change

  • Professor Mari's classic 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 needed native tool calls. Since then the provider layer learned native tool calls, and pi reached 1.x.
  • This PR 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.

What changed

  • Setting. Global mariRuntime: classic (default) or pi, with a Runtime row below Permissions mode in Search and Professor Mari settings. GET/PUT /runtime sits next to /permissions-mode behind the same privileged gate. Professor Mari cannot change the key through raw DB writes.
  • Shared command layer (slice 1, #7520). The command execution, the Permissions Mode floors, the per-round review and the message store moved out of the classic loop so both runtimes use the same code. Classic behaviour and its prompt are unchanged.
  • Pi runtime (slice 2, #7523). pi's agent loop drives the run. Model requests go through Marinara's own provider layer: no pi auth, no pi model registry, no network refresh, nothing read from or written to ~/.pi. pi's built-in tools are off; the only tools are Marinara's. Session creation fails closed if any active tool is not Marinara's. No extensions, skills, context files or MCP config are loaded. Pi passes the connection's own reasoning settings. There is no 12-round cap (safety cap 400) and pi compacts context inside a long run.
  • Accept applies on the server (slice 3, #7533). In Manual mode, the held calls are stored with the message. Accept applies exactly those calls without another model request, once, on both runtimes. Suggestion chips and plans work on Pi.
  • Parity (slice 4, #7546). Pi now runs on every connection. Connections without native tool calls (the local model, claude_subscription, grok_subscription) use a textual tool-call mode. Pi also got the empty-answer retry, the duplicate-call skip, parallel reads, a summary at the round limit and the cut-off reply guard.
  • Polish (slice 5, #7567). Professor Mari's words show live while she writes. A batch step shows its items on its step row. The shared textual tool-call parser reads DeepSeek (DSML, V3/R1), Kimi K2, GLM, Qwen3-Coder, MiniMax M2 and Mistral markup, in linear time. The OpenAI-compatible provider keeps the prose that a model writes beside a textual tool call; this also affects roleplay chats with function calling.
  • Dependency. @earendil-works/pi-coding-agent and @earendil-works/pi-ai pinned at exact 1.2.0. They add 86 packages to the lockfile: MIT (43), Apache-2.0 (35), BSD-3-Clause (3), ISC (3), Unlicense (1), BlueOak-1.0.0 (1). All are permissive and compatible with AGPL-3.0. 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 on this merged state. 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 both runtimes: a change is held, Accept applies it at once, a second Accept on the same card does nothing, a later change is held again.
  • Manually verify Plan mode on Pi refuses a change, and Stop ends a Pi run at once.
  • Manually verify the live words line while Professor Mari writes, and the item names on a batch step row, in a browser. No agent took browser proof of these two.
  • Manually verify one roleplay chat with function calling on an OpenAI-compatible connection: the reply shows no tool-call markup and keeps its prose.
  • Manually verify Pi with the local model and with a subscription connection (textual tool calls). No agent ran these on a real model.
  • 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 on real models.
  • Manually verify a fresh install on Android (Termux): pnpm install must succeed with the pi packages.

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 issue is #7571.

UI evidence (if applicable)

No screenshots are attached. A person should attach the Runtime row, the live words line and a batch step row.

Proof

  • Each slice had an adversarial review before its PR; the findings and fixes are in #7520, #7523, #7533, #7546 and #7567.
  • On this merged state: pnpm check passed (exit 0, includes the build). Regressions passed: professor-mari 18/18, mari/ 32/32, mari- 17/17, provider-stream 1/1, prompt.regression 7/7. pnpm install --frozen-lockfile passed after the merge.
  • Real-model runs during the trial: DeepSeek V4 Pro and other models through an OpenAI-compatible gateway, on a private instance. The trial build ef6bb34a3 ran on that instance.
  • pi-coding-agent 1.2.0 was published on 2026-10-13. The workspace minimumReleaseAge rule (24 hours) blocks a fresh resolution of it until 2026-10-14; installs from the committed lockfile work.

Known limits

  • app_data reads run one after another on Pi.
  • The settings row still carries a fallback note for connections that cannot run Pi. The server no longer reports that state, so the note does not show.

Summary by CodeRabbit

  • New Features

    • Added an experimental Pi runtime option for Professor Mari, with a setting to switch between Pi and Classic. Runtime changes apply to the next run; unsupported connections fall back to Classic with a notice.
    • Professor Mari’s work timeline now shows provisional response text and clearer summaries of batch actions, including item names and counts.
    • Expanded recognition of tool calls across model response formats while preserving surrounding text.
  • Bug Fixes

    • Corrected streamed responses when the final response differs from text shown during generation.
    • Improved runtime-switching feedback when the selected runtime isn’t active.

🔄 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/7570 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `feat/mari-pi-runtime` --- ### 📝 Commits (10+) - [`d29a2df`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d29a2df453f6d5826dd19c26973ead74c14481a2) Move Mari's workspace tool commands into WorkspaceCommands - [`d2817ed`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d2817ed55ed086f4efd53c897be54363ba1e7fcc) Keep executeWorkspaceCommand delegate reachable for scripts - [`466db9a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/466db9a1e2f85f6359329426f0a594a57c97600a) Extract Mari's per-round safety review into workspace-round-review - [`0ff8b5b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0ff8b5b5043c327190af9747b8d6cbb97e7e6203) Extract Mari's message storage into workspace-message-store - [`11f7340`](https://github.com/Pasta-Devs/Marinara-Engine/commit/11f734068fb3f34f5dbac06d88cf50be00c20385) Pin the round-review call sites in the run loop and format touched regressions - [`5985535`](https://github.com/Pasta-Devs/Marinara-Engine/commit/59855358d5e2a4f9ce08e3e36aad047b121f863c) Mark type-only imports in workspace-commands - [`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 ### 📊 Changes **40 files changed** (+5777 additions, -1434 deletions) <details> <summary>View changed files</summary> 📝 `docs/home/professor-mari.md` (+8 -0) 📝 `packages/client/src/components/chat/mari/MariTranscript.tsx` (+1 -0) 📝 `packages/client/src/components/chat/mari/MariWorkTimeline.tsx` (+33 -6) 📝 `packages/client/src/components/chat/mari/use-mari-workspace-run.ts` (+17 -1) 📝 `packages/client/src/components/layout/omnibar/OmnibarSettingsMenu.tsx` (+88 -0) 📝 `packages/client/src/lib/mari-referenced-resources.ts` (+20 -0) 📝 `packages/client/src/lib/settings-registry.ts` (+8 -0) 📝 `packages/client/src/localization/locales/en.json` (+8 -0) 📝 `packages/client/src/stores/chat.store.ts` (+13 -0) 📝 `packages/client/src/styles/mari.css` (+17 -0) 📝 `packages/server/package.json` (+2 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+22 -7) 📝 `packages/server/src/routes/professor-mari-workspace.routes.ts` (+22 -1) 📝 `packages/server/src/services/llm/providers/openai.provider.ts` (+3 -3) 📝 `packages/server/src/services/llm/textual-tool-call-parser.ts` (+250 -23) 📝 `packages/server/src/services/mari-db/mari-db.service.ts` (+10 -0) ➕ `packages/server/src/services/professor-mari/pi-runtime.ts` (+946 -0) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+613 -1337) ➕ `packages/server/src/services/professor-mari/workspace-commands.ts` (+1090 -0) ➕ `packages/server/src/services/professor-mari/workspace-message-store.ts` (+115 -0) _...and 20 more files_ </details> ### 📄 Description ## Linked issue No linked issue. This is planned work: the integration branch for the experimental Pi runtime for Professor Mari. It carries the five reviewed slices #7520, #7523, #7533, #7546 and #7567, plus a merge of current `staging`. ## Why this change - Professor Mari's classic 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 needed native tool calls. Since then the provider layer learned native tool calls, and pi reached 1.x. - This PR 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. ## What changed - **Setting.** Global `mariRuntime`: `classic` (default) or `pi`, with a **Runtime** row below **Permissions mode** in Search and Professor Mari settings. `GET`/`PUT /runtime` sits next to `/permissions-mode` behind the same privileged gate. Professor Mari cannot change the key through raw DB writes. - **Shared command layer (slice 1, #7520).** The command execution, the Permissions Mode floors, the per-round review and the message store moved out of the classic loop so both runtimes use the same code. Classic behaviour and its prompt are unchanged. - **Pi runtime (slice 2, #7523).** pi's agent loop drives the run. Model requests go through Marinara's own provider layer: no pi auth, no pi model registry, no network refresh, nothing read from or written to `~/.pi`. pi's built-in tools are off; the only tools are Marinara's. Session creation fails closed if any active tool is not Marinara's. No extensions, skills, context files or MCP config are loaded. Pi passes the connection's own reasoning settings. There is no 12-round cap (safety cap 400) and pi compacts context inside a long run. - **Accept applies on the server (slice 3, #7533).** In Manual mode, the held calls are stored with the message. **Accept** applies exactly those calls without another model request, once, on both runtimes. Suggestion chips and plans work on Pi. - **Parity (slice 4, #7546).** Pi now runs on every connection. Connections without native tool calls (the local model, `claude_subscription`, `grok_subscription`) use a textual tool-call mode. Pi also got the empty-answer retry, the duplicate-call skip, parallel reads, a summary at the round limit and the cut-off reply guard. - **Polish (slice 5, #7567).** Professor Mari's words show live while she writes. A batch step shows its items on its step row. The shared textual tool-call parser reads DeepSeek (DSML, V3/R1), Kimi K2, GLM, Qwen3-Coder, MiniMax M2 and Mistral markup, in linear time. The OpenAI-compatible provider keeps the prose that a model writes beside a textual tool call; this also affects roleplay chats with function calling. - **Dependency.** `@earendil-works/pi-coding-agent` and `@earendil-works/pi-ai` pinned at exact `1.2.0`. They add 86 packages to the lockfile: MIT (43), Apache-2.0 (35), BSD-3-Clause (3), ISC (3), Unlicense (1), BlueOak-1.0.0 (1). All are permissive and compatible with AGPL-3.0. 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 on this merged state. 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 both runtimes: a change is held, **Accept** applies it at once, a second **Accept** on the same card does nothing, a later change is held again. - Manually verify Plan mode on Pi refuses a change, and Stop ends a Pi run at once. - Manually verify the live words line while Professor Mari writes, and the item names on a batch step row, in a browser. No agent took browser proof of these two. - Manually verify one roleplay chat with function calling on an OpenAI-compatible connection: the reply shows no tool-call markup and keeps its prose. - Manually verify Pi with the local model and with a subscription connection (textual tool calls). No agent ran these on a real model. - 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 on real models. - Manually verify a fresh install on Android (Termux): `pnpm install` must succeed with the pi packages. ## 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 issue is #7571. ## UI evidence (if applicable) No screenshots are attached. A person should attach the Runtime row, the live words line and a batch step row. ## Proof - Each slice had an adversarial review before its PR; the findings and fixes are in #7520, #7523, #7533, #7546 and #7567. - On this merged state: `pnpm check` passed (exit 0, includes the build). Regressions passed: `professor-mari` 18/18, `mari/` 32/32, `mari-` 17/17, `provider-stream` 1/1, `prompt.regression` 7/7. `pnpm install --frozen-lockfile` passed after the merge. - Real-model runs during the trial: DeepSeek V4 Pro and other models through an OpenAI-compatible gateway, on a private instance. The trial build `ef6bb34a3` ran on that instance. - `pi-coding-agent` 1.2.0 was published on 2026-10-13. The workspace `minimumReleaseAge` rule (24 hours) blocks a fresh resolution of it until 2026-10-14; installs from the committed lockfile work. ## Known limits - `app_data` reads run one after another on Pi. - The settings row still carries a fallback note for connections that cannot run Pi. The server no longer reports that state, so the note does not show. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added an experimental Pi runtime option for Professor Mari, with a setting to switch between Pi and Classic. Runtime changes apply to the next run; unsupported connections fall back to Classic with a notice. - Professor Mari’s work timeline now shows provisional response text and clearer summaries of batch actions, including item names and counts. - Expanded recognition of tool calls across model response formats while preserving surrounding text. - **Bug Fixes** - Corrected streamed responses when the final response differs from text shown during generation. - Improved runtime-switching feedback when the selected runtime isn’t active. <!-- 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-24 04:07:40 +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#7806
No description provided.