[PR #5247] [MERGED] fix: stop local models burning their whole budget on discarded thinking #6689

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5247
Author: @kh0p
Created: 8/19/2026
Status: ✅ Merged
Merged: 8/19/2026
Merged by: @SpicyMarinara

Base: staging ← Head: pr/local-endpoint-reasoning


📝 Commits (7)

  • 8e96863 fix(llm): honour explicit reasoning-off on local OpenAI-compatible endpoints
  • 46e7edf fix(agents): disable reasoning for agents that must return JSON
  • 573717f Merge branch 'staging' into pr/local-endpoint-reasoning
  • b9be275 Address reasoning review gaps
  • 29ecae2 Harden local reasoning overrides
  • c35b99f Log final agent provider requests
  • 498198a Merge branch 'staging' into pr/local-endpoint-reasoning

📊 Changes

6 files changed (+342 additions, -7 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/middleware/ip-allowlist.ts (+7 -1)
📝 packages/server/src/services/agents/agent-executor.ts (+60 -2)
📝 packages/server/src/services/llm/providers/openai.provider.ts (+48 -0)
📝 scripts/regressions/agent-runtime.regression.ts (+62 -0)
📝 scripts/regressions/provider-compat.regression.ts (+164 -4)

📄 Description

Linked issue

Closes #5257

Why this change

Locally hosted reasoning models can ignore an explicit Reasoning Effort setting of Off, spend their whole completion budget on thinking that Marinara discards, and leave JSON-returning agents with empty or invalid output. The strict-JSON retry then repeats the same expensive failure.

What changed

  • Send both reasoning_effort: "none" and chat_template_kwargs.enable_thinking: false to local OpenAI-compatible endpoints when reasoning is explicitly disabled, while preserving sibling custom template parameters and keeping the template override away from remote endpoints.
  • Treat loopback, private/link-local IPs, Docker host aliases, Compose service names, and local/internal hostnames as local inference endpoints without coupling provider behavior to the server authentication allowlist.
  • Disable reasoning for JSON-returning agent requests across normal calls, strict-JSON retries, tool loops, final tool responses, and batched execution, unless the connection deliberately disables the reasoning send-switch.
  • Log the final assembled agent request in debug mode for normal, retry, tool-assisted, and batched provider calls.
  • Add focused provider-compatibility and agent-runtime regression coverage, plus an Unreleased changelog entry.

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

Automated proof recorded by the maintainer without marking human verification boxes:

  • pnpm check
  • pnpm --filter @marinara-engine/server exec tsx ../../scripts/regressions/agent-runtime.regression.ts
  • pnpm --filter @marinara-engine/server exec tsx ../../scripts/regressions/provider-compat.regression.ts
  • CodeRabbit CLI review of the final pre-merge diff: zero findings

Manual verification notes

  • The contributor measured the original failure and corrected local-model behavior against llama.cpp/Qwen and a JSON agent running Gemma.
  • Manually verify Connection Settings → Reasoning Effort → Off against a local reasoning model.
  • Manually verify a JSON agent returns parseable content without exhausting its budget or invoking the strict-JSON retry.
  • Manually verify remote custom endpoints retain existing behavior.
  • Maintainer review approved after automated checks and CodeRabbit review.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) 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)

The user-facing fix is documented under CHANGELOG.md → [Unreleased]; no configuration or translated documentation changed.

UI evidence (if applicable)

Not applicable; this is provider and agent-runtime behavior.


🔄 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/5247 **Author:** [@kh0p](https://github.com/kh0p) **Created:** 8/19/2026 **Status:** ✅ Merged **Merged:** 8/19/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `pr/local-endpoint-reasoning` --- ### 📝 Commits (7) - [`8e96863`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8e96863446d01e3b7bc4dcd766bce2b0e02074da) fix(llm): honour explicit reasoning-off on local OpenAI-compatible endpoints - [`46e7edf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/46e7edf47b800079a5ac97088f53aec438c6dddb) fix(agents): disable reasoning for agents that must return JSON - [`573717f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/573717fae5ae7915cca376c00f004c7e748c117b) Merge branch 'staging' into pr/local-endpoint-reasoning - [`b9be275`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b9be275cc3e482660636dac04ee8f83df68c85a7) Address reasoning review gaps - [`29ecae2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/29ecae201e8dc21eb594ea1465b586a82facf48f) Harden local reasoning overrides - [`c35b99f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c35b99f92feac71edd3edd453c111050f3dfebe4) Log final agent provider requests - [`498198a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/498198ae7cb45158bd4832ce967929008d0e110a) Merge branch 'staging' into pr/local-endpoint-reasoning ### 📊 Changes **6 files changed** (+342 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/middleware/ip-allowlist.ts` (+7 -1) 📝 `packages/server/src/services/agents/agent-executor.ts` (+60 -2) 📝 `packages/server/src/services/llm/providers/openai.provider.ts` (+48 -0) 📝 `scripts/regressions/agent-runtime.regression.ts` (+62 -0) 📝 `scripts/regressions/provider-compat.regression.ts` (+164 -4) </details> ### 📄 Description ## Linked issue Closes #5257 ## Why this change Locally hosted reasoning models can ignore an explicit Reasoning Effort setting of Off, spend their whole completion budget on thinking that Marinara discards, and leave JSON-returning agents with empty or invalid output. The strict-JSON retry then repeats the same expensive failure. ## What changed - Send both `reasoning_effort: "none"` and `chat_template_kwargs.enable_thinking: false` to local OpenAI-compatible endpoints when reasoning is explicitly disabled, while preserving sibling custom template parameters and keeping the template override away from remote endpoints. - Treat loopback, private/link-local IPs, Docker host aliases, Compose service names, and local/internal hostnames as local inference endpoints without coupling provider behavior to the server authentication allowlist. - Disable reasoning for JSON-returning agent requests across normal calls, strict-JSON retries, tool loops, final tool responses, and batched execution, unless the connection deliberately disables the reasoning send-switch. - Log the final assembled agent request in debug mode for normal, retry, tool-assisted, and batched provider calls. - Add focused provider-compatibility and agent-runtime regression coverage, plus an Unreleased changelog entry. ## 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` Automated proof recorded by the maintainer without marking human verification boxes: - `pnpm check` - `pnpm --filter @marinara-engine/server exec tsx ../../scripts/regressions/agent-runtime.regression.ts` - `pnpm --filter @marinara-engine/server exec tsx ../../scripts/regressions/provider-compat.regression.ts` - CodeRabbit CLI review of the final pre-merge diff: zero findings ### Manual verification notes - The contributor measured the original failure and corrected local-model behavior against llama.cpp/Qwen and a JSON agent running Gemma. - Manually verify Connection Settings → Reasoning Effort → Off against a local reasoning model. - Manually verify a JSON agent returns parseable content without exhausting its budget or invoking the strict-JSON retry. - Manually verify remote custom endpoints retain existing behavior. - Maintainer review approved after automated checks and CodeRabbit review. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) 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) The user-facing fix is documented under `CHANGELOG.md` → `[Unreleased]`; no configuration or translated documentation changed. ## UI evidence (if applicable) Not applicable; this is provider and agent-runtime behavior. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:12:46 +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#6689
No description provided.