[GH-ISSUE #2658] [Issue]: Preset stop sequences are parsed and saved but never sent to any provider #1310

Closed
opened 2026-10-21 05:31:21 +07:00 by bsakaguchi · 0 comments
Owner

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

Originally assigned to: @kolacheee on GitHub.

Summary

Preset "stop sequences" are parsed and persisted but are never attached to the ChatOptions.stop field that provider adapters read, so they are silently inert on every backend (OpenAI, Anthropic, Google, sidecar). A user's configured stop strings have no effect on generation.

Expected behavior

Stop sequences configured in a preset/connection should be sent to the model so generation halts at those strings (e.g. preventing the model from writing the user's lines or running past a turn boundary).

Actual behavior

Stop sequences are parsed from stored parameters and saved, but the generate route never copies them into the ChatOptions.stop passed to provider.chat()/chatComplete(). As a result:

  • OpenAI has mapping code (body.stop = options.stop) that never receives a populated value (dead in practice).
  • Anthropic and Google never reference options.stop and never set stop_sequences / generationConfig.stopSequences at all.

How it breaks the pipeline

Code trace (staging @ b826f8f4):

  • Stored params parse stopSequences: packages/server/src/routes/generate/generate-route-utils.ts:863–864 → out.stopSequences = source.stopSequences;
  • ChatOptions.stop is the field providers consume (defined in base-provider.ts). A repo-wide search shows no assignment of the parsed stopSequences onto the ChatOptions object built in generate.routes.ts — i.e. options.stop is never populated in the normal generate flow.
  • OpenAI reads it: packages/server/src/services/llm/providers/openai.provider.ts:854 and :1089 → if (this.shouldSendStopSequences(options.model) && options.stop?.length) body.stop = options.stop; — but options.stop is always undefined, so this never fires.
  • Anthropic: anthropic.provider.ts body construction (chat() ~:362–389, chatComplete() ~:238–247) never reads options.stop and never sets stop_sequences.
  • Google: google.provider.ts generationConfig (:383, :542) emits temperature/maxOutputTokens/topP/topK/penalties but never stopSequences.

Net effect: the stop-sequence feature is wired into the UI and storage but disconnected from the request builder for all providers.

Steps to reproduce

  1. In a preset/connection, set a stop sequence (e.g. \nUser: or a character-name delimiter).
  2. Generate a message on any connection (OpenAI, Anthropic, or Google).
  3. Observe: the outbound request body contains no stop / stop_sequences / stopSequences; the model continues past the configured stop string.

Suggested fix

  • Populate ChatOptions.stop from the parsed stopSequences where the ChatOptions object is assembled in generate.routes.ts (this immediately activates the existing OpenAI mapping).
  • Add the provider-specific mapping where missing:
    • Anthropic: if (options.stop?.length) body.stop_sequences = options.stop; in both chat() and chatComplete().
    • Google: if (options.stop?.length) generationConfig.stopSequences = options.stop; in both request builders.
  • Guard with ?.length to preserve valid sequences.

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). This is a uniform missing-wiring gap, not provider-specific — stop sequences are dropped equally for OpenAI, Anthropic, and Google. 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/2658 Originally assigned to: @kolacheee on GitHub. ## Summary Preset "stop sequences" are parsed and persisted but are never attached to the `ChatOptions.stop` field that provider adapters read, so they are silently inert on **every** backend (OpenAI, Anthropic, Google, sidecar). A user's configured stop strings have no effect on generation. ## Expected behavior Stop sequences configured in a preset/connection should be sent to the model so generation halts at those strings (e.g. preventing the model from writing the user's lines or running past a turn boundary). ## Actual behavior Stop sequences are parsed from stored parameters and saved, but the generate route never copies them into the `ChatOptions.stop` passed to `provider.chat()/chatComplete()`. As a result: - OpenAI has mapping code (`body.stop = options.stop`) that never receives a populated value (dead in practice). - Anthropic and Google never reference `options.stop` and never set `stop_sequences` / `generationConfig.stopSequences` at all. ## How it breaks the pipeline Code trace (staging @ `b826f8f4`): - Stored params parse `stopSequences`: `packages/server/src/routes/generate/generate-route-utils.ts:863–864` → `out.stopSequences = source.stopSequences;` - `ChatOptions.stop` is the field providers consume (defined in `base-provider.ts`). A repo-wide search shows **no assignment** of the parsed `stopSequences` onto the `ChatOptions` object built in `generate.routes.ts` — i.e. `options.stop` is never populated in the normal generate flow. - OpenAI reads it: `packages/server/src/services/llm/providers/openai.provider.ts:854` and `:1089` → `if (this.shouldSendStopSequences(options.model) && options.stop?.length) body.stop = options.stop;` — but `options.stop` is always `undefined`, so this never fires. - Anthropic: `anthropic.provider.ts` body construction (`chat()` ~`:362–389`, `chatComplete()` ~`:238–247`) never reads `options.stop` and never sets `stop_sequences`. - Google: `google.provider.ts` `generationConfig` (`:383`, `:542`) emits temperature/maxOutputTokens/topP/topK/penalties but never `stopSequences`. Net effect: the stop-sequence feature is wired into the UI and storage but disconnected from the request builder for all providers. ## Steps to reproduce 1. In a preset/connection, set a stop sequence (e.g. `\nUser:` or a character-name delimiter). 2. Generate a message on any connection (OpenAI, Anthropic, or Google). 3. Observe: the outbound request body contains no `stop` / `stop_sequences` / `stopSequences`; the model continues past the configured stop string. ## Suggested fix - Populate `ChatOptions.stop` from the parsed `stopSequences` where the `ChatOptions` object is assembled in `generate.routes.ts` (this immediately activates the existing OpenAI mapping). - Add the provider-specific mapping where missing: - Anthropic: `if (options.stop?.length) body.stop_sequences = options.stop;` in both `chat()` and `chatComplete()`. - Google: `if (options.stop?.length) generationConfig.stopSequences = options.stop;` in both request builders. - Guard with `?.length` to preserve valid sequences. ## 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`). This is a uniform missing-wiring gap, **not** provider-specific — stop sequences are dropped equally for OpenAI, Anthropic, and Google. 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.
bsakaguchi 2026-10-21 05:31:21 +07:00
  • closed this issue
  • added the
    in-pr
    label
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#1310
No description provided.