[PR #7546] [MERGED] Professor Mari: Pi runtime reaches Classic parity and runs on every connection #7786

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7546
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-4-parity


📝 Commits (4)

  • 9491fca Bring the pi runtime to classic parity: textual tool calls, understood-request record, final summary at the round limit
  • b888ea8 Pi runtime parity, second batch: empty-answer retry, Gemini repair, name scrub, duplicate calls, parallel reads, textual call cleanup
  • 9444f8f Pi runtime review fixes: fence-safe call stripping, cut-off textual replies, text-only limit summary, settle only executed rounds
  • 5ecfe42 Read DeepSeek's DSML call markup as tool calls

📊 Changes

5 files changed (+609 additions, -153 deletions)

View changed files

📝 packages/server/src/services/llm/textual-tool-call-parser.ts (+90 -23)
📝 packages/server/src/services/professor-mari/pi-runtime.ts (+224 -24)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+95 -84)
📝 scripts/regressions/mari-understood-request.regression.ts (+7 -11)
📝 scripts/regressions/professor-mari/pi-runtime.regression.ts (+193 -11)

📄 Description

Linked issue

No linked issue. This is planned work: slice 4 on the integration branch feat/mari-pi-runtime. It is stacked on slice 3 (#7533) and targets that branch, so the diff shows only this slice.

Why this change

  • The Pi runtime is meant to be a full alternative to Classic, but it lacked several Classic behaviors. Users saw this: no retry after an empty answer, internal names such as app_data in her text, no "Acting on" line, a run that stopped after "I will read it now".
  • Pi also refused connections without native tool calls (local model, Claude subscription, Grok subscription) and silently used Classic there.

What changed

  • Text tool calls. On the local model and on providers without native tool calls, Pi lists the tools in the prompt and Professor Mari writes calls as <tool_call>{...}</tool_call>. The existing textual parser reads them; the call text is removed from the visible answer; history is replayed as plain text. Connections with native tool calls never parse text in the Pi adapter. resolveMariRuntime no longer falls back to Classic.
  • Cut-off text replies (finish reason error or an unclosed tag) run no calls, like a length cut.
  • "Acting on" record (#5740) on Pi. Classic and Pi share recordUnderstood/settleUnderstood; Classic behavior unchanged.
  • Round limit: Pi makes one final summary with no tool calls (history flattened to text), audited with auditWorkspaceCompletionClaim.
  • DeepSeek DSML markup. DeepSeek V4 sometimes writes its own call markup (<|DSML|tool_calls>…) as text; the run then ended with that markup as the answer (seen on production with nanogpt/deepseek/deepseek-v4-pro). The shared textual parser now reads it, matches spaced tool names ("app data") to known tools and rejoins a spaced action ("lorebook get entry" → lorebook.getEntry). Both runtimes use the parser through the provider fallback.
  • Classic parity items: empty-answer retry (2, local model 6) and the same note; Gemini MALFORMED_FUNCTION_CALL recovery (shared helper); scrubInternalNames on text, chips and the summary; "say, then do" rule; "Continue the task." chip after a cut-off turn with a change; remaining chip and plan prompt rules; identical calls in one turn run once (shared dedupe); pure read tools run in parallel; raw-response debug log.

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 Pi on the Claude subscription and on the local model: a read, an edit, Manual hold and Accept.
  • Manually verify a code block in an answer stays visible on a subscription connection.
  • Manually verify the "Acting on" line on Pi after an edit.
  • Manually verify a long task (more than 12 steps) on Pi.
  • Manually verify Pi on a native Anthropic and a Gemini connection over several tool rounds.

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 (from slice 2) still says some connections use Classic; to update before the final PR into staging.

UI evidence (if applicable)

No client change.

Proof

Run by agents on commit 9444f8f50:

  • 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 (scripted provider): text calls on a non-native connection (no tools sent, call executes, result replayed as user text, call text removed, Manual hold), a code block kept next to a call, an unclosed tag runs nothing, empty-answer retry, Gemini repair, name scrub, "Continue" chip, duplicate skip, final summary at the limit.

  • Read-only parity audit (Opus) of Classic versus Pi: 9 gaps, all addressed (parallel reads only partly, see limits).

  • Read-only adversarial review (Opus): 5 findings (code fences stripped, cut-off text reply could run part of its calls, Anthropic summary request with tool history and no tools, wrong outcome on an invalid-only round, unscrubbed summary). All fixed. Confirmed: Classic unchanged, all floors apply to text calls, only new model output is parsed, parallel runs cannot bypass a hold, every repair loop is bounded.

  • Local CodeRabbit: 2 findings (abort checks in the final summary, fence stripping). Both fixed.

  • DSML case added to the pi regression (fails without the parser change); roleplay-function-calling and prompt regressions pass.

Known limits:

  • The text tool-call path ran only against the scripted provider, not a real subscription or local model.
  • app_data reads stay sequential on Pi (pi sets parallel per tool, and app_data also writes). No cap of 4 on a parallel read batch.
  • Existing behavior, not changed here: openai.provider.ts (near lines 1911 and 2121) reads <tool_call> tags and JSON fences from text when tools were sent and no native call came back. This affects both runtimes on native OpenAI-compatible connections.
  • In Manual mode Pi holds a silent change behind a card; Classic refuses it. Pi uses the connection's reasoning setting; Classic sends none. Both are intended.

🔄 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/7546 **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-4-parity` --- ### 📝 Commits (4) - [`9491fca`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9491fca1a7dac501c273e6da671c89bd05a8708d) Bring the pi runtime to classic parity: textual tool calls, understood-request record, final summary at the round limit - [`b888ea8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b888ea811b2a725727b1511d809a47ee74095e15) Pi runtime parity, second batch: empty-answer retry, Gemini repair, name scrub, duplicate calls, parallel reads, textual call cleanup - [`9444f8f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9444f8f50036c581225a2480ddf094566ac32b15) Pi runtime review fixes: fence-safe call stripping, cut-off textual replies, text-only limit summary, settle only executed rounds - [`5ecfe42`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5ecfe4203152ec24b7e2c1fbc03708cbefde3561) Read DeepSeek's DSML call markup as tool calls ### 📊 Changes **5 files changed** (+609 additions, -153 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/llm/textual-tool-call-parser.ts` (+90 -23) 📝 `packages/server/src/services/professor-mari/pi-runtime.ts` (+224 -24) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+95 -84) 📝 `scripts/regressions/mari-understood-request.regression.ts` (+7 -11) 📝 `scripts/regressions/professor-mari/pi-runtime.regression.ts` (+193 -11) </details> ### 📄 Description ## Linked issue No linked issue. This is planned work: slice 4 on the integration branch `feat/mari-pi-runtime`. It is stacked on slice 3 (#7533) and targets that branch, so the diff shows only this slice. ## Why this change - The Pi runtime is meant to be a full alternative to Classic, but it lacked several Classic behaviors. Users saw this: no retry after an empty answer, internal names such as `app_data` in her text, no "Acting on" line, a run that stopped after "I will read it now". - Pi also refused connections without native tool calls (local model, Claude subscription, Grok subscription) and silently used Classic there. ## What changed - **Text tool calls.** On the local model and on providers without native tool calls, Pi lists the tools in the prompt and Professor Mari writes calls as `<tool_call>{...}</tool_call>`. The existing textual parser reads them; the call text is removed from the visible answer; history is replayed as plain text. Connections with native tool calls never parse text in the Pi adapter. `resolveMariRuntime` no longer falls back to Classic. - **Cut-off text replies** (finish reason `error` or an unclosed tag) run no calls, like a length cut. - **"Acting on" record (#5740)** on Pi. Classic and Pi share `recordUnderstood`/`settleUnderstood`; Classic behavior unchanged. - **Round limit:** Pi makes one final summary with no tool calls (history flattened to text), audited with `auditWorkspaceCompletionClaim`. - **DeepSeek DSML markup.** DeepSeek V4 sometimes writes its own call markup (`<|DSML|tool_calls>…`) as text; the run then ended with that markup as the answer (seen on production with `nanogpt/deepseek/deepseek-v4-pro`). The shared textual parser now reads it, matches spaced tool names ("app data") to known tools and rejoins a spaced action ("lorebook get entry" → `lorebook.getEntry`). Both runtimes use the parser through the provider fallback. - **Classic parity items:** empty-answer retry (2, local model 6) and the same note; Gemini `MALFORMED_FUNCTION_CALL` recovery (shared helper); `scrubInternalNames` on text, chips and the summary; "say, then do" rule; "Continue the task." chip after a cut-off turn with a change; remaining chip and plan prompt rules; identical calls in one turn run once (shared dedupe); pure read tools run in parallel; raw-response debug log. ## 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 Pi on the Claude subscription and on the local model: a read, an edit, Manual hold and Accept. - Manually verify a code block in an answer stays visible on a subscription connection. - Manually verify the "Acting on" line on Pi after an edit. - Manually verify a long task (more than 12 steps) on Pi. - Manually verify Pi on a native Anthropic and a Gemini connection over several tool rounds. ## 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` (from slice 2) still says some connections use Classic; to update before the final PR into `staging`. ## UI evidence (if applicable) No client change. ## Proof Run by agents on commit `9444f8f50`: - `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` (scripted provider): text calls on a non-native connection (no `tools` sent, call executes, result replayed as user text, call text removed, Manual hold), a code block kept next to a call, an unclosed tag runs nothing, empty-answer retry, Gemini repair, name scrub, "Continue" chip, duplicate skip, final summary at the limit. - Read-only parity audit (Opus) of Classic versus Pi: 9 gaps, all addressed (parallel reads only partly, see limits). - Read-only adversarial review (Opus): 5 findings (code fences stripped, cut-off text reply could run part of its calls, Anthropic summary request with tool history and no tools, wrong outcome on an invalid-only round, unscrubbed summary). All fixed. Confirmed: Classic unchanged, all floors apply to text calls, only new model output is parsed, parallel runs cannot bypass a hold, every repair loop is bounded. - Local CodeRabbit: 2 findings (abort checks in the final summary, fence stripping). Both fixed. - DSML case added to the pi regression (fails without the parser change); `roleplay-function-calling` and `prompt` regressions pass. Known limits: - The text tool-call path ran only against the scripted provider, not a real subscription or local model. - `app_data` reads stay sequential on Pi (pi sets parallel per tool, and `app_data` also writes). No cap of 4 on a parallel read batch. - Existing behavior, not changed here: `openai.provider.ts` (near lines 1911 and 2121) reads `<tool_call>` tags and JSON fences from text when tools were sent and no native call came back. This affects both runtimes on native OpenAI-compatible connections. - In Manual mode Pi holds a silent change behind a card; Classic refuses it. Pi uses the connection's reasoning setting; Classic sends none. Both are intended. --- <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:29 +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#7786
No description provided.