[GH-ISSUE #2660] [Issue]: Switching a connection's provider keeps the previous model's max-tokens cap → responses silently truncated #1311

Closed
opened 2026-10-21 05:31:23 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2660

Originally assigned to: @SpicyMarinara on GitHub.

Summary

When a user switches a connection's provider in the editor, the per-model max-tokens override from the previous provider's model is not reset, so it is saved and silently caps the new model's output length.

Expected behavior

Switching providers should reset model-specific state (including localMaxTokensOverride), just as it resets model/baseUrl/apiKey, so the new provider/model isn't constrained by the old model's output cap.

Actual behavior

The provider button handler clears model/baseUrl/apiKey but leaves localMaxTokensOverride (auto-populated from the previous model's maxOutput). On save, the stale override is persisted and the server enforces it as a hard cap (Math.min) on the new model's responses.

How it breaks the pipeline

Code trace (staging @ b826f8f4):

  • Provider switch handler: packages/client/src/components/connections/ConnectionEditor.tsx:876–893 clears model/baseUrl/apiKey but not localMaxTokensOverride (nor localDefaultParameters).
  • localMaxTokensOverride is auto-set from a remote model's maxOutput in selectModel (~:700).
  • On save it is sent in the payload (~:401: maxTokensOverride: localMaxTokensOverride ?? null).
  • The server caps output via applyProviderMaxTokensOverride / capMaxTokens (Math.min), so e.g. a stale 8192 override truncates a new 128k-output model.
  • The only reset runs on the connection-load effect keyed to the conn prop, which does not fire on an in-editor provider switch.

Steps to reproduce

  1. Configure connection A on provider X; fetch models; pick a model whose maxOutput = 8192 (this sets the override to 8192).
  2. Switch the provider to Y; pick a high-output model (e.g. 128k) without touching the max-tokens override field.
  3. Save and generate a long response.
  4. Observe: responses are silently truncated to ~8192 tokens (the stale override) instead of the new model's capability.

Suggested fix

In the provider-switch handler, reset localMaxTokensOverride to null (and consider resetting localDefaultParameters) alongside the existing model/baseUrl/apiKey clearing.

Environment

  • Marinara Engine version: 2.0.0 (staging @ b826f8f4)
  • Install type: source
  • OS + version: All (code-level defect, platform-independent)
  • Browser or app shell: All

Additional context

Identified via systematic source review on staging (refs @ b826f8f4). Symptom is "my replies keep getting cut short after I changed providers." Filed alongside related pipeline issues.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @kolacheee on GitHub (Jun 20, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2660 Originally assigned to: @SpicyMarinara on GitHub. ## Summary When a user switches a connection's provider in the editor, the per-model max-tokens override from the *previous* provider's model is not reset, so it is saved and silently caps the new model's output length. ## Expected behavior Switching providers should reset model-specific state (including `localMaxTokensOverride`), just as it resets model/baseUrl/apiKey, so the new provider/model isn't constrained by the old model's output cap. ## Actual behavior The provider button handler clears model/baseUrl/apiKey but leaves `localMaxTokensOverride` (auto-populated from the previous model's `maxOutput`). On save, the stale override is persisted and the server enforces it as a hard cap (`Math.min`) on the new model's responses. ## How it breaks the pipeline Code trace (staging @ `b826f8f4`): - Provider switch handler: `packages/client/src/components/connections/ConnectionEditor.tsx:876–893` clears `model`/`baseUrl`/`apiKey` but **not** `localMaxTokensOverride` (nor `localDefaultParameters`). - `localMaxTokensOverride` is auto-set from a remote model's `maxOutput` in `selectModel` (~`:700`). - On save it is sent in the payload (~`:401`: `maxTokensOverride: localMaxTokensOverride ?? null`). - The server caps output via `applyProviderMaxTokensOverride` / `capMaxTokens` (`Math.min`), so e.g. a stale `8192` override truncates a new 128k-output model. - The only reset runs on the connection-load effect keyed to the `conn` prop, which does **not** fire on an in-editor provider switch. ## Steps to reproduce 1. Configure connection A on provider X; fetch models; pick a model whose `maxOutput` = 8192 (this sets the override to 8192). 2. Switch the provider to Y; pick a high-output model (e.g. 128k) **without** touching the max-tokens override field. 3. Save and generate a long response. 4. Observe: responses are silently truncated to ~8192 tokens (the stale override) instead of the new model's capability. ## Suggested fix In the provider-switch handler, reset `localMaxTokensOverride` to `null` (and consider resetting `localDefaultParameters`) alongside the existing model/baseUrl/apiKey clearing. ## Environment - Marinara Engine version: 2.0.0 (staging @ `b826f8f4`) - Install type: source - OS + version: All (code-level defect, platform-independent) - Browser or app shell: All ## Additional context Identified via systematic source review on staging (refs @ `b826f8f4`). Symptom is "my replies keep getting cut short after I changed providers." Filed alongside related pipeline issues. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 20, 2026):

Implemented on branch codex/spicymarinara-assigned-issues: switching providers in the connection editor now resets stale model-specific max-token overrides and default parameters. Final validation will run after the full assigned sweep per maintainer request.

<!-- gh-comment-id:4760051981 --> @SpicyMarinara commented on GitHub (Jun 20, 2026): Implemented on branch codex/spicymarinara-assigned-issues: switching providers in the connection editor now resets stale model-specific max-token overrides and default parameters. Final validation will run after the full assigned sweep per maintainer request.
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#1311
No description provided.