[GH-ISSUE #2767] [Issue]: Connection/chat-default sampler params override the active preset's samplers (resolution precedence) #1405

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

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

The preset->ChatOptions resolution layering has several gaps where connection/chat defaults silently win over the user's preset, plus latent overwrite/merge gaps in preset parameter storage. These are the 'works in ST, ignored here' class.

Sub-bug 1: Connection defaultParameters override the preset (new-bug / disputed-intent)

(a) When a chat has a prompt preset AND the connection has opted-in defaultParameters, the code applies preset params first (generate.routes.ts:2072-2088) then applyParameterOverrides(connectionParams) (3501) UNCONDITIONALLY (no if (!presetId) guard), so the connection defaults clobber the preset's temperature/topP/topK/minP/maxTokens/penalties/reasoningEffort. Because the connection editor seeds the FULL field set when the toggle is enabled, ALL preset samplers get clobbered, not just changed ones.
(b) Set a preset temperature 0.7; on the connection enable custom default parameters (leaves temperature 1); generate -> request uses temperature 1.
(c) generate.routes.ts:1969-2094 (preset block), 3460-3502 (unconditional connection override; VERIFIED no presetId guard); same pattern dry-run-route.ts:1217-1239. NOTE: in-product help text ('chats can still override these in Chat Settings') leans toward connection>preset being intended, so the correct precedence is a design decision — but it contradicts the connection-preset-pipeline-priority principle and ST parity. Kind: new-bug (precedence; verify intended layering with maintainer).

Sub-bug 2: chatParameters frozen at creation, stale after connection switch (new-bug)

(a) On chat creation, if the connection has defaultParameters, the server bakes the FULL blob into metadata.chatParameters. Because chat params apply after the preset, this overrides the preset from the start; worse, switching the chat's connection never refreshes chatParameters, so every later generation uses stale sampler params from the ORIGINAL connection (and the live connection defaults are also applied then clobbered by the frozen copy).
(b) Create a chat against connection A (which has defaultParameters); switch the chat to connection B; generate -> uses A's frozen samplers.
(c) chats.routes.ts:442-460 (bake), generate.routes.ts:3501-3502 (connection then chat override), chats.routes.ts:466-483 / chats.storage.ts:315-340 (update never touches metadata). Kind: new-bug.

Sub-bug 3: Partial parameters PATCH / assembler no-default-merge (new-bug, latent)

(a) updatePromptPresetSchema.parameters is generationParametersSchema.partial().optional() and prompts.storage.update overwrites the whole stored blob with no merge; the assembler raw-JSON.parses it with no DEFAULT merge. A partial blob therefore loses unspecified fields, and an empty blob ('{}') leaves temperature/maxTokens undefined (the other fields have ?? default guards at 2074-2086 but 2072-2073 do not). VERIFIED reachable in principle, but no first-party caller currently sends a partial parameters object (PresetEditor round-trips the full object), so this is a latent robustness gap that providers' own ?? 4096/?? 1 re-defaults largely absorb.
(c) prompt.schema.ts:155, prompts.storage.ts:79, assembler.ts:213, generate.routes.ts:2072-2088. Kind: new-bug (latent).

Suggested Fix

  • Decide intended precedence. If preset should own samplers: gate applyParameterOverrides(connectionParams) behind if (!presetId) (keep chat overrides top-priority), in both generate.routes.ts and dry-run-route.ts.
  • Do not bake connection defaults into chatParameters at chat creation (the pipeline already applies live connection defaults); leave chatParameters sparse/user-driven, OR re-derive on connection switch.
  • Merge preset parameters against DEFAULT_GENERATION_PARAMS at the assembler boundary; merge partial PATCHes against the stored blob in prompts.storage.update.

Template

  • Intended preset/connection/chat precedence confirmed with maintainer
  • Preset samplers honored when a preset is active
  • chatParameters not frozen at creation / refreshed on connection switch
  • Partial preset-params PATCH merges instead of wiping
  • pnpm check passes

Affected files

  • packages/server/src/routes/generate.routes.ts
  • packages/server/src/routes/chats.routes.ts
  • packages/server/src/services/prompt/assembler.ts
  • packages/server/src/services/storage/prompts.storage.ts
  • packages/shared/src/schemas/prompt.schema.ts

Audit provenance

Found by a multi-agent re-review of the connection/preset subsystem (editors UI + send-pipeline) against the merged staging tree (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified). The prior #2656-#2668 fixes were re-verified as HELD on their primary paths. Severity: MEDIUM.

AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.

Originally created by @kolacheee on GitHub (Jun 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2767 Originally assigned to: @SpicyMarinara on GitHub. ## Summary The preset->ChatOptions resolution layering has several gaps where connection/chat defaults silently win over the user's preset, plus latent overwrite/merge gaps in preset parameter storage. These are the 'works in ST, ignored here' class. ## Sub-bug 1: Connection defaultParameters override the preset (new-bug / disputed-intent) **(a)** When a chat has a prompt preset AND the connection has opted-in `defaultParameters`, the code applies preset params first (generate.routes.ts:2072-2088) then `applyParameterOverrides(connectionParams)` (3501) UNCONDITIONALLY (no `if (!presetId)` guard), so the connection defaults clobber the preset's temperature/topP/topK/minP/maxTokens/penalties/reasoningEffort. Because the connection editor seeds the FULL field set when the toggle is enabled, ALL preset samplers get clobbered, not just changed ones. **(b)** Set a preset temperature 0.7; on the connection enable custom default parameters (leaves temperature 1); generate -> request uses temperature 1. **(c)** generate.routes.ts:1969-2094 (preset block), 3460-3502 (unconditional connection override; VERIFIED no presetId guard); same pattern dry-run-route.ts:1217-1239. NOTE: in-product help text ('chats can still override these in Chat Settings') leans toward connection>preset being intended, so the correct precedence is a design decision — but it contradicts the connection-preset-pipeline-priority principle and ST parity. Kind: new-bug (precedence; verify intended layering with maintainer). ## Sub-bug 2: chatParameters frozen at creation, stale after connection switch (new-bug) **(a)** On chat creation, if the connection has `defaultParameters`, the server bakes the FULL blob into `metadata.chatParameters`. Because chat params apply after the preset, this overrides the preset from the start; worse, switching the chat's connection never refreshes `chatParameters`, so every later generation uses stale sampler params from the ORIGINAL connection (and the live connection defaults are also applied then clobbered by the frozen copy). **(b)** Create a chat against connection A (which has defaultParameters); switch the chat to connection B; generate -> uses A's frozen samplers. **(c)** chats.routes.ts:442-460 (bake), generate.routes.ts:3501-3502 (connection then chat override), chats.routes.ts:466-483 / chats.storage.ts:315-340 (update never touches metadata). Kind: new-bug. ## Sub-bug 3: Partial parameters PATCH / assembler no-default-merge (new-bug, latent) **(a)** `updatePromptPresetSchema.parameters` is `generationParametersSchema.partial().optional()` and `prompts.storage.update` overwrites the whole stored blob with no merge; the assembler raw-`JSON.parse`s it with no DEFAULT merge. A partial blob therefore loses unspecified fields, and an empty blob ('{}') leaves temperature/maxTokens undefined (the other fields have `?? default` guards at 2074-2086 but 2072-2073 do not). VERIFIED reachable in principle, but no first-party caller currently sends a partial `parameters` object (PresetEditor round-trips the full object), so this is a latent robustness gap that providers' own `?? 4096`/`?? 1` re-defaults largely absorb. **(c)** prompt.schema.ts:155, prompts.storage.ts:79, assembler.ts:213, generate.routes.ts:2072-2088. Kind: new-bug (latent). ## Suggested Fix - Decide intended precedence. If preset should own samplers: gate `applyParameterOverrides(connectionParams)` behind `if (!presetId)` (keep chat overrides top-priority), in both generate.routes.ts and dry-run-route.ts. - Do not bake connection defaults into `chatParameters` at chat creation (the pipeline already applies live connection defaults); leave chatParameters sparse/user-driven, OR re-derive on connection switch. - Merge preset parameters against DEFAULT_GENERATION_PARAMS at the assembler boundary; merge partial PATCHes against the stored blob in `prompts.storage.update`. ## Template - [ ] Intended preset/connection/chat precedence confirmed with maintainer - [ ] Preset samplers honored when a preset is active - [ ] chatParameters not frozen at creation / refreshed on connection switch - [ ] Partial preset-params PATCH merges instead of wiping - [ ] `pnpm check` passes --- ### Affected files - `packages/server/src/routes/generate.routes.ts` - `packages/server/src/routes/chats.routes.ts` - `packages/server/src/services/prompt/assembler.ts` - `packages/server/src/services/storage/prompts.storage.ts` - `packages/shared/src/schemas/prompt.schema.ts` ### Audit provenance Found by a multi-agent re-review of the connection/preset subsystem (editors UI + send-pipeline) against the merged `staging` tree (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified). The prior #2656-#2668 fixes were re-verified as HELD on their primary paths. Severity: **MEDIUM**. > AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.
Author
Owner

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

Fixed in PR #2747.\n\nWhat changed:\n- generation and dry-run only apply connection default parameters when no prompt preset is active, preserving preset sampler intent\n- chat Advanced Parameters still apply after preset/connection defaults, so explicit per-chat overrides remain highest priority\n- new chats no longer bake connection defaults into metadata.chatParameters, avoiding stale sampler blobs after connection switches\n- preset assembly merges partial/legacy parameter blobs over DEFAULT_GENERATION_PARAMS\n- prompt preset parameter PATCHes now merge partial updates over the stored blob plus defaults instead of replacing the whole parameter object\n\nDeferred pnpm/check validation until the end of the issue sweep per maintainer request.

<!-- gh-comment-id:4763389694 --> @SpicyMarinara commented on GitHub (Jun 21, 2026): Fixed in PR #2747.\n\nWhat changed:\n- generation and dry-run only apply connection default parameters when no prompt preset is active, preserving preset sampler intent\n- chat Advanced Parameters still apply after preset/connection defaults, so explicit per-chat overrides remain highest priority\n- new chats no longer bake connection defaults into metadata.chatParameters, avoiding stale sampler blobs after connection switches\n- preset assembly merges partial/legacy parameter blobs over DEFAULT_GENERATION_PARAMS\n- prompt preset parameter PATCHes now merge partial updates over the stored blob plus defaults instead of replacing the whole parameter object\n\nDeferred pnpm/check validation until the end of the issue 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#1405
No description provided.