mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6614] Generation broken near the backend context limit — request may exceed the actual context window #3703
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#3703
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @scavru on GitHub (Sep 24, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6614
Originally assigned to: @SonaGat3 on GitHub.
Description
When a chat approaches the context limit supported by the configured backend/model, generation can suddenly stop working or return an invalid/empty/broken response.
The behavior strongly suggests that Marinara is sometimes sending more context than the backend can actually accept, instead of reliably trimming the assembled prompt before the request is sent.
This is especially noticeable in long Conversation / Roleplay chats with large messages.
Observed behavior
During normal conversation, generation works correctly for a long time.
As the chat approaches the backend's maximum context size:
Generation continues to work normally.
The chat becomes large enough to approach the backend context limit.
At some point generation suddenly breaks.
The failure happens even though the chat itself is still usable and the previous messages are present.
Reducing the amount of history manually (for example with Context Message Limit) can make generation work again.
This makes it appear that the final request may contain the full or oversized assembled history instead of being strictly constrained to the available context budget.
Expected behavior
Before sending a generation request, Marinara should guarantee that the complete assembled request fits within the actual context budget of the selected model/backend.
The context budget should account for all components that can be present in the request, including:
system prompt
character/persona data
chat history
current user message
lorebook/context injections
memory/context recall
agent/tool injections
attachments or other prompt content
reserved output tokens
any provider-specific prompt overhead
Older chat messages should be removed from the beginning of the history until the complete request fits safely within the available context.
The important part is that this should be a hard pre-flight guarantee before the HTTP request is sent, rather than relying only on a message-count limit.
Why the current message limit is insufficient
The existing Limit Context Messages option limits the number of messages, not the number of tokens.
For example:
50 short messages
≈ 2,000–4,000 tokens
can be completely different from:
50 long roleplay messages
≈ 20,000–30,000+ tokens
Therefore the same message limit can either waste most of the available context or exceed the backend context window.
The current documentation confirms that Limit Context Messages sends only the last N messages and is disabled by default. It also states that context fitting may further modify the final request.
Why this appears related to existing issues
Issue #2034 already documents that several generation paths can load the full chat transcript when no contextMessageLimit / historyLimit is provided.
In particular, the issue identifies normal generation, retry, lorebook-keeper and autonomous paths that can perform unbounded history reads.
Issue #289 separately documents the problem with using a fixed message count instead of a token-based context limit.
This report is specifically about the runtime failure that occurs when the final assembled generation request approaches/exceeds the backend context window, and about ensuring that the final outbound request can never exceed that budget.
Reproduction
A simple reproduction can be performed with a backend/model having a known context window, for example:
Backend context: 16,384 tokens
Max output: 4,096 tokens
Create a new Conversation or Roleplay chat.
Use relatively long messages so that the transcript grows quickly.
Leave Limit Context Messages disabled.
Continue generating until the conversation approaches the backend context limit.
Observe generation as the context gets close to the limit.
Compare this with the same conversation after manually reducing the history using Limit Context Messages.
The expected result is that Marinara automatically removes enough old context to keep the request valid.
The observed result is that generation can suddenly fail when the conversation gets close to the backend limit.
Suggested fix
Introduce a final context-budgeting step immediately before the provider request is constructed/sent.
Conceptually:
available_context =
model_context_limit
- reserved_output_tokens
- safety_margin
Then build the prompt from newest history backwards:
system
<= available_context
If adding the next older message would exceed the budget, stop adding older messages.
This should happen regardless of whether Limit Context Messages is enabled.
Limit Context Messages can remain as an optional user-controlled additional restriction, but it should not be the mechanism responsible for preventing context overflow.
Important implementation detail
The context check should be performed against the final assembled prompt, not only the raw chat transcript.
For example, this should not be considered safe:
history_tokens < context_limit
because the final request may additionally contain:
system prompt
The invariant should instead be:
final_prompt_tokens + reserved_output_tokens + safety_margin
<= model_context_limit
Additional regression tests
A useful regression test would create a synthetic large chat and verify that:
A chat larger than the model context can still generate.
The generated request never exceeds the configured context budget.
Older messages are removed first.
The newest user/assistant messages remain intact.
Large character cards/lorebook injections are included in the budget.
Max Output Tokens is reserved before selecting history.
Retry/regeneration uses the same context guard.
The behavior is consistent with and without Limit Context Messages.
A useful diagnostic would also be to expose the final estimated prompt token count in Peek Prompt, for example:
Context:
Model limit: 16384
Prompt tokens: 11842
Output reserved: 4096
Safety margin: 446
Total: 16384
This would make context-related generation failures much easier to diagnose.
Related issues
#2034 — Generation and autonomous checks still load full chat histories
#289 — Add a Token-Based Context Limit alongside the existing Message Limit
The existing issues appear related, but this report focuses specifically on preventing an oversized final generation request from reaching the backend and breaking generation.
@scavru commented on GitHub (Sep 24, 2026):
Additional observation
I was able to reproduce an important part of the behavior consistently.
When the generation starts breaking near the backend's context limit, I can manually delete a number of the oldest messages from the chat.
After enough context is freed:
This strongly suggests that the problem is related to the amount of context being sent to the backend rather than to the model/backend itself.
In other words, the pattern is:
This is particularly noticeable because the recovery happens within the same chat and with the same backend/model configuration.
It would therefore be useful to log the final estimated token count of the actual generation request immediately before it is sent to the provider. This could help confirm whether the request is exceeding the configured context window at the point where generation starts failing.
@SonaGat3 commented on GitHub (Sep 24, 2026):
@scavru Hi! Thanks for the report.
A couple of questions:
Do you have a Max Context Window? (If it's a known model the engine sets it up but if it's not you need to set it -a local model per example-)
What is your language on RP's? (Remember that the tokens 'used' is an estimate and it changes from language to language, it's based on english on the engine)
@scavru commented on GitHub (Sep 24, 2026):
"contextsize": 49152, koboldccp gemma4 31b
@SonaGat3 commented on GitHub (Sep 24, 2026):
Thanks, that helps a lot.
Two things:
[LLM context] Trimmed prompt for from ~52000 to ~46120 tokens (budget ~46120, maxContext=49152)
Could you check whether that line appears when generation breaks, and paste it?
If you want to see the exact prompt that goes out, set LOG_PRESET=prompt-connections in your .env and restart. It shows the same detail as debug without the routine request lines.
If that's the case, the cause is that the token count is an estimate: the Engine counts 4 characters per token, and roleplay prose in markdown (asterisks, quotes, blank lines, invented names) usually tokenizes denser than that. A 10% underestimate at 46k is ~4600 tokens, while the safety margin is only ~984. KoboldCpp doesn't reject an oversized prompt, it drops the oldest part and keeps going, which is exactly the incoherence you're seeing.
A quick test: lower Max Context Window to about 44000 and keep everything else the same. If the problem goes away, it's the estimate, and the real fix is a larger safety margin (or a real tokenizer) rather than message-count limits.
@scavru commented on GitHub (Sep 24, 2026):
There's nothing in the logs. “Processing Prompt [BATCH] (43425 / 43425 tokens)”—I added 6,885 tokens to them, which should have caused an overflow, even though the generation is already broken. In the following generations, “Processing Prompt [BATCH] (42,691 / 42,691 tokens),” so it seems the history is being truncated. The engine shows Context 43.1k / 49.2k tokens. Tomorrow I’ll conduct a more relevant experiment. Otherwise, it seems to me that this might be a memory bug—it’s very similar to a response from message 54, even though I’m on message 121. This happened before bedtime, and the chatbot responds as if it were at that time, with a similar selfie and a similar reply.
@SonaGat3 commented on GitHub (Sep 24, 2026):
Thanks, this is useful. A caveat on the numbers though: what KoboldCpp reports as processed may already be trimmed by KoboldCpp itself, so 43,425 doesn't prove the request fit. And as you point out, 43,425 + 6,885 would be over 49,152.
For tomorrow's test, these are the things that would tell us apart who trimmed what:
Marinara's own console at the moment generation breaks. If the Engine trimmed, there's a warning line:
[LLM context] Trimmed prompt for from ~X to ~Y tokens (budget ~Z, maxContext=49152)
Its presence or absence is the key fact. Default LOG_LEVEL is warn, so it should already be there.
Whether KoboldCpp mentions context shifting / fast forwarding on that same generation.
The token counts from the broken generation itself rather than the ones after it, since those may already reflect the trim.
If you can, LOG_PRESET=prompt-connections in your .env shows the exact prompt that leaves the Engine, which removes the guesswork entirely.
The message 54 observation is noted too — if it turns out to be a separate thing, it may be worth its own issue later, but let's see what the test shows first.
@scavru commented on GitHub (Sep 24, 2026):
normal:
{"level":20,"time":1790281690422,"pid":21152,"hostname":"scav","msg":"[OpenAI chatComplete()] stream=false model=koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M reasoning=high enableThinking=false verbosity=default onToken=false"}
{"level":30,"time":1790281794169,"pid":21152,"hostname":"scav","msg":"[generate] chatId=syzmoRCQjyJa0aP0AqCLK, chatMode=conversation"}
{"level":20,"time":1790281794237,"pid":21152,"hostname":"scav","msg":"[timing] Embedding: 0ms"}
{"level":30,"time":1790281794323,"pid":21152,"hostname":"scav","msg":"[generate] Resolved 0 agents for chat syzmoRCQjyJa0aP0AqCLK (enableAgents=true, perChatList=true, activeIds=[long-term-memory]): "}
{"level":20,"time":1790281794355,"pid":21152,"hostname":"scav","msg":"[memory-recall] Injecting 4/6 recalled memories (~1536/1536 tokens) after trimming"}
{"level":20,"time":1790281794355,"pid":21152,"hostname":"scav","msg":"[timing] Memory recall: 17ms"}
{"level":20,"time":1790281794356,"pid":21152,"hostname":"scav","msg":"[generate/conversation] Injected commands reminder (3571 chars) as last user message"}
{"level":20,"time":1790281794359,"pid":21152,"hostname":"scav","msg":"[timing] Prompt assembly + context: 122ms"}
{"level":20,"time":1790281800276,"pid":21152,"hostname":"scav","msg":"[OpenAI chat()] stream=true model=koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M reasoning=high enableThinking=true verbosity=default max_completion_tokens=n/a max_tokens=1000 temperature=1 top_p=0.98 tools=0"}
{"level":30,"time":1790281866714,"pid":21152,"hostname":"scav","msg":"[generate] Parsed 5 character command(s), 5 enabled: ["schedule_update","selfie","memory","scene","react"]"}
{"level":20,"time":1790281866727,"pid":21152,"hostname":"scav","msg":"[debug/commands/selfie] prompt-builder system:\nYou are an image prompt ."}
{"level":20,"time":1790281866728,"pid":21152,"hostname":"scav","msg":"[debug/commands/selfie] prompt-builder user:."}
{"level":20,"time":1790281866728,"pid":21152,"hostname":"scav","msg":"[OpenAI chatComplete()] stream=false model=koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M reasoning=high enableThinking=false verbosity=default onToken=false"}
{"level":20,"time":1790281889053,"pid":21152,"hostname":"scav","msg":"[commands] Selfie generated for 4chan Doomer Girl"}
{"level":40,"time":1790281889141,"pid":21152,"hostname":"scav","msg":"[commands] Memory target character "Sergey" not found"}
{"level":30,"time":1790281889143,"pid":21152,"hostname":"scav","msg":"[react/conversation] ozY4iy4HyYNd2yse_tpQU reacted with ЁЯШ│ on message 0g-YqkLmrPk8-AsJPStYs"}
{"level":20,"time":1790281889180,"pid":21152,"hostname":"scav","msg":"[memory-recall] Created 1 chunk(s) for chat syzmoRCQjyJa0aP0AqCLK"}
find broken point:
The model used its whole output budget (128 of 128 output tokens) before writing any visible text. Raise Max Tokens or lower Reasoning Effort, then try again.
{"level":20,"time":1790283794330,"pid":21152,"hostname":"scav","msg":"[timing] Embedding: 0ms"}
{"level":20,"time":1790283794451,"pid":21152,"hostname":"scav","msg":"[OpenAI chatComplete()] stream=false model=koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M reasoning=none enableThinking=false verbosity=default onToken=false"}
{"level":20,"time":1790283804137,"pid":21152,"hostname":"scav","msg":"[OpenAI chatComplete()] stream=false model=koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M reasoning=none enableThinking=false verbosity=default onToken=false"}
{"level":20,"time":1790283813422,"pid":21152,"hostname":"scav","msg":"[OpenAI chatComplete()] stream=false model=koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M reasoning=none enableThinking=false verbosity=default onToken=false"}
{"level":20,"time":1790283820779,"pid":21152,"hostname":"scav","msg":"[OpenAI chatComplete()] stream=false model=koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M reasoning=none enableThinking=false verbosity=default onToken=false"}
{"level":30,"time":1790283830908,"pid":21152,"hostname":"scav","msg":"[generate] Resolved 0 agents for chat syzmoRCQjyJa0aP0AqCLK (enableAgents=true, perChatList=true, activeIds=[long-term-memory]): "}
{"level":20,"time":1790283830919,"pid":21152,"hostname":"scav","msg":"[memory-recall] Injecting 4/6 recalled memories (~1536/1536 tokens) after trimming"}
{"level":20,"time":1790283830919,"pid":21152,"hostname":"scav","msg":"[timing] Memory recall: 5ms"}
{"level":20,"time":1790283830919,"pid":21152,"hostname":"scav","msg":"[generate/conversation] Injected commands reminder (3571 chars) as last user message"}
{"level":20,"time":1790283830921,"pid":21152,"hostname":"scav","msg":"[timing] Prompt assembly + context: 36591ms"}
{"level":20,"time":1790283831070,"pid":21152,"hostname":"scav","msg":"[OpenAI chat()] stream=true model=koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M reasoning=high enableThinking=true verbosity=default max_completion_tokens=n/a max_tokens=128 temperature=1 top_p=0.98 tools=0"}
{"level":40,"time":1790283871482,"pid":21152,"hostname":"scav","chatId":"syzmoRCQjyJa0aP0AqCLK","targetCharId":"ozY4iy4HyYNd2yse_tpQU","parsedCommandCount":0,"parsedRawCommandCount":0,"gmVerbCallCount":0,"providerThinkingLength":544,"fullThinkingLength":544,"contentReplaced":false,"chatMode":"conversation","groupChatMode":"individual","finishReason":"length","completionTokens":128,"completionReasoningTokens":null,"maxTokens":128,"msg":"[generate] Empty response after post-processing"}
{"level":40,"time":1790283871482,"pid":21152,"hostname":"scav","msg":"[generate] Empty response from model for chat syzmoRCQjyJa0aP0AqCLK (char: ozY4iy4HyYNd2yse_tpQU): The model used its whole output budget (128 of 128 output tokens) before writing any visible text. Raise Max Tokens or lower Reasoning Effort, then try again."}
{"level":30,"time":1790283878520,"pid":21152,"hostname":"scav","msg":"[generate] chatId=syzmoRCQjyJa0aP0AqCLK, chatMode=conversation"}
{"level":20,"time":1790283878567,"pid":21152,"hostname":"scav","msg":"[timing] Embedding: 0ms"}
{"level":30,"time":1790283878775,"pid":21152,"hostname":"scav","msg":"[generate] Resolved 0 agents for chat syzmoRCQjyJa0aP0AqCLK (enableAgents=true, perChatList=true, activeIds=[long-term-memory]): "}
{"level":20,"time":1790283878786,"pid":21152,"hostname":"scav","msg":"[memory-recall] Injecting 4/6 recalled memories (~1536/1536 tokens) after trimming"}
{"level":20,"time":1790283878786,"pid":21152,"hostname":"scav","msg":"[timing] Memory recall: 6ms"}
{"level":20,"time":1790283878786,"pid":21152,"hostname":"scav","msg":"[generate/conversation] Injected commands reminder (3571 chars) as last user message"}
{"level":20,"time":1790283878789,"pid":21152,"hostname":"scav","msg":"[timing] Prompt assembly + context: 222ms"}
{"level":20,"time":1790283878936,"pid":21152,"hostname":"scav","msg":"[OpenAI chat()] stream=true model=koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M reasoning=high enableThinking=true verbosity=default max_completion_tokens=n/a max_tokens=128 temperature=1 top_p=0.98 tools=0"}
{"level":30,"time":1790283924894,"pid":21152,"hostname":"scav","msg":"[generate] chatId=syzmoRCQjyJa0aP0AqCLK, chatMode=conversation"}
{"level":20,"time":1790283924942,"pid":21152,"hostname":"scav","msg":"[timing] Embedding: 0ms"}
{"level":30,"time":1790283925062,"pid":21152,"hostname":"scav","msg":"[generate] Resolved 0 agents for chat syzmoRCQjyJa0aP0AqCLK (enableAgents=true, perChatList=true, activeIds=[long-term-memory]): "}
{"level":20,"time":1790283925072,"pid":21152,"hostname":"scav","msg":"[memory-recall] Injecting 4/6 recalled memories (~1536/1536 tokens) after trimming"}
{"level":20,"time":1790283925072,"pid":21152,"hostname":"scav","msg":"[timing] Memory recall: 6ms"}
{"level":20,"time":1790283925072,"pid":21152,"hostname":"scav","msg":"[generate/conversation] Injected commands reminder (3571 chars) as last user message"}
{"level":20,"time":1790283925074,"pid":21152,"hostname":"scav","msg":"[timing] Prompt assembly + context: 132ms"}
{"level":20,"time":1790283925186,"pid":21152,"hostname":"scav","msg":"[OpenAI chat()] stream=true model=koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M reasoning=high enableThinking=true verbosity=default max_completion_tokens=n/a max_tokens=128 temperature=1 top_p=0.98 tools=0"}
@SonaGat3 commented on GitHub (Sep 24, 2026):
One thing doesn't add up, so before anything else: did you lower Max Tokens to 128 yourself while looking for the breaking point?
Your earlier log shows max_tokens=1000, and with 128 the chat would never have worked at all, so 128 can't be your normal setting.
It matters because:
If you set it: the empty reply is explained. With reasoning=high and thinking on, the model spent all 128 output tokens reasoning before writing anything — the Engine says exactly that in the same line. The real question then becomes whether it also happens at 1000, and the log lines with finishReason and completionTokens from that attempt would tell us.
If you did not set it: then something lowered your output budget from 1000 to 128 on its own, and that would be the actual bug. The Engine does shrink the output budget when a prompt doesn't fit, but with your numbers (45.6k used, ~47k budget) it shouldn't have, and it would have trimmed messages first and logged it. Neither happened.
@scavru commented on GitHub (Sep 25, 2026):
But as soon as I noticed, the response right around 128 tokens; I have it set to 1,000 for convo:
** (+128,719 chars)**
Processing Prompt [BATCH] (45,453 / 45,453 tokens)
Generating (128 / 128 tokens)
[07:00:15] CtxLimit:45581/49152, Init:0.34s, Processed:45453 in 32.54s (1396.96T/s), Generated:128/128 in 7.08s (18.09T/s), Total:39.96s
{"level":30,"time":1790309047826,"pid":19880,"hostname":"scav","msg":"[generate] chatId=syzmoRCQjyJa0aP0AqCLK, chatMode=conversation"}
{"level":20,"time":1790309047904,"pid":19880,"hostname":"scav","msg":"[timing] Embedding: 0ms"}
{"level":30,"time":1790309048061,"pid":19880,"hostname":"scav","msg":"[generate] Resolved 0 agents for chat syzmoRCQjyJa0aP0AqCLK (enableAgents=true, perChatList=true, activeIds=[long-term-memory]): "}
{"level":30,"time":1790309048220,"pid":19880,"hostname":"scav","msg":"[local-embedder] Loading model Xenova/all-MiniLM-L6-v2..."}
{"level":30,"time":1790309048452,"pid":19880,"hostname":"scav","msg":"[local-embedder] Model loaded in 232ms"}
{"level":20,"time":1790309048472,"pid":19880,"hostname":"scav","msg":"[memory-recall] Injecting 4/6 recalled memories (~1536/1536 tokens) after trimming"}
{"level":20,"time":1790309048472,"pid":19880,"hostname":"scav","msg":"[timing] Memory recall: 394ms"}
{"level":20,"time":1790309048473,"pid":19880,"hostname":"scav","msg":"[generate/conversation] Injected commands reminder (3571 chars) as last user message"}
{"level":20,"time":1790309048479,"pid":19880,"hostname":"scav","msg":"[timing] Prompt assembly + context: 575ms"}
{"level":20,"time":1790309048730,"pid":19880,"hostname":"scav","msg":"\n[debug] Prompt sent to model (92 messages):\n Model: koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M (custom) Temp: 1 MaxTokens: 128 MaxContext: 49152 TopP: 0.98 TopK: 100 EnableThinking: true ShowThoughts: true Effort: high Verbosity: high Stream: true"}
{"level":20,"time":1790309048730,"pid":19880,"hostname":"scav","msg":" [xxxxxxx\n</output_format>"}
{"level":20,"time":1790309048737,"pid":19880,"hostname":"scav","msg":"[OpenAI chat()] stream=true model=koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M reasoning=high enableThinking=true verbosity=default max_completion_tokens=n/a max_tokens=128 temperature=1 top_p=0.98 tools=0"}
All subsequent generations come with {"level":20,"time":1790309385880,"pid":19880,"hostname":"scav","msg":"[OpenAI chat()] stream=true model=koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M reasoning=high enableThinking=true verbosity=default max_completion_tokens=n/a max_tokens=128 temperature=1 top_p=0.98 tools=0"}
after delete messages:
(+124082 chars)
Processing Prompt [BATCH] (44600 / 44600 tokens)
Generating (599 / 1000 tokens)
(EOS token triggered! ID:106)
[07:22:50] CtxLimit:45203/49152, Init:0.27s, Processed:44600 in 34.51s (1292.57T/s), Generated:599/1000 in 42.68s (14.04T/s), Total:77.46s
the writer lease after confirming its same-host PID exited."}
{"level":30,"time":1790310063067,"pid":19212,"hostname":"scav","tables":{"messages":166,"chats":5,"conversation_call_sounds":0,"characters":2484,"character_card_versions":873,"personas":2,"persona_card_versions":4,"character_groups":0,"persona_groups":0,"noodle_accounts":16,"noodle_posts":114,"noodle_account_subscriptions":0,"noodle_post_unlocks":0,"noodle_interactions":90,"noodler_creator_reply_claims":0,"noodler_prepared_posts":0,"noodler_automatic_attempts":0,"noodler_reserve_state":0,"noodler_fan_activity_state":0,"noodle_activity_digests":163,"noodle_refresh_runs":49,"slurp_accounts":1,"slurp_posts":0,"slurp_account_subscriptions":0,"slurp_post_unlocks":0,"slurp_interactions":0,"slurp_creator_reply_claims":0,"slurp_prepared_posts":0,"slurp_automatic_attempts":0,"slurp_reserve_state":1,"slurp_fan_activity_state":8,"slurp_activity_digests":0,"slurp_refresh_runs":0,"lorebooks":881,"lorebook_character_links":378,"lorebook_persona_links":0,"lorebook_folders":0,"lorebook_entries":11448,"prompt_presets":7,"prompt_groups":7,"prompt_sections":77,"choice_blocks":42,"api_connections":4,"assets":0,"agent_configs":18,"custom_tools":0,"capability_documents":2,"game_turn_storyboard_keyframes":0,"game_rulesets":0,"regex_scripts":3,"character_images":1365,"persona_images":85,"gallery_folders":0,"global_images":0,"custom_emojis":0,"custom_stickers":0,"chat_folders":0,"api_connection_folders":0,"custom_themes":0,"app_settings":11,"achievement_unlocks":9,"chat_presets":12,"prompt_overrides":4,"installed_extensions":0,"library_folders":0,"mari_instructions":0},"msg":"[file-storage] Loaded file-native data from O:\Marinara-Engine\packages\server\data\storage"}
{"level":30,"time":1790310063067,"pid":19212,"hostname":"scav","msg":"[file-storage] Using file-native storage at O:\Marinara-Engine\packages\server\data\storage"}
{"level":30,"time":1790310063094,"pid":19212,"hostname":"scav","msg":"[seed] Skipped default connection seed because saved connections already exist"}
{"level":40,"time":1790310063499,"pid":19212,"hostname":"scav","err":{"type":"Error","message":"EEXIST: file already exists, symlink 'O:\Marinara-Engine\packages\server\node_modules' -> 'O:\Marinara-Engine\packages\server\data\capability-packages\node_modules'","stack":"Error: EEXIST: file already exists, symlink 'O:\Marinara-Engine\packages\server\node_modules' -> 'O:\Marinara-Engine\packages\server\data\capability-packages\node_modules'\n at async symlink (node:internal/fs/promises:1009:10)\n at async CapabilityModuleRuntime.ensureModuleResolution (file:///O:/Marinara-Engine/packages/server/dist/services/capability-packages/capability-module-runtime.service.js:118:13)\n at async CapabilityModuleRuntime.start (file:///O:/Marinara-Engine/packages/server/dist/services/capability-packages/capability-module-runtime.service.js:97:9)\n at async buildApp (file:///O:/Marinara-Engine/packages/server/dist/app.js:231:5)\n at async main (file:///O:/Marinara-Engine/packages/server/dist/index.js:54:17)","errno":-4075,"code":"EEXIST","syscall":"symlink","path":"O:\Marinara-Engine\packages\server\node_modules","dest":"O:\Marinara-Engine\packages\server\data\capability-packages\node_modules"},"msg":"Could not link package runtime dependencies"}
{"level":30,"time":1790310063548,"pid":19212,"hostname":"scav","msg":"Activated and verified capability package memory-nag@1.1.2"}
{"level":30,"time":1790310063644,"pid":19212,"hostname":"scav","msg":"Activated and verified capability package hierarchical-maps@1.4.3"}
{"level":30,"time":1790310063783,"pid":19212,"hostname":"scav","msg":"Activated and verified capability package long-term-memory@1.3.18"}
{"level":30,"time":1790310063850,"pid":19212,"hostname":"scav","msg":"[autonomous-scheduler] Server-side autonomous scheduler started"}
{"level":30,"time":1790310063896,"pid":19212,"hostname":"scav","msg":"[env-watcher] Watching O:\Marinara-Engine\.env for changes (changes propagate without restart)"}
{"level":30,"time":1790310063925,"pid":19212,"hostname":"scav","msg":"Server listening at https://127.0.0.1:7777"}
{"level":30,"time":1790310063925,"pid":19212,"hostname":"scav","msg":"Marinara Engine server listening on https://0.0.0.0:7777"}
{"level":40,"time":1790310063927,"pid":19212,"hostname":"scav","msg":"Previous session (pid 16908) ended without shutting down: last alive 2026-09-25T04:20:45.225Z after 1 min, RSS 440.4 MiB. Nothing was logged, so the process was ended from outside - on Android/Termux the usual causes are the phantom process killer or battery management; on desktop, a force-quit or power loss. See Support Diagnostics for the record."}
{"level":30,"time":1790310063928,"pid":19212,"hostname":"scav","msg":"[csrf] Auto-trusted (loopback): http://127.0.0.1:7777, http://localhost:7777"}
{"level":30,"time":1790310063928,"pid":19212,"hostname":"scav","msg":"[csrf] Auto-trusted (pattern): any RFC 1918 / CGNAT (Tailscale) / Docker / link-local IP literal where Origin matches Host"}
{"level":30,"time":1790310063928,"pid":19212,"hostname":"scav","msg":"[csrf] CSRF_TRUSTED_ORIGINS: https://46.30.47.43:7777, https://192.168.31.43:7777"}
{"level":30,"time":1790310063925,"pid":19212,"hostname":"scav","msg":"Server listening at https://192.168.31.43:7777"}
{"level":30,"time":1790310063925,"pid":19212,"hostname":"scav","msg":"Server listening at https://192.168.131.67:7777"}
{"level":30,"time":1790310063925,"pid":19212,"hostname":"scav","msg":"Server listening at https://172.29.208.1:7777"}
{"level":30,"time":1790310063925,"pid":19212,"hostname":"scav","msg":"Server listening at https://172.19.208.1:7777"}
{"level":30,"time":1790310063925,"pid":19212,"hostname":"scav","msg":"Server listening at https://172.27.240.1:7777"}
{"level":30,"time":1790310063925,"pid":19212,"hostname":"scav","msg":"Server listening at https://172.26.32.1:7777"}
{"level":30,"time":1790310063925,"pid":19212,"hostname":"scav","msg":"Server listening at https://172.31.48.1:7777"}
{"level":30,"time":1790310063925,"pid":19212,"hostname":"scav","msg":"Server listening at https://172.29.224.1:7777"}
{"level":20,"time":1790310065764,"pid":19212,"hostname":"scav","msg":"Taskbar migration: C:\Users\scav\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Marinara Engine\Marinara Engine.lnk targets O:\Ma\MarinaraLauncher.exe (not this install), skipping"}
{"level":20,"time":1790310066053,"pid":19212,"hostname":"scav","msg":"Taskbar migration: C:\Users\scav\Desktop\Marinara Engine.lnk targets O:\Ma\MarinaraLauncher.exe (not this install), skipping"}
{"level":30,"time":1790310091906,"pid":19212,"hostname":"scav","msg":"[generate] chatId=syzmoRCQjyJa0aP0AqCLK, chatMode=conversation"}
{"level":20,"time":1790310091986,"pid":19212,"hostname":"scav","msg":"[timing] Embedding: 0ms"}
{"level":30,"time":1790310092211,"pid":19212,"hostname":"scav","msg":"[generate] Resolved 0 agents for chat syzmoRCQjyJa0aP0AqCLK (enableAgents=true, perChatList=true, activeIds=[long-term-memory]): "}
{"level":30,"time":1790310092451,"pid":19212,"hostname":"scav","msg":"[local-embedder] Loading model Xenova/all-MiniLM-L6-v2..."}
{"level":30,"time":1790310092720,"pid":19212,"hostname":"scav","msg":"[local-embedder] Model loaded in 269ms"}
{"level":20,"time":1790310092733,"pid":19212,"hostname":"scav","msg":"[memory-recall] Injecting 4/8 recalled memories (~1536/1536 tokens) after trimming"}
{"level":20,"time":1790310092733,"pid":19212,"hostname":"scav","msg":"[timing] Memory recall: 500ms"}
{"level":20,"time":1790310092733,"pid":19212,"hostname":"scav","msg":"[generate/conversation] Injected commands reminder (3571 chars) as last user message"}
{"level":20,"time":1790310092739,"pid":19212,"hostname":"scav","msg":"[timing] Prompt assembly + context: 753ms"}
{"level":20,"time":1790310092948,"pid":19212,"hostname":"scav","msg":"\n[debug] Prompt sent to model (102 messages):\n Model: koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M (custom) Temp: 1 MaxTokens: 1000 MaxContext: 49152 TopP: 0.98 TopK: 100 EnableThinking: true ShowThoughts: true Effort: high Verbosity: high Stream: true"}
{"level":20,"time":1790310092948,"pid":19212,"hostname":"scav","msg":" [SYSTEM] </output_format>"}
{"level":20,"time":1790310092955,"pid":19212,"hostname":"scav","msg":"[OpenAI chat()] stream=true model=koboldcpp/Gemma-4-Dark-Gemistry-31B.i1-Q4_K_M reasoning=high enableThinking=true verbosity=default max_completion_tokens=n/a max_tokens=1000 temperature=1 top_p=0.98 tools=0"}
@scavru commented on GitHub (Sep 25, 2026):
@scavru commented on GitHub (Sep 25, 2026):
And take a look at the number of characters sent to Kobold. (+124,082 chars) works, but 128k+ doesn't—it's a very suspicious coincidence that it's 128.
@SonaGat3 commented on GitHub (Sep 25, 2026):
Good catch on the 128 — it comes from the Engine, not from your settings.
When the assembled prompt doesn't fit the input budget, the Engine makes room by shrinking the reply instead of sending an oversized request, down to a floor of exactly 128 tokens (MIN_OUTPUT_BUDGET_TOKENS). That's what turned your configured 1000 into the 128 in your log, and with Reasoning Effort at Maximum the model spent all 128 thinking and wrote nothing visible.
It does that silently. The "[LLM context] Trimmed prompt" warning only fires when messages are dropped, so when only the reply budget shrinks there's no trace — which is why your logs looked empty.
What pushes it over is in your own log: the chat indicator says 45.6k, but the server adds ~1536 tokens of recalled memories and a ~3571-char commands reminder on top, landing right at the usable window (49152 minus a 2% margin = 48168). So the request never exceeded your context window; the reply budget collapsed.
To stop it happening:
The Engine's behaviour here is reasonable — shrinking the reply beats sending a request the backend will truncate. What's missing is telling you it happened, in the log and ideally in the UI when your Max Tokens isn't what gets sent.
Still unexplained: your 124,082 vs 128k character threshold. At the Engine's 4-chars-per-token estimate that's ~32k tokens, nowhere near the limit but as always it's an estimate.
@SonaGat3 commented on GitHub (Sep 25, 2026):
I'm closing the issue as completed: now there is a log when it happens. Use the recommended steps that I sent to you to try and stop the issue, you can open an issue again in the future if you feel like it's a genuine error, from my findings it's as intended.