[PR #8807] [MERGED] Recover when Home Mari prints a lorebook lookup instead of answering #8817

Closed
opened 2026-11-07 17:39:55 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8807
Author: @ylli-selmani
Created: 11/4/2026
Status: ✅ Merged
Merged: 11/4/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/mari-lorebook-retry


📝 Commits (4)

  • ce03730 Retry printed Home Mari lorebook lookups once
  • 550d9f4 Keep Mari's original task and permission checks intact on retry
  • c53971b Recognize printed lookups in the tool names Mari actually receives
  • cfd7f62 Integrate staging's quick replies with printed lookup recovery

📊 Changes

3 files changed (+146 additions, -1 deletions)

View changed files

📝 packages/server/src/services/professor-mari/pi-runtime.ts (+39 -1)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+5 -0)
📝 scripts/regressions/professor-mari/pi-runtime.regression.ts (+102 -0)

📄 Description

Linked issue

Closes #8806

Why this change

Home Mari can finish a turn by showing the tool call she meant to make. The user sees XML, the tool never runs, and resending the request can produce the same reply. One report came from GLM 5.3 on NanoGPT. In the other, the user asked Mari to create a chat and got a printed lorebook search. Running that search would still have missed the request.

What changed

  • Home Pi recognizes two complete, standalone replies seen in the reports: a use_tool block for lorebook entries, and a tool_calls/invoke block for lorebook search. Both blocks can use the registered identifiers (app_data, lorebook.entries, lorebook.search) or the spaced names seen in chat. Mari drops the printed arguments and asks the model to reconsider the original request. The model can answer directly or make a fresh call in the format its connection supports.
  • The repair gets one extra model turn per run. If the model repeats either block, Mari tells the user the lookup did not run. The live draft also withholds the standalone opener so it does not flash before the final answer.
  • Recognition stays inside Home Pi. Quotes, fenced examples, partial blocks, other tools and write actions do not trigger this retry. A response that already contains a native tool call follows the existing dispatch path. Any fresh call on the retry goes through Mari’s usual permission checks.

Validation

Replayed both reports with synthetic buffered JSON and split SSE responses through the OpenAI-compatible provider, Home Pi and saved chat storage. On staging both remained visible as text and produced zero tool calls. The regression covers successful recovery in textual mode, stopping after one retry, negative examples, and a mixed native call. The follow-up also exercises the live draft callback and a Plan-mode write refusal on the repair turn.

Local runs passed: the Professor Mari Pi runtime regression, pnpm regression:prompt, pnpm check, and all seven desktop Chromium smoke tests. The provider responses were fixtures. Live-model reproduction on the reporters’ connections remains unverified.

  • 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

  • Manually verify a Home Mari request on an affected connection. When the model prints either lookup, watch the live draft and the saved reply. Check that Mari returns to the task you actually asked for.
  • Manually verify that a second printed lookup ends with the failure notice and no further retry.

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 follow-up issue opened
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

The provider-to-Mari regression checks emitted draft events and the stored assistant reply. Reporter screenshots remain private.


🔄 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/8807 **Author:** [@ylli-selmani](https://github.com/ylli-selmani) **Created:** 11/4/2026 **Status:** ✅ Merged **Merged:** 11/4/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/mari-lorebook-retry` --- ### 📝 Commits (4) - [`ce03730`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ce03730dfc84392745b5e41322755a180aa91db2) Retry printed Home Mari lorebook lookups once - [`550d9f4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/550d9f4f77abcab2c60bcc717dcbf680b76c09ca) Keep Mari's original task and permission checks intact on retry - [`c53971b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c53971b63bf5188dd23ecbb30fba34da915cfae1) Recognize printed lookups in the tool names Mari actually receives - [`cfd7f62`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cfd7f62b12bac489dec92b2c20878c72a8f970de) Integrate staging's quick replies with printed lookup recovery ### 📊 Changes **3 files changed** (+146 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/professor-mari/pi-runtime.ts` (+39 -1) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+5 -0) 📝 `scripts/regressions/professor-mari/pi-runtime.regression.ts` (+102 -0) </details> ### 📄 Description ## Linked issue Closes #8806 ## Why this change Home Mari can finish a turn by showing the tool call she meant to make. The user sees XML, the tool never runs, and resending the request can produce the same reply. One report came from GLM 5.3 on NanoGPT. In the other, the user asked Mari to create a chat and got a printed lorebook search. Running that search would still have missed the request. ## What changed - Home Pi recognizes two complete, standalone replies seen in the reports: a `use_tool` block for `lorebook entries`, and a `tool_calls/invoke` block for `lorebook search`. Both blocks can use the registered identifiers (`app_data`, `lorebook.entries`, `lorebook.search`) or the spaced names seen in chat. Mari drops the printed arguments and asks the model to reconsider the original request. The model can answer directly or make a fresh call in the format its connection supports. - The repair gets one extra model turn per run. If the model repeats either block, Mari tells the user the lookup did not run. The live draft also withholds the standalone opener so it does not flash before the final answer. - Recognition stays inside Home Pi. Quotes, fenced examples, partial blocks, other tools and write actions do not trigger this retry. A response that already contains a native tool call follows the existing dispatch path. Any fresh call on the retry goes through Mari’s usual permission checks. ## Validation Replayed both reports with synthetic buffered JSON and split SSE responses through the OpenAI-compatible provider, Home Pi and saved chat storage. On staging both remained visible as text and produced zero tool calls. The regression covers successful recovery in textual mode, stopping after one retry, negative examples, and a mixed native call. The follow-up also exercises the live draft callback and a Plan-mode write refusal on the repair turn. Local runs passed: the Professor Mari Pi runtime regression, `pnpm regression:prompt`, `pnpm check`, and all seven desktop Chromium smoke tests. The provider responses were fixtures. Live-model reproduction on the reporters’ connections remains unverified. - [ ] `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 - Manually verify a Home Mari request on an affected connection. When the model prints either lookup, watch the live draft and the saved reply. Check that Mari returns to the task you actually asked for. - Manually verify that a second printed lookup ends with the failure notice and no further retry. ## 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 follow-up issue opened - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) The provider-to-Mari regression checks emitted draft events and the stored assistant reply. Reporter screenshots remain private. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:39:55 +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#8817
No description provided.