[GH-ISSUE #7457] [Issue]: Strict Mistral-family chat templates (Rocinante et al.) reject requests with HTTP 400 when any flow sends consecutive same-role messages via custom OpenAI-compatible endpoints #4154

Closed
opened 2026-10-21 06:11:50 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @minouris on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7457

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Any flow that sends two consecutive same-role messages through a custom (OpenAI-compatible) connection to a local model with a strict Mistral-family Jinja template fails with HTTP 400 Unable to generate parser for this template ... conversation roles must alternate user/assistant/user/assistant/.... Only the Anthropic provider merges consecutive roles; the OpenAI-compatible path passes them straight through.

Expected behavior

Requests to strict-template local models should either have consecutive same-role messages merged client-side (as already done for Anthropic), or fail with an actionable Marinara-side message — not a raw llama.cpp parser 400.

Actual behavior

Professor Mari could not answer right now. Custom OpenAI-compatible endpoint error 400: Unable to generate parser for this template. Automatic parser generation failed: ... raise_exception("After the optional system message, con.... Same failure is reachable from normal generation via post-assembly pushes (see below).

Steps to reproduce

  1. Serve a Mistral-template model (e.g. Rocinante-X-12B-v1b, whose card prescribes Mistral v3 Tekken) via llama.cpp with a custom connection in Marinara. Model links: card https://huggingface.co/TheDrummer/Rocinante-X-12B-v1, GGUF https://huggingface.co/TheDrummer/Rocinante-X-12B-v1-GGUF (file served: Rocinante-X-12B-v1b-Q5_K_M.gguf).
  2. Trigger a Professor Mari workspace round that hits protocol/verification repair (invalid command frame), or run normal generation with an assistant prefill where history already ends on assistant (continue/swipe), or impersonate where history ends on user.
  3. The request 400s; llama logs confirm the template's raise_exception during parser generation.

Environment

  • Marinara Engine version: 2.5.0 (docker ghcr.io/pasta-devs/marinara-engine:2.5.0)
  • Install type: docker
  • OS + version: CachyOS Linux, kernel 7.2.9-1-cachyos x86_64
  • Browser or app shell: Chrome (latest)

Logs, screenshots, or video

llama child log (failing request):
got exception: {"error":{"code":400,"message":"Unable to generate parser for this template. Automatic parser generation failed: ... While executing CallExpression at line 18, column 32 ... raise_exception(\"After the optional system message, con... Error: Jinja Exception: After the optional system message, conversation roles must alternate user/assistant/user/assistant/...","type":"invalid_request_error"}}

Marinara log just before: Professor Mari returned an invalid workspace command frame; requesting protocol repair.

Additional context

Confirmed sender-side emitters (v2.5.0 tag):

  • Professor Mari workspace builds messages manually and never calls the prompt assembler (no assembler import in workspace-agent.service.ts), so neither mergeAdjacentMessages nor enforceStrictRoles ever runs there. Verification repair pushes assistant + user(command results) + user(verification) (user,user); round-limit pushes user + user.
  • Normal generation IS assembled with enforceStrictRoles when strictRoleFormatting is true (default preset), but the impersonate user push (generate.routes.ts:6843) and trailing assistant prefill (appendGenerationTailMessages, generate-route-utils.ts:1153) are appended AFTER assembly and bypass it. enforceStrictRoles also skips assistant turns with providerMetadata or differing characterId/audience (assembler.ts:1157-1164), so strict-template 400s stay reachable there.
  • openai.provider.ts:formatMessages does no merging; the only in-code merges are Anthropic-only (anthropic.provider.ts:1121), agent-executor.ts:2930 (appends into trailing user), and the assembler.

Related history (none cover custom endpoints): #2289/#2395 (strict roles for Anthropic/Google), #5915 (post-processing selector request), #2792 (custom-endpoint tool-call compat). Searched Unable to generate parser, conversation roles must alternate, Rocinante, Mistral, jinja, alternation, strict template — no matching open report.

Ruled out: models.ini/llama preset config (router spawns with correct --ctx-size; meta.n_ctx reflects per-slot size), response_format (undefined for custom), and server flags (llama.cpp has no auto-merge flag; builtin mistral-v3-tekken is equally strict — verified against v0.6.0 templates).

Serving preset for the reproducing model (llama.cpp router models.ini; note no chat-template-file line, so the embedded strict Tekken template applies):

; ---- Rocinante (dense, primary narrative model) ----------------------------
; Native 131072 context (config.json: max_position_embeddings = 131072).
; ctx-size 32768 tuned for 16 GB VRAM: ~8.5 GiB Q5_K_M weights + ~2 GiB KV cache
; at Q8_0 quantization leaves ~5.5 GB headroom on 16 GB card.
[Rocinante-X-12B-v1b-Q5_K_M.gguf]
model = /models/Rocinante-X-12B-v1b-Q5_K_M.gguf
n-gpu-layers = -1
parallel = 1
ctx-size = 32768

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 @minouris on GitHub (Oct 12, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7457 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Any flow that sends two consecutive same-role messages through a `custom` (OpenAI-compatible) connection to a local model with a strict Mistral-family Jinja template fails with HTTP 400 `Unable to generate parser for this template ... conversation roles must alternate user/assistant/user/assistant/...`. Only the Anthropic provider merges consecutive roles; the OpenAI-compatible path passes them straight through. ## Expected behavior Requests to strict-template local models should either have consecutive same-role messages merged client-side (as already done for Anthropic), or fail with an actionable Marinara-side message — not a raw llama.cpp parser 400. ## Actual behavior `Professor Mari could not answer right now. Custom OpenAI-compatible endpoint error 400: Unable to generate parser for this template. Automatic parser generation failed: ... raise_exception("After the optional system message, con...`. Same failure is reachable from normal generation via post-assembly pushes (see below). ## Steps to reproduce 1. Serve a Mistral-template model (e.g. Rocinante-X-12B-v1b, whose card prescribes Mistral v3 Tekken) via llama.cpp with a `custom` connection in Marinara. Model links: card https://huggingface.co/TheDrummer/Rocinante-X-12B-v1, GGUF https://huggingface.co/TheDrummer/Rocinante-X-12B-v1-GGUF (file served: `Rocinante-X-12B-v1b-Q5_K_M.gguf`). 2. Trigger a Professor Mari workspace round that hits protocol/verification repair (invalid command frame), **or** run normal generation with an assistant prefill where history already ends on `assistant` (continue/swipe), or impersonate where history ends on `user`. 3. The request 400s; `llama` logs confirm the template's `raise_exception` during parser generation. ## Environment - Marinara Engine version: 2.5.0 (docker `ghcr.io/pasta-devs/marinara-engine:2.5.0`) - Install type: docker - OS + version: CachyOS Linux, kernel 7.2.9-1-cachyos x86_64 - Browser or app shell: Chrome (latest) ## Logs, screenshots, or video llama child log (failing request): `got exception: {"error":{"code":400,"message":"Unable to generate parser for this template. Automatic parser generation failed: ... While executing CallExpression at line 18, column 32 ... raise_exception(\"After the optional system message, con... Error: Jinja Exception: After the optional system message, conversation roles must alternate user/assistant/user/assistant/...","type":"invalid_request_error"}}` Marinara log just before: `Professor Mari returned an invalid workspace command frame; requesting protocol repair`. ## Additional context Confirmed sender-side emitters (v2.5.0 tag): - Professor Mari workspace builds messages manually and never calls the prompt assembler (no assembler import in `workspace-agent.service.ts`), so neither `mergeAdjacentMessages` nor `enforceStrictRoles` ever runs there. Verification repair pushes assistant + user(command results) + user(verification) (`user,user`); round-limit pushes user + user. - Normal generation IS assembled with `enforceStrictRoles` when `strictRoleFormatting` is true (default preset), but the impersonate `user` push (`generate.routes.ts:6843`) and trailing `assistant` prefill (`appendGenerationTailMessages`, `generate-route-utils.ts:1153`) are appended AFTER assembly and bypass it. `enforceStrictRoles` also skips `assistant` turns with `providerMetadata` or differing `characterId`/audience (`assembler.ts:1157-1164`), so strict-template 400s stay reachable there. - `openai.provider.ts:formatMessages` does no merging; the only in-code merges are Anthropic-only (`anthropic.provider.ts:1121`), `agent-executor.ts:2930` (appends into trailing `user`), and the assembler. Related history (none cover custom endpoints): #2289/#2395 (strict roles for Anthropic/Google), #5915 (post-processing selector request), #2792 (custom-endpoint tool-call compat). Searched `Unable to generate parser`, `conversation roles must alternate`, `Rocinante`, `Mistral`, `jinja`, `alternation`, `strict template` — no matching open report. Ruled out: `models.ini`/llama preset config (router spawns with correct `--ctx-size`; `meta.n_ctx` reflects per-slot size), response_format (undefined for `custom`), and server flags (llama.cpp has no auto-merge flag; builtin `mistral-v3-tekken` is equally strict — verified against v0.6.0 templates). Serving preset for the reproducing model (llama.cpp router `models.ini`; note no `chat-template-file` line, so the embedded strict Tekken template applies): ```ini ; ---- Rocinante (dense, primary narrative model) ---------------------------- ; Native 131072 context (config.json: max_position_embeddings = 131072). ; ctx-size 32768 tuned for 16 GB VRAM: ~8.5 GiB Q5_K_M weights + ~2 GiB KV cache ; at Q8_0 quantization leaves ~5.5 GB headroom on 16 GB card. [Rocinante-X-12B-v1b-Q5_K_M.gguf] model = /models/Rocinante-X-12B-v1b-Q5_K_M.gguf n-gpu-layers = -1 parallel = 1 ctx-size = 32768 ``` ## 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 06:11:50 +07:00
  • closed this issue
  • added the
    in-pr
    label
Author
Owner

@SpicyMarinara commented on GitHub (Oct 12, 2026):

Fixed on staging by #7486.

<!-- gh-comment-id:6131787927 --> @SpicyMarinara commented on GitHub (Oct 12, 2026): Fixed on staging by #7486.
Author
Owner

@minouris commented on GitHub (Oct 12, 2026):

Thanks @SpicyMarinara, that's working much better now :)

<!-- gh-comment-id:6134739921 --> @minouris commented on GitHub (Oct 12, 2026): Thanks @SpicyMarinara, that's working much better now :)
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#4154
No description provided.