[GH-ISSUE #3040] [Issue]: Editing the model ID by typing silently wipes the user's Max Output Tokens Override #1608

Closed
opened 2026-10-21 05:40:37 +07:00 by bsakaguchi · 2 comments
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

What's wrong

In the connection editor, every keystroke in any free-text model input resets the separate "Max Output Tokens Override" field to null. A user who deliberately set an output cap (the field's own help text gives the example "DeepSeek caps at 8192") and then edits the model ID by typing — fixing a typo or appending a suffix in the always-visible "Or type model ID directly…" box — silently loses that override. On save the payload sends maxTokensOverride: null, so the per-connection hard cap is gone, and later requests to a provider that enforces a lower limit get an oversized max_tokens and are rejected or truncated. The override field visibly flips to "No override"/0, but a user focused on the model box is unlikely to notice.

How to reproduce (try it yourself)

  1. Open a connection (e.g. provider=custom or a DeepSeek-style OpenAI-compatible endpoint).
  2. Set "Max Output Tokens Override" to 8192; the label shows "8,192 tokens max".
  3. Click into the "Or type model ID directly…" input and type/edit any character of the model name.
  4. Save.

You'll see: the Max Output Tokens Override field instantly resets to 0 / "No override" on the keystroke, and the connection persists maxTokensOverride: null.

Expected: typing in the model box leaves the user-set override untouched.

Where it is

packages/client/src/components/connections/ConnectionEditor.tsx: handleManualModelChange (lines 806-813) unconditionally calls setLocalMaxTokensOverride(null). It is wired to all three free-text model inputs (custom-provider input at 1391, empty-results fallback at 1442, always-visible manual input at 1489-1496). The override field is a separate DraftNumberInput (FieldGroup at 1653-1680). Save sends maxTokensOverride at line 477. Legitimate override seeding lives in selectModel (line 798).

What's happening

handleManualModelChange always nulls localMaxTokensOverride on every model-text change. That reset is appropriate in selectModel (a list/remote pick carries its own maxOutput), but it is incorrectly coupled to manual typing in a field that is independent of the override control, so editing the model string clobbers an unrelated, user-set value.

Suggested fix

Remove the unconditional override reset from handleManualModelChange (lines 806-813):

const handleManualModelChange = useCallback(
  (model: string) => {
    setLocalModel(model);
    markDirty();
  },
  [markDirty],
);

Leave the per-model override seeding where it belongs — in selectModel (line 798), which only sets the override for remote list picks that legitimately carry a maxOutput. No regression: handleManualModelChange is wired only to the three free-text model inputs, none of which is the override control; all other reset paths (init at 282, provider switch at 994, the override field's own onCommit at 1666) are untouched, and the save payload still sends whatever the user/seed set. The only behavior delta is that a remote-model-seeded cap now persists when the user then edits the model string by typing — which is correct, since the override is a visible field. The literal flag-gating alternative (track whether the override was auto-seeded) was rejected as unnecessary state for a rarely-hit edge the visible field already surfaces.


AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.

Originally created by @kolacheee on GitHub (Jun 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3040 Originally assigned to: @SpicyMarinara on GitHub. **What's wrong** In the connection editor, every keystroke in any free-text model input resets the separate "Max Output Tokens Override" field to null. A user who deliberately set an output cap (the field's own help text gives the example "DeepSeek caps at 8192") and then edits the model ID by typing — fixing a typo or appending a suffix in the always-visible "Or type model ID directly…" box — silently loses that override. On save the payload sends `maxTokensOverride: null`, so the per-connection hard cap is gone, and later requests to a provider that enforces a lower limit get an oversized `max_tokens` and are rejected or truncated. The override field visibly flips to "No override"/0, but a user focused on the model box is unlikely to notice. **How to reproduce (try it yourself)** 1. Open a connection (e.g. provider=custom or a DeepSeek-style OpenAI-compatible endpoint). 2. Set "Max Output Tokens Override" to 8192; the label shows "8,192 tokens max". 3. Click into the "Or type model ID directly…" input and type/edit any character of the model name. 4. Save. You'll see: the Max Output Tokens Override field instantly resets to 0 / "No override" on the keystroke, and the connection persists `maxTokensOverride: null`. Expected: typing in the model box leaves the user-set override untouched. **Where it is** `packages/client/src/components/connections/ConnectionEditor.tsx`: `handleManualModelChange` (lines 806-813) unconditionally calls `setLocalMaxTokensOverride(null)`. It is wired to all three free-text model inputs (custom-provider input at 1391, empty-results fallback at 1442, always-visible manual input at 1489-1496). The override field is a separate `DraftNumberInput` (FieldGroup at 1653-1680). Save sends `maxTokensOverride` at line 477. Legitimate override seeding lives in `selectModel` (line 798). **What's happening** `handleManualModelChange` always nulls `localMaxTokensOverride` on every model-text change. That reset is appropriate in `selectModel` (a list/remote pick carries its own `maxOutput`), but it is incorrectly coupled to manual typing in a field that is independent of the override control, so editing the model string clobbers an unrelated, user-set value. **Suggested fix** Remove the unconditional override reset from `handleManualModelChange` (lines 806-813): ```ts const handleManualModelChange = useCallback( (model: string) => { setLocalModel(model); markDirty(); }, [markDirty], ); ``` Leave the per-model override seeding where it belongs — in `selectModel` (line 798), which only sets the override for remote list picks that legitimately carry a `maxOutput`. **No regression:** `handleManualModelChange` is wired only to the three free-text model inputs, none of which is the override control; all other reset paths (init at 282, provider switch at 994, the override field's own onCommit at 1666) are untouched, and the save payload still sends whatever the user/seed set. The only behavior delta is that a remote-model-seeded cap now persists when the user then edits the model string by typing — which is correct, since the override is a visible field. The literal flag-gating alternative (track whether the override was auto-seeded) was rejected as unnecessary state for a rarely-hit edge the visible field already surfaces. --- *AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.*
Author
Owner

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

Claiming this for the current staging sweep in draft PR #3053 (branch codex/issue-sweep-3033-3052).

<!-- gh-comment-id:4834988061 --> @SpicyMarinara commented on GitHub (Jun 29, 2026): Claiming this for the current staging sweep in draft PR #3053 (branch `codex/issue-sweep-3033-3052`).
Author
Owner

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

Fixed in PR #3053 on branch codex/issue-sweep-3033-3052 (commit bfb1bc76). Closing this issue as addressed; the PR remains open for staging review/merge.

<!-- gh-comment-id:4835087916 --> @SpicyMarinara commented on GitHub (Jun 29, 2026): Fixed in PR #3053 on branch `codex/issue-sweep-3033-3052` (commit bfb1bc76). Closing this issue as addressed; the PR remains open for staging review/merge.
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#1608
No description provided.