[GH-ISSUE #1054] [Feature]: Review custom agent prompt template ordering #516

Closed
opened 2026-10-20 17:29:41 +07:00 by bsakaguchi · 2 comments
Owner

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

What problem does this solve?

Custom agent prompt template instructions currently appear in the middle of the assembled agent prompt, after the generic role/lore sections and before the chat summary. A Discord reporter found this while investigating custom agent failures and expected the agent-specific instructions to appear at the start or end where they are less likely to be diluted by surrounding context.

The reporter observed a custom pacing-suggestion agent sometimes working correctly, but also producing failures such as:

{
  "text": ""
}

They also saw one response where the agent ignored the custom instructions and continued roleplaying in the agent response instead of producing the requested suggestion format.

Proposed solution

Review the custom agent prompt assembly order and adjust it if needed so the prompt template text from the custom agent UI has stronger placement/priority. The likely goal is to keep the agent-specific task and output-format rules near the beginning or end of the assembled prompt, or otherwise protect them from being buried by long summaries.

At minimum, decide whether the current ordering is intentional and safe. If it is safe, document the reasoning. If it is not safe, update the prompt structure for custom agents so template instructions remain authoritative even when lore and chat summary content are large.

Alternatives considered

Leave the current prompt order unchanged if prompt-quality testing shows that template-in-the-middle does not materially hurt agent output.

Another option is to clarify custom agent authoring guidance so users know that long chat summaries may follow their template instructions and should design their templates accordingly. This would not solve the observed empty/roleplay-style failures if ordering is the cause.

Additional context

Source: Discord report from WozzaRole.

Reported current prompt structure from logs:

<role>
You are a specialized agent. Fulfill your task and return the requested output.
</role>
<lore>
<characters>
character text
</characters>
<user_persona>
persona text
</user_persona>
</lore>
<agents>
Fulfill the requested task here and return the output in the format specified:
TEXT FROM THE PROMPT TEMPLATE IN THE AGENT UI IS HERE
</agents>
<chat_summary>
chat summary text
</chat_summary>

Reporter example custom agent prompt template:

Analyze the story's current pacing across the questions below.
Has the scene been static too long (characters talking in circles, no movement)? -> Suggest an interruption, arrival, environmental change, or new stimulus.
Has the player been passive (only reacting, not driving)? -> Suggest a situation that forces a choice, commitment, or action.

Based on the answers to those questions, IF needed, inject a concise suggestion:

OTHERWISE, output exactly:
"[Suggestion: Pacing is good, continue.]"

Output format:
"[Suggestion: <insert suggestion here>]"

Examples:
"[Suggestion: The tavern door should burst open - someone is looking for the player.]"
"[Suggestion: Time for the weather to turn. A storm is rolling in, forcing the player to find shelter.]"
"[Suggestion: Have the character notice something suspicious about the letter - a detail that doesn't add up.]"
"[Suggestion: The player has been passive. Present them with two conflicting requests they must choose between right now.]"

CRITICAL RULES:
Your output is a SUGGESTION to guide the main model, not story prose. Do NOT write dialogue, narration, action descriptions, or anything that reads like a roleplay response.
Do NOT start writing the scene yourself. Only say what SHOULD happen, not how it plays out.
Only produce a suggestion when the story would genuinely benefit. A well-paced slow moment is better than an artificial interruption.

Examples of expected/correct output from the same agent:

[Suggestion: Pacing is good, continue.]
[Suggestion: An unexpected interruption, such as a knock at the door from a faculty member or another student, should break the tension and force a quick conclusion to this negotiation.]

The reporter noted one specific prompt had about 350 words before the custom template and about 1600 words of chat summary after it.

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 @cha1latte on GitHub (May 20, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1054 ## What problem does this solve? Custom agent prompt template instructions currently appear in the middle of the assembled agent prompt, after the generic role/lore sections and before the chat summary. A Discord reporter found this while investigating custom agent failures and expected the agent-specific instructions to appear at the start or end where they are less likely to be diluted by surrounding context. The reporter observed a custom pacing-suggestion agent sometimes working correctly, but also producing failures such as: ```json { "text": "" } ``` They also saw one response where the agent ignored the custom instructions and continued roleplaying in the agent response instead of producing the requested suggestion format. ## Proposed solution Review the custom agent prompt assembly order and adjust it if needed so the prompt template text from the custom agent UI has stronger placement/priority. The likely goal is to keep the agent-specific task and output-format rules near the beginning or end of the assembled prompt, or otherwise protect them from being buried by long summaries. At minimum, decide whether the current ordering is intentional and safe. If it is safe, document the reasoning. If it is not safe, update the prompt structure for custom agents so template instructions remain authoritative even when lore and chat summary content are large. ## Alternatives considered Leave the current prompt order unchanged if prompt-quality testing shows that template-in-the-middle does not materially hurt agent output. Another option is to clarify custom agent authoring guidance so users know that long chat summaries may follow their template instructions and should design their templates accordingly. This would not solve the observed empty/roleplay-style failures if ordering is the cause. ## Additional context Source: Discord report from WozzaRole. Reported current prompt structure from logs: ```text <role> You are a specialized agent. Fulfill your task and return the requested output. </role> <lore> <characters> character text </characters> <user_persona> persona text </user_persona> </lore> <agents> Fulfill the requested task here and return the output in the format specified: TEXT FROM THE PROMPT TEMPLATE IN THE AGENT UI IS HERE </agents> <chat_summary> chat summary text </chat_summary> ``` Reporter example custom agent prompt template: ```text Analyze the story's current pacing across the questions below. Has the scene been static too long (characters talking in circles, no movement)? -> Suggest an interruption, arrival, environmental change, or new stimulus. Has the player been passive (only reacting, not driving)? -> Suggest a situation that forces a choice, commitment, or action. Based on the answers to those questions, IF needed, inject a concise suggestion: OTHERWISE, output exactly: "[Suggestion: Pacing is good, continue.]" Output format: "[Suggestion: <insert suggestion here>]" Examples: "[Suggestion: The tavern door should burst open - someone is looking for the player.]" "[Suggestion: Time for the weather to turn. A storm is rolling in, forcing the player to find shelter.]" "[Suggestion: Have the character notice something suspicious about the letter - a detail that doesn't add up.]" "[Suggestion: The player has been passive. Present them with two conflicting requests they must choose between right now.]" CRITICAL RULES: Your output is a SUGGESTION to guide the main model, not story prose. Do NOT write dialogue, narration, action descriptions, or anything that reads like a roleplay response. Do NOT start writing the scene yourself. Only say what SHOULD happen, not how it plays out. Only produce a suggestion when the story would genuinely benefit. A well-paced slow moment is better than an artificial interruption. ``` Examples of expected/correct output from the same agent: ```text [Suggestion: Pacing is good, continue.] [Suggestion: An unexpected interruption, such as a knock at the door from a faculty member or another student, should break the tension and force a quick conclusion to this negotiation.] ``` The reporter noted one specific prompt had about 350 words before the custom template and about 1600 words of chat summary after it. ## 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.
Author
Owner

@cha1latte commented on GitHub (May 20, 2026):

Triage note: labeling this as scope-risk because it is strongly aligned with custom agent reliability, but it touches agent prompt assembly and needs a prompt-quality decision before changing ordering that may affect built-in and custom agents.

Least risky next step is to reproduce the bad outputs with a captured prompt, then compare the current order against a small reordered prompt assembly before changing the default structure.

<!-- gh-comment-id:4502978928 --> @cha1latte commented on GitHub (May 20, 2026): Triage note: labeling this as `scope-risk` because it is strongly aligned with custom agent reliability, but it touches agent prompt assembly and needs a prompt-quality decision before changing ordering that may affect built-in and custom agents. Least risky next step is to reproduce the bad outputs with a captured prompt, then compare the current order against a small reordered prompt assembly before changing the default structure.
Author
Owner

@SpicyMarinara commented on GitHub (May 23, 2026):

This is the correct placement, we want the instructions at the end of the system prompt, after the context has been gathered.

<!-- gh-comment-id:4524806525 --> @SpicyMarinara commented on GitHub (May 23, 2026): This is the correct placement, we want the instructions at the end of the system prompt, after the context has been gathered.
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#516
No description provided.