[GH-ISSUE #5423] [Issue]: Agent prompts leak encoded quotes and raw conditional macro wrappers #3006

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

Originally created by @SpicyMarinara on GitHub (Aug 22, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5423

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Agent calls are receiving HTML-encoded quotes and raw conditional macro directive text in their final prompts. Debug logs show " surviving inside a {{#if ...}} expression instead of resolving to a quote.

For agent calls, the conditional wrapper itself is unnecessary context and wastes tokens. The enclosed authored content must remain, but the {{#if ...}} / {{/if}} control syntax should not be sent to the agent model.

Expected behavior

Given source content such as:

{{#if char == “Powers That Be” || "Maukie"}}***Arc Two***{{/if}}

the agent-bound prompt should contain the useful inner text:

***Arc Two***

It should not contain ", the opening conditional expression, or the closing directive.

Requirements:

  • Decode supported HTML entities used inside macro expressions before agent prompt preprocessing, so " does not survive into debug output or the provider request.
  • For agent calls, flatten conditional macro blocks by removing their directive markup while preserving their enclosed authored content.
  • Handle matching opening and closing directives without damaging surrounding text or nested content.
  • Keep normal/main-generation macro behavior unchanged.
  • Ensure Debug Mode shows the exact final prompt sent to the agent provider.

Actual behavior

The agent debug prompt includes content resembling:

{{#if char == “Powers That Be” || "Maukie"}}***Arc Two***

The encoded quote is not resolved, and the raw conditional expression is sent to the model. This exposes implementation syntax to the agent and consumes tokens without adding useful context.

Steps to reproduce

  1. Add the following text to a prompt field that is included in an agent call:
    {{#if char == “Powers That Be” || "Maukie"}}***Arc Two***{{/if}}
    
  2. Enable Debug Mode.
  3. Trigger an agent call that receives the field.
  4. Inspect the final agent prompt in the debug logs.
  5. Observe that " and the raw {{#if ...}} directive survive in the prompt instead of only the inner text being included.

Environment

  • Marinara Engine version: Staging build; exact version not provided
  • Install type: Not provided
  • OS + version: Not provided
  • Browser or app shell: Not provided
  • Agent/model: Not provided; visible in the server-side agent debug prompt

Logs, screenshots, or video

Observed debug-log fragment:

{{#if char == “Powers That Be” || "Maukie"}}***Arc Two***

Additional context

Related to #5372, which fixed HTML-escaped lorebook tags in agent prompts. That fix covered escaped lorebook body characters such as < and >; this report demonstrates that encoded quotes and conditional macro wrappers still leak through an agent prompt path.

A focused regression should assert both properties together:

  1. the inner text remains in the agent prompt;
  2. neither HTML quote entities nor conditional directive tokens remain.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @SpicyMarinara on GitHub (Aug 22, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5423 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Agent calls are receiving HTML-encoded quotes and raw conditional macro directive text in their final prompts. Debug logs show `"` surviving inside a `{{#if ...}}` expression instead of resolving to a quote. For agent calls, the conditional wrapper itself is unnecessary context and wastes tokens. The enclosed authored content must remain, but the `{{#if ...}}` / `{{/if}}` control syntax should not be sent to the agent model. ## Expected behavior Given source content such as: ```handlebars {{#if char == “Powers That Be” || "Maukie"}}***Arc Two***{{/if}} ``` the agent-bound prompt should contain the useful inner text: ```markdown ***Arc Two*** ``` It should not contain `"`, the opening conditional expression, or the closing directive. Requirements: - Decode supported HTML entities used inside macro expressions before agent prompt preprocessing, so `"` does not survive into debug output or the provider request. - For agent calls, flatten conditional macro blocks by removing their directive markup while preserving their enclosed authored content. - Handle matching opening and closing directives without damaging surrounding text or nested content. - Keep normal/main-generation macro behavior unchanged. - Ensure Debug Mode shows the exact final prompt sent to the agent provider. ## Actual behavior The agent debug prompt includes content resembling: ```handlebars {{#if char == “Powers That Be” || "Maukie"}}***Arc Two*** ``` The encoded quote is not resolved, and the raw conditional expression is sent to the model. This exposes implementation syntax to the agent and consumes tokens without adding useful context. ## Steps to reproduce 1. Add the following text to a prompt field that is included in an agent call: ```handlebars {{#if char == “Powers That Be” || "Maukie"}}***Arc Two***{{/if}} ``` 2. Enable Debug Mode. 3. Trigger an agent call that receives the field. 4. Inspect the final agent prompt in the debug logs. 5. Observe that `"` and the raw `{{#if ...}}` directive survive in the prompt instead of only the inner text being included. ## Environment - Marinara Engine version: Staging build; exact version not provided - Install type: Not provided - OS + version: Not provided - Browser or app shell: Not provided - Agent/model: Not provided; visible in the server-side agent debug prompt ## Logs, screenshots, or video Observed debug-log fragment: ```handlebars {{#if char == “Powers That Be” || "Maukie"}}***Arc Two*** ``` ## Additional context Related to #5372, which fixed HTML-escaped lorebook tags in agent prompts. That fix covered escaped lorebook body characters such as `<` and `>`; this report demonstrates that encoded quotes and conditional macro wrappers still leak through an agent prompt path. A focused regression should assert both properties together: 1. the inner text remains in the agent prompt; 2. neither HTML quote entities nor conditional directive tokens remain. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:58:46 +07:00
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#3006
No description provided.