[PR #1740] [MERGED] Fix Mari custom tool_choice compatibility #5252

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1740
Author: @cha1latte
Created: 5/31/2026
Status: ✅ Merged
Merged: 5/31/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/issue-1704-lm-studio-tool-choice


📝 Commits (1)

  • 4495b7d Fix Mari custom tool choice compatibility

📊 Changes

1 file changed (+98 additions, -10 deletions)

View changed files

📝 src-tauri/src/commands/storage/mari.rs (+98 -10)

📄 Description

Linked issue

Closes #1704

Why this change

  • Professor Mari forced a specific function tool with OpenAI object-form tool_choice for all native-tool providers. LM Studio's OpenAI-compatible local server rejects that object form and only accepts string values such as "required", which made Mari fail before the model saw codebase/library requests.

What changed

  • Pass the selected LLM connection into Mari's request-parameter builder.
  • Use tool_choice: "required" for custom connections so LM Studio-compatible endpoints get the broadly accepted string form.
  • Keep exact object-form tool selection for known OpenAI-style providers such as openai.
  • Add Rust regression coverage for custom codebase, custom library, and OpenAI exact-tool behavior.

Refactor impact

Primary owner:

Rust storage / Professor Mari provider bridge.

Impact areas reviewed:

  • src-tauri/src/commands/storage/mari.rs
  • src-tauri/crates/llm/src/lib.rs tool-choice pass-through behavior
  • Professor Mari codebase and library forced-tool paths

Boundary notes:

  • The fix stays in the Rust Professor Mari request-shaping layer. It does not change React UI, engine TypeScript, shared API wrappers, persisted connection schema, or the Rust LLM transport contract.

Pressure points touched:

  • Professor Mari ReAct chat_with_tools request parameters.

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • pnpm check passes locally before PR push/handoff, including the unused-code check
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Browser screenshot/recording evidence added when UI/browser state is the claim
  • Remote runtime smoke checked when relevant

Codex-run verification:

  • node scratch\repro-1704-tool-choice.mjs
    • Before fix: reproduced object-form tool_choice assignments for search_marinara_code and read_marinara_library.
    • After fix: passes, confirming custom Professor Mari requests use string tool_choice: "required".
  • cargo test --manifest-path src-tauri\Cargo.toml professor_mari -- --nocapture passed: 10 passed.
  • cargo check --manifest-path src-tauri\Cargo.toml passed.
  • pnpm check passed after rebasing onto current upstream/refactor.
  • node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed.
  • Bunny pass before opening: focused one-file diff, no blocking findings.

Manual verification notes

  • Not manually tested against a live LM Studio server in this environment. The core request-shape claim is covered by the Rust regression tests and scratch repro.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

No docs or release-note files were changed.

UI evidence

N/A. This is a backend/provider request-shape fix with no visible UI state change.


🔄 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/1740 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/31/2026 **Status:** ✅ Merged **Merged:** 5/31/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1704-lm-studio-tool-choice` --- ### 📝 Commits (1) - [`4495b7d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4495b7d3b2ea2f43b43dfff1654822892e04dd7c) Fix Mari custom tool choice compatibility ### 📊 Changes **1 file changed** (+98 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/mari.rs` (+98 -10) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue Closes #1704 ## Why this change - Professor Mari forced a specific function tool with OpenAI object-form `tool_choice` for all native-tool providers. LM Studio's OpenAI-compatible local server rejects that object form and only accepts string values such as `"required"`, which made Mari fail before the model saw codebase/library requests. ## What changed - Pass the selected LLM connection into Mari's request-parameter builder. - Use `tool_choice: "required"` for `custom` connections so LM Studio-compatible endpoints get the broadly accepted string form. - Keep exact object-form tool selection for known OpenAI-style providers such as `openai`. - Add Rust regression coverage for custom codebase, custom library, and OpenAI exact-tool behavior. ## Refactor impact Primary owner: Rust storage / Professor Mari provider bridge. Impact areas reviewed: - `src-tauri/src/commands/storage/mari.rs` - `src-tauri/crates/llm/src/lib.rs` tool-choice pass-through behavior - Professor Mari codebase and library forced-tool paths Boundary notes: - The fix stays in the Rust Professor Mari request-shaping layer. It does not change React UI, engine TypeScript, shared API wrappers, persisted connection schema, or the Rust LLM transport contract. Pressure points touched: - Professor Mari ReAct `chat_with_tools` request parameters. ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> - [ ] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] `pnpm check` passes locally before PR push/handoff, including the unused-code check - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Browser screenshot/recording evidence added when UI/browser state is the claim - [ ] Remote runtime smoke checked when relevant Codex-run verification: - `node scratch\repro-1704-tool-choice.mjs` - Before fix: reproduced object-form `tool_choice` assignments for `search_marinara_code` and `read_marinara_library`. - After fix: passes, confirming custom Professor Mari requests use string `tool_choice: "required"`. - `cargo test --manifest-path src-tauri\Cargo.toml professor_mari -- --nocapture` passed: 10 passed. - `cargo check --manifest-path src-tauri\Cargo.toml` passed. - `pnpm check` passed after rebasing onto current `upstream/refactor`. - `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed. - Bunny pass before opening: focused one-file diff, no blocking findings. ### Manual verification notes - Not manually tested against a live LM Studio server in this environment. The core request-shape claim is covered by the Rust regression tests and scratch repro. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims No docs or release-note files were changed. ## UI evidence N/A. This is a backend/provider request-shape fix with no visible UI state change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:14:37 +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#5252
No description provided.