[GH-ISSUE #6018] [Bug]: {{model}} macro resolves to an empty string during real generation — prompt assembler never passes the model to the macro context #3332

Closed
opened 2026-10-21 06:02:04 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @oakosb on GitHub (Sep 10, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6018

Originally assigned to: @SpicyMarinara on GitHub.

Summary

The {{model}} macro always resolves to an empty string during real generation, even when a model is selected on the connection. It only resolves in the dry-run/preview path.

Expected behavior

Per docs/prompts/macros.md: {{model}} resolves to "The current model name, when one is selected." With a model selected on the active connection, preset sections containing {{model}} should render that model name in the prompt that is actually sent.

Actual behavior

The model receives literally e.g. Assistant is , a large language model. — the macro slot is empty. Verified by asking the model to quote its own system prompt. The same prompt resolves correctly in the dry-run/preview path, which confirms the selection itself is fine.

Root cause (code analysis on main)

  • BuildPromptMacroContextInput accepts model?: string and buildPromptMacroContext copies it into the macro context (packages/server/src/services/prompt/macro-context.ts, ~line 722: model: input.model).
  • The dry-run route passes it: model: conn.model (packages/server/src/routes/generate/dry-run-route.ts, ~line 882). This is why preview works.
  • The main prompt assembler never passes it (packages/server/src/services/prompt/assembler.ts, ~line 365): its buildPromptMacroContext({ ... }) call omits model, and AssemblerInput has no model field at all, so the generation path cannot supply it.
  • Result: MacroContext.model is undefined at generation time → {{model}} resolves to "".

Steps to reproduce

  1. Configure any connection with a model selected.
  2. Add a prompt preset section containing {{model}} (e.g. Assistant is {{model}}, a large language model.).
  3. Generate a reply in roleplay mode and inspect what was sent (saved request / Peek where available) — the macro renders empty in the real request.

Proposed fix

Add model?: string to AssemblerInput, pass the resolved connection's model from the generate routes, and forward it in the buildPromptMacroContext call in assembler.ts. (Alternatively, resolve the connection model inside the assembler if it already has access to it.)

Why it matters

{{model}} is the only mechanism a preset has to anchor the model's identity ("You are X, a large language model"). This matters especially for distilled/open models that tend to hallucinate a different vendor's identity and system-prompt guidelines; without the slug, the prompt can't contradict that. Currently the macro silently produces broken sentences instead.

Environment

  • Marinara Engine version: 2.4 (behavior verified against main source, commit 1a29936)
  • Install type: source
  • Connection type: OpenAI-compatible (Z.AI / GLM), but the bug is provider-independent (the assembler path never sets the value)

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @oakosb on GitHub (Sep 10, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6018 Originally assigned to: @SpicyMarinara on GitHub. ## Summary The `{{model}}` macro always resolves to an empty string during real generation, even when a model is selected on the connection. It only resolves in the dry-run/preview path. ## Expected behavior Per docs/prompts/macros.md: `{{model}}` resolves to "The current model name, when one is selected." With a model selected on the active connection, preset sections containing `{{model}}` should render that model name in the prompt that is actually sent. ## Actual behavior The model receives literally e.g. `Assistant is , a large language model.` — the macro slot is empty. Verified by asking the model to quote its own system prompt. The same prompt resolves correctly in the dry-run/preview path, which confirms the selection itself is fine. ## Root cause (code analysis on `main`) - `BuildPromptMacroContextInput` accepts `model?: string` and `buildPromptMacroContext` copies it into the macro context (`packages/server/src/services/prompt/macro-context.ts`, ~line 722: `model: input.model`). - The dry-run route passes it: `model: conn.model` (`packages/server/src/routes/generate/dry-run-route.ts`, ~line 882). This is why preview works. - **The main prompt assembler never passes it** (`packages/server/src/services/prompt/assembler.ts`, ~line 365): its `buildPromptMacroContext({ ... })` call omits `model`, and `AssemblerInput` has no `model` field at all, so the generation path cannot supply it. - Result: `MacroContext.model` is `undefined` at generation time → `{{model}}` resolves to `""`. ## Steps to reproduce 1. Configure any connection with a model selected. 2. Add a prompt preset section containing `{{model}}` (e.g. `Assistant is {{model}}, a large language model.`). 3. Generate a reply in roleplay mode and inspect what was sent (saved request / Peek where available) — the macro renders empty in the real request. ## Proposed fix Add `model?: string` to `AssemblerInput`, pass the resolved connection's model from the generate routes, and forward it in the `buildPromptMacroContext` call in `assembler.ts`. (Alternatively, resolve the connection model inside the assembler if it already has access to it.) ## Why it matters `{{model}}` is the only mechanism a preset has to anchor the model's identity ("You are X, a large language model"). This matters especially for distilled/open models that tend to hallucinate a different vendor's identity and system-prompt guidelines; without the slug, the prompt can't contradict that. Currently the macro silently produces broken sentences instead. ## Environment - Marinara Engine version: 2.4 (behavior verified against `main` source, commit 1a29936) - Install type: source - Connection type: OpenAI-compatible (Z.AI / GLM), but the bug is provider-independent (the assembler path never sets the value) ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 06:02:04 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Sep 10, 2026):

Owner: @SpicyMarinara (Codex). This issue is included in draft PR #6026, targeting staging, as part of the requested assigned-issue sweep. Implementation is starting; the draft will carry the regression and browser verification evidence.

<!-- gh-comment-id:5615168803 --> @SpicyMarinara commented on GitHub (Sep 10, 2026): Owner: @SpicyMarinara (Codex). This issue is included in draft PR #6026, targeting staging, as part of the requested assigned-issue sweep. Implementation is starting; the draft will carry the regression and browser verification evidence.
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#3332
No description provided.