[GH-ISSUE #436] [Issue]: Expression Engine prompt bloat exceeds context window for single-character scenes #189

Closed
opened 2026-10-20 17:26:02 +07:00 by bsakaguchi · 0 comments
Owner

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

Summary

Expression Engine fails in a single-character scene because the agent request grows to thousands of tokens and exceeds the available context window.

Increasing the Expression Engine context cap does not resolve the issue; the request size appears to grow proportionally with the configured cap, suggesting runaway context bloat in the agent prompt construction.

Discord thread

Expected behavior

A single-character scene should not require anywhere near 7,000-10,000+ tokens for expression assignment.

Expression Engine should respect the configured agent context settings and only include the necessary recent chat/context and sprite/expression data needed to choose an expression.

Actual behavior

Expression Engine fails with an OpenAI API context error, even when only one character is active in the scene.

Reported error:

Expression Engine failed: OpenAI API error 400: request (10824 tokens) exceeds the available context size (6144 tokens), try increasing it

Increasing the cap does not fix the problem. Instead, the request grows to match the new cap:

Set to 8000 -> request bloated to ~7300 tokens
Set to 12000 -> request bloated to ~10800 tokens

The user also set agents to read only 5 messages, and then tried 1 message, but the error persisted.

Steps to reproduce

  1. Use Marinara Engine v1.5.8 build 3281d01.
  2. Open a chat with only one character active in the scene.
  3. Enable/use Expression Engine.
  4. Set Expression Engine agent context settings to high values, such as 12000.
  5. Set Runtime Context Window to 12000.
  6. Trigger expression assignment.
  7. Observe that Expression Engine fails with a context-size error.
  8. Lower the agent message-read setting to 5 messages or 1 message.
  9. Observe that the error still persists.

Environment

  • Marinara Engine version: v1.5.8 build 3281d01
  • Install type: Not provided
  • OS + version: Not provided
  • Browser or app shell: Not provided
  • Model/API: gemma 4 e2b

Logs, screenshots, or video

Reported error:

Expression Engine failed: OpenAI API error 400: request (10824 tokens) exceeds the available context size (6144 tokens), try increasing it

Reported behavior when changing the cap:

Set to 8000 -> request bloated to ~7300 tokens
Set to 12000 -> request bloated to ~10800 tokens

Additional context

The issue appears unresolved after increasing context size caps. The user reports that increasing the cap only allows the prompt bloat to grow larger.

This suggests the problem may not be only a hard context ceiling. There may be runaway or repeated context accumulation in the Expression Engine agent prompt pipeline.

The user also noted that the affected chat could not be salvaged even after reimporting JSON while the error was active.

Temporary workaround: the user is using a designated fallback API, which is currently working.

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 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/436 ## Summary Expression Engine fails in a single-character scene because the agent request grows to thousands of tokens and exceeds the available context window. Increasing the Expression Engine context cap does not resolve the issue; the request size appears to grow proportionally with the configured cap, suggesting runaway context bloat in the agent prompt construction. [Discord thread](https://discord.com/channels/1417099416812392641/1501235902670835882) ## Expected behavior A single-character scene should not require anywhere near 7,000-10,000+ tokens for expression assignment. Expression Engine should respect the configured agent context settings and only include the necessary recent chat/context and sprite/expression data needed to choose an expression. ## Actual behavior Expression Engine fails with an OpenAI API context error, even when only one character is active in the scene. Reported error: ```text Expression Engine failed: OpenAI API error 400: request (10824 tokens) exceeds the available context size (6144 tokens), try increasing it ``` Increasing the cap does not fix the problem. Instead, the request grows to match the new cap: ```text Set to 8000 -> request bloated to ~7300 tokens Set to 12000 -> request bloated to ~10800 tokens ``` The user also set agents to read only 5 messages, and then tried 1 message, but the error persisted. ## Steps to reproduce 1. Use Marinara Engine `v1.5.8` build `3281d01`. 2. Open a chat with only one character active in the scene. 3. Enable/use Expression Engine. 4. Set Expression Engine agent context settings to high values, such as `12000`. 5. Set Runtime Context Window to `12000`. 6. Trigger expression assignment. 7. Observe that Expression Engine fails with a context-size error. 8. Lower the agent message-read setting to 5 messages or 1 message. 9. Observe that the error still persists. ## Environment - Marinara Engine version: `v1.5.8` build `3281d01` - Install type: Not provided - OS + version: Not provided - Browser or app shell: Not provided - Model/API: gemma 4 e2b ## Logs, screenshots, or video Reported error: ```text Expression Engine failed: OpenAI API error 400: request (10824 tokens) exceeds the available context size (6144 tokens), try increasing it ``` Reported behavior when changing the cap: ```text Set to 8000 -> request bloated to ~7300 tokens Set to 12000 -> request bloated to ~10800 tokens ``` ## Additional context The issue appears unresolved after increasing context size caps. The user reports that increasing the cap only allows the prompt bloat to grow larger. This suggests the problem may not be only a hard context ceiling. There may be runaway or repeated context accumulation in the Expression Engine agent prompt pipeline. The user also noted that the affected chat could not be salvaged even after reimporting JSON while the error was active. Temporary workaround: the user is using a designated fallback API, which is currently working. ## 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-20 17:26:02 +07:00
  • closed this issue
  • added the
    bug
    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#189
No description provided.