[GH-ISSUE #2288] [Issue]: useMaxContext flag is never honored, so prompt fitting and memory recall always use the manual maxContext instead of the model's real window #1125

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

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

Originally assigned to: @Xelvanis on GitHub.

Summary

When a preset has useMaxContext enabled (it is true in the shipped default preset), the refactor still trims the prompt and sizes memory recall against the raw manual maxContext (default 128000) and never resolves the model's real context window. Main resolves the known model window and folds it into the effective budget.

Expected behavior

With useMaxContext on, the engine should resolve the model's real context window and use it for prompt context fitting and recall budget sizing, matching main.

Actual behavior

fitMessagesToContextWindow reads only parameters.maxContext with no useMaxContext branch, and recall packing reads only the raw connection maxContext. The flag is consumed by no engine code, so a model with a larger window keeps the 128000 value and a model with a smaller real window is over-budgeted, risking provider truncation or 400s. Section trim priority (history dropped first) is otherwise preserved.

Steps to reproduce

  1. Use the default preset (useMaxContext: true) with a model whose real context window differs from 128000.
  2. Build a prompt near the window.
  3. Observe trimming uses 128000, not the model's real window (over- or under-budgeting).

Impact area

  • React-free engine behavior, contracts, agents, or capability ports
  • Runtime systems: generation, world-state, visuals, tracker, or haptics

Regression notes

Worked on main. Main resolves findKnownModel(provider, model)?.context into knownModelContext and folds it into effectiveMaxContext (packages/server/src/routes/generate.routes.ts:2242-2244,2534-2537,3818-3819), which drives fitting (:7169/7441/7589/7643) and recall budget (:5053). The refactor's fitMessagesToContextWindow reads raw parameters.maxContext (src/engine/generation/context-window.ts:64-72) and recall reads raw connection.maxContext (prompt-assembly.ts:2897). Grepping src + src-tauri + crates, useMaxContext exists only as a type/schema/default/passthrough (prompt.ts:188, prompt.schema.ts:53, defaults.ts:29, generate-route-utils.ts:268) with zero reads driving sizing; MODEL_LISTS/KnownModel.context are wired only to the connection editor, never the fitter. The default preset ships useMaxContext:true (src-tauri/resources/default-data/db/default-preset.json:14).

Environment

  • Branch or commit: refactor @ 5ddb9840 (compared against main @ b4ab97f)
  • Run mode: Tauri desktop
  • OS + version: Windows 11
  • Node + pnpm versions: not relevant (static source comparison)
  • Rust version, if relevant: not relevant (static source comparison)
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: see body

Template check

Please uncheck 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 @Romuromylus on GitHub (Jun 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2288 Originally assigned to: @Xelvanis on GitHub. ## Summary When a preset has useMaxContext enabled (it is true in the shipped default preset), the refactor still trims the prompt and sizes memory recall against the raw manual maxContext (default 128000) and never resolves the model's real context window. Main resolves the known model window and folds it into the effective budget. ## Expected behavior With useMaxContext on, the engine should resolve the model's real context window and use it for prompt context fitting and recall budget sizing, matching main. ## Actual behavior `fitMessagesToContextWindow` reads only `parameters.maxContext` with no useMaxContext branch, and recall packing reads only the raw connection maxContext. The flag is consumed by no engine code, so a model with a larger window keeps the 128000 value and a model with a smaller real window is over-budgeted, risking provider truncation or 400s. Section trim priority (history dropped first) is otherwise preserved. ## Steps to reproduce 1. Use the default preset (useMaxContext: true) with a model whose real context window differs from 128000. 2. Build a prompt near the window. 3. Observe trimming uses 128000, not the model's real window (over- or under-budgeting). ## Impact area - [x] React-free engine behavior, contracts, agents, or capability ports - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics ## Regression notes Worked on main. Main resolves `findKnownModel(provider, model)?.context` into `knownModelContext` and folds it into `effectiveMaxContext` (`packages/server/src/routes/generate.routes.ts:2242-2244,2534-2537,3818-3819`), which drives fitting (`:7169/7441/7589/7643`) and recall budget (`:5053`). The refactor's `fitMessagesToContextWindow` reads raw `parameters.maxContext` (`src/engine/generation/context-window.ts:64-72`) and recall reads raw `connection.maxContext` (`prompt-assembly.ts:2897`). Grepping src + src-tauri + crates, useMaxContext exists only as a type/schema/default/passthrough (`prompt.ts:188`, `prompt.schema.ts:53`, `defaults.ts:29`, `generate-route-utils.ts:268`) with zero reads driving sizing; `MODEL_LISTS`/`KnownModel.context` are wired only to the connection editor, never the fitter. The default preset ships `useMaxContext:true` (`src-tauri/resources/default-data/db/default-preset.json:14`). ## Environment - Branch or commit: refactor @ 5ddb9840 (compared against main @ b4ab97f) - Run mode: Tauri desktop - OS + version: Windows 11 - Node + pnpm versions: not relevant (static source comparison) - Rust version, if relevant: not relevant (static source comparison) - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: see body ## Template check Please uncheck 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-21 05:27:26 +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#1125
No description provided.