[PR #1199] [MERGED] fix(noodle): 1.4.1 — keep the timeline prompt whole on small context windows #1340

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Agents/pull/1199
Author: @SpicyMarinara
Created: 10/2/2026
Status: ✅ Merged
Merged: 10/2/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/noodle-timeline-context


📝 Commits (5)

  • 22f2373 fix(noodle): 1.4.1 — keep the timeline prompt whole on small context windows
  • 1011c1c fix(noodle): size only the primary connection and keep slack for the estimate
  • 1a3478b Merge branch 'staging' into fix/noodle-timeline-context
  • 7db260c Merge remote-tracking branch 'origin/staging' into fix/noodle-timeline-context
  • 7e7f35e fix(noodle): count only a primary length stop as a lowered-budget cut

📊 Changes

15 files changed (+487 additions, -220 deletions)

View changed files

📝 .github/workflows/pull-request-checks.yml (+3 -0)
➕ artifacts/noodle-1.4.1.zip (+0 -0)
📝 catalog/catalog.json (+6 -6)
📝 catalog/notes.json (+6 -0)
📝 catalog/v2/catalog.json (+6 -6)
📝 catalog/v2/notes.json (+6 -0)
📝 catalog/v3/catalog.json (+6 -6)
📝 catalog/v3/notes.json (+6 -0)
📝 packages/noodle/CHANGELOG.md (+4 -0)
📝 packages/noodle/manifest.json (+3 -3)
📝 packages/noodle/server.mjs (+187 -187)
📝 packages/noodle/src/engine/packages/server/src/services/noodle/noodle-post-target.ts (+32 -0)
📝 packages/noodle/src/engine/packages/server/src/services/noodle/noodle-public-generation.service.ts (+101 -11)
📝 scripts/build-feature-packages.mjs (+1 -1)
➕ tests/noodle-timeline-context-budget.regression.ts (+120 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #1201

Refs Pasta-Devs/Marinara-Engine#6973. That report produces exactly this symptom, but it is not yet confirmed to be this bug. The reporter's KoboldCpp runs at 49152 context, where the cut needs a very large prompt; the numbers that would settle it have been requested on the issue.

Why this change

Noodle bundles the vendored sources/engine copy of the context fitter (base-provider.ts, unchanged since 2026-07-14). It predates Engine #4124 (85c139a38). When a prompt with no chat history does not fit beside max_tokens, that fitter deletes the first non-system message. For a timeline refresh that is the entire context body: accounts, handles, character profiles, chats and the timeline. The model gets only the system rules and the JSON template, with the full max_tokens still reserved. It writes a short answer about nobody, and the correction pass is cut the same way. Debug Mode logs the prompt before the cut, so the log still shows the big prompt, which hides the problem.

Since Engine 2.4.6 (#6003 / #6007), the Engine reads the real context size from KoboldCpp, llama.cpp, TabbyAPI and ooba on every page load and stores it as the connection's Max Context. Before that, the column usually held the 128000 default. Timeline refreshes reserve 4096 + 1024 tokens per account for the answer, so on a 16k context with four accounts the body is deleted once the prompt passes about 7.7k estimated tokens, under half the window. The small profile prompt still fits, which is why profiles keep working.

What changed

  • noodle-post-target.ts: noodleTimelineMaxTokensForPrompt() returns the largest max_tokens that fits beside the whole prompt. It uses the bundled fitter's own estimate and margin, and keeps 15% of the prompt estimate back as slack, because the characters / 4 estimate undercounts IDs, timestamps and digits on some tokenizers (Gemma spends a token per digit) and KoboldCpp cuts the start of a prompt that overflows. It returns null when less than 1024 tokens (or a smaller budget saved on the connection) would be left.
  • noodle-public-generation.service.ts: a small NoodleTimelineBudgetProvider facade (same shape as the vendored ConnectionDefaultProvider) wraps the primary connection's provider for the three timeline calls: first try, text-only vision retry and correction. Because only the primary is wrapped, a configured fallback connection still gets the original request and fits it to its own context. Profile generation keeps the unwrapped provider.
    • When too little room is left, the refresh stops before sending, with: "The timeline prompt is too long for this connection's context window. No timeline changes were saved. In Noodle settings, use fewer active accounts or turn off Lorebook context. You can also turn off Allow Noodle references in some chats, or load the model with a larger context size." The wording names controls that every Active Accounts mode shows.
    • If the prompt with images is the part that does not fit, the refresh retries text-only, as it already does when a model rejects images.
    • If an answer under a lowered limit runs out of room and cannot be used, the refresh ends with the same message, instead of a correction pass that has even less room and reports "no timeline activity twice".
    • Debug Mode logs when the answer limit was lowered.
  • New tests/noodle-timeline-context-budget.regression.ts. It runs the vendored fitter from source (the code Noodle bundles), checks that the fitter still deletes the body without the guard, and that the guarded budget keeps every message across 8k–128k contexts, 1, 3 and 6 accounts and prompts up to 200k characters. It also pins the call sites: all three timeline calls use the wrapped provider, and only the primary is wrapped. The required "Catalog validation" CI job now runs it.
  • Noodle 1.4.1 ([highlight] changelog entry), rebuilt server.mjs, manifest, artifacts/noodle-1.4.1.zip, catalog lanes and notes.

The guard sits in package-owned code rather than a package-owned copy of base-provider.ts: sources/engine is frozen by the vendored-Engine baseline, and an override would fork an 800-line file and need a build-script change. A ponytail: comment records the ceiling (the estimate is still characters / 4) and the upgrade path (generate through the Engine's live LLM integration, Capability API 1.31, and count real tokens where the backend can).

Package and security impact

  • Affected package IDs: noodle (1.4.0 → 1.4.1).
  • Engine compatibility impact: none. engine.min 2.4.6, capability API 1.35 and permissions are unchanged.
  • New or changed permissions/entrypoints: none. The executable server payload changed: server.mjs only. client.js is byte-identical to 1.4.0.
  • Restart, storage, update, or uninstall impact: no storage, schema, route or lifecycle change. A normal package update and restart.

Build provenance: rebuilt with MARINARA_ENGINE_ROOT at Engine ead04150a. With that root, an unchanged tree reproduces the published Noodle 1.4.0 byte for byte (zip, server.mjs, client.js, catalogs), so the artifact diff contains only this change. A second rebuild of this branch is byte-identical. Newer Engine staging adds unrelated Engine CSS to client.js (#6941 and the editor-header fix).

Validation

  • node scripts/validate-catalog.mjs passes locally
  • git diff --check passes locally
  • Rebuilt every affected manifest, payload, artifact, and catalog entry
  • Installed or updated the affected package through Marinara Engine
  • Checked supported modes, restart behavior, and uninstall cleanup
  • Read and followed CONTRIBUTING.md

Manual verification notes

Run by the agent:

  • Passed: npm run check, npm run typecheck:packages, node scripts/test-catalog-lanes.mjs, node scripts/tests/ui-translation-retention.regression.mjs, node scripts/validate-package-locales.mjs, node scripts/validate-package-locale-keys.mjs, node scripts/validate-catalog.mjs, node scripts/tests/catalog-generatedat-determinism.regression.mjs, node scripts/tests/catalog-release-notes.regression.mjs, node scripts/tests/vendored-engine.regression.mjs, npm run test:security, node scripts/validate-pr-triage.mjs, git diff --check.
  • The new regression passes, and fails if a timeline call bypasses the wrapper, if the fallback is wrapped too, if the guard stops lowering the budget, or if the slack is removed (all four mutations checked).
  • npm run test:noodle:regressions stops at the first failure: noodle-public-only fails on untouched staging. Run one by one, the same 46 Noodle/NoodleR/Slurp regressions fail on untouched origin/staging and on this branch; every other one passes.
  • End to end on the first commit: a real Engine (ead04150a, isolated data dir) with each artifact installed through installPackageBrowserFixture, a fake KoboldCpp backend recording every request, Max Context set to 16384 by the Engine's own refresh-local-context, and 4 characters with long cards. 1.4.0 sent only the system prompt and JSON format (max_tokens 8192), and so did its correction. 1.4.1 sent all three messages with a lowered max_tokens and created posts. A prompt too big for the window failed with the new message and sent nothing. At 128k the request was unchanged from 1.4.0. The fallback, image, slack and wording problems that run found are what the second commit fixes.
  • Local CodeRabbit (coderabbit review --agent --committed --base staging): 0 findings on the first commit and 0 on the second.

Not run by the agent:

  • An update from 1.4.0 to 1.4.1 through Agents → Download Agents, offline restart and uninstall. This change touches no storage, permissions, entrypoints, routes or startup code.
  • A real KoboldCpp or llama.cpp with Gemma 4. The fake backend answers instantly, so how a real model uses a lowered limit is unverified.
  • A real-Engine run of the second commit's new paths: the fallback wrapper, the text-only retry when the images are what does not fit, the stop after an answer runs out of room, and the 15% slack. The first commit's end-to-end run covered the core fix; the second commit is covered by the regression, its four mutation checks, review and CodeRabbit only.
  • The "Noodle package browser" CI job fails on pre-existing vendored-Engine drift before its e2e step, as on #1188, so it provides no automated browser proof here.

Still to verify by hand:

  • Update Noodle to 1.4.1 through Agents → Download Agents on an Engine staging checkout, restart, and confirm the timeline loads.
  • On a local KoboldCpp or llama.cpp connection with a 16k context and 4 or more active accounts, refresh the timeline. The backend should receive the full prompt (check its prompt token count) with a smaller max_tokens, and posts should appear.
  • With a prompt larger than the context (many accounts, chats with Allow Noodle references, Lorebook context on), confirm the refresh stops at once with the new message and nothing is sent to the backend.
  • With a fallback connection for main that has a larger context, and a prompt too big for the primary, confirm the fallback takes the refresh with the full prompt.
  • On a cloud connection with a large context, confirm refreshes behave as before.

Documentation impact

  • No documentation changes needed
  • Updated this README catalog and package guidance
  • Updated linked Marinara Engine documentation

No README or Engine documentation change is made here: the 1.4.1 release notes describe the change, and no existing statement in the README or the Engine docs becomes wrong. Pre-existing Engine docs gap for a follow-up: docs/noodle/settings.md says All invited has no cap and never names Accounts per refresh.

Summary by CodeRabbit

  • Bug Fixes
    • Timeline refreshes now preserve the full prompt when it exceeds a local model’s context budget by reducing the space reserved for the answer. If too little answer space remains, refresh stops and explains what to reduce.
    • When image-based timeline generation cannot proceed because the prompt is too long or the model rejects image input, Noodle can retry using text-only content.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Agents/pull/1199 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/2/2026 **Status:** ✅ Merged **Merged:** 10/2/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/noodle-timeline-context` --- ### 📝 Commits (5) - [`22f2373`](https://github.com/Pasta-Devs/Marinara-Agents/commit/22f23731ef99188b113b2cded0ced225b4ee9404) fix(noodle): 1.4.1 — keep the timeline prompt whole on small context windows - [`1011c1c`](https://github.com/Pasta-Devs/Marinara-Agents/commit/1011c1c591eec842ca1948c8d30feb614ebd34ac) fix(noodle): size only the primary connection and keep slack for the estimate - [`1a3478b`](https://github.com/Pasta-Devs/Marinara-Agents/commit/1a3478b76112bbe1d97ab8e5229f342394dc0405) Merge branch 'staging' into fix/noodle-timeline-context - [`7db260c`](https://github.com/Pasta-Devs/Marinara-Agents/commit/7db260c9ffd22ec1a43048ea5cac374a64c204f0) Merge remote-tracking branch 'origin/staging' into fix/noodle-timeline-context - [`7e7f35e`](https://github.com/Pasta-Devs/Marinara-Agents/commit/7e7f35e00068b2aa8cac90f0a4f8529c3c040a98) fix(noodle): count only a primary length stop as a lowered-budget cut ### 📊 Changes **15 files changed** (+487 additions, -220 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/pull-request-checks.yml` (+3 -0) ➕ `artifacts/noodle-1.4.1.zip` (+0 -0) 📝 `catalog/catalog.json` (+6 -6) 📝 `catalog/notes.json` (+6 -0) 📝 `catalog/v2/catalog.json` (+6 -6) 📝 `catalog/v2/notes.json` (+6 -0) 📝 `catalog/v3/catalog.json` (+6 -6) 📝 `catalog/v3/notes.json` (+6 -0) 📝 `packages/noodle/CHANGELOG.md` (+4 -0) 📝 `packages/noodle/manifest.json` (+3 -3) 📝 `packages/noodle/server.mjs` (+187 -187) 📝 `packages/noodle/src/engine/packages/server/src/services/noodle/noodle-post-target.ts` (+32 -0) 📝 `packages/noodle/src/engine/packages/server/src/services/noodle/noodle-public-generation.service.ts` (+101 -11) 📝 `scripts/build-feature-packages.mjs` (+1 -1) ➕ `tests/noodle-timeline-context-budget.regression.ts` (+120 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #1201 Refs Pasta-Devs/Marinara-Engine#6973. That report produces exactly this symptom, but it is not yet confirmed to be this bug. The reporter's KoboldCpp runs at 49152 context, where the cut needs a very large prompt; the numbers that would settle it have been requested on the issue. ## Why this change Noodle bundles the vendored `sources/engine` copy of the context fitter (`base-provider.ts`, unchanged since 2026-07-14). It predates Engine #4124 (85c139a38). When a prompt with no chat history does not fit beside `max_tokens`, that fitter deletes the first non-system message. For a timeline refresh that is the entire context body: accounts, handles, character profiles, chats and the timeline. The model gets only the system rules and the JSON template, with the full `max_tokens` still reserved. It writes a short answer about nobody, and the correction pass is cut the same way. Debug Mode logs the prompt before the cut, so the log still shows the big prompt, which hides the problem. Since Engine 2.4.6 (#6003 / #6007), the Engine reads the real context size from KoboldCpp, llama.cpp, TabbyAPI and ooba on every page load and stores it as the connection's Max Context. Before that, the column usually held the 128000 default. Timeline refreshes reserve 4096 + 1024 tokens per account for the answer, so on a 16k context with four accounts the body is deleted once the prompt passes about 7.7k estimated tokens, under half the window. The small profile prompt still fits, which is why profiles keep working. ## What changed - `noodle-post-target.ts`: `noodleTimelineMaxTokensForPrompt()` returns the largest `max_tokens` that fits beside the whole prompt. It uses the bundled fitter's own estimate and margin, and keeps 15% of the prompt estimate back as slack, because the characters / 4 estimate undercounts IDs, timestamps and digits on some tokenizers (Gemma spends a token per digit) and KoboldCpp cuts the *start* of a prompt that overflows. It returns null when less than 1024 tokens (or a smaller budget saved on the connection) would be left. - `noodle-public-generation.service.ts`: a small `NoodleTimelineBudgetProvider` facade (same shape as the vendored `ConnectionDefaultProvider`) wraps the **primary** connection's provider for the three timeline calls: first try, text-only vision retry and correction. Because only the primary is wrapped, a configured fallback connection still gets the original request and fits it to its own context. Profile generation keeps the unwrapped provider. - When too little room is left, the refresh stops before sending, with: "The timeline prompt is too long for this connection's context window. No timeline changes were saved. In Noodle settings, use fewer active accounts or turn off Lorebook context. You can also turn off Allow Noodle references in some chats, or load the model with a larger context size." The wording names controls that every Active Accounts mode shows. - If the prompt with images is the part that does not fit, the refresh retries text-only, as it already does when a model rejects images. - If an answer under a lowered limit runs out of room and cannot be used, the refresh ends with the same message, instead of a correction pass that has even less room and reports "no timeline activity twice". - Debug Mode logs when the answer limit was lowered. - New `tests/noodle-timeline-context-budget.regression.ts`. It runs the vendored fitter from source (the code Noodle bundles), checks that the fitter still deletes the body without the guard, and that the guarded budget keeps every message across 8k–128k contexts, 1, 3 and 6 accounts and prompts up to 200k characters. It also pins the call sites: all three timeline calls use the wrapped provider, and only the primary is wrapped. The required "Catalog validation" CI job now runs it. - Noodle 1.4.1 (`[highlight]` changelog entry), rebuilt `server.mjs`, manifest, `artifacts/noodle-1.4.1.zip`, catalog lanes and notes. The guard sits in package-owned code rather than a package-owned copy of `base-provider.ts`: `sources/engine` is frozen by the vendored-Engine baseline, and an override would fork an 800-line file and need a build-script change. A `ponytail:` comment records the ceiling (the estimate is still characters / 4) and the upgrade path (generate through the Engine's live LLM integration, Capability API 1.31, and count real tokens where the backend can). ## Package and security impact - Affected package IDs: `noodle` (1.4.0 → 1.4.1). - Engine compatibility impact: none. `engine.min` 2.4.6, capability API 1.35 and permissions are unchanged. - New or changed permissions/entrypoints: none. The executable server payload changed: `server.mjs` only. `client.js` is byte-identical to 1.4.0. - Restart, storage, update, or uninstall impact: no storage, schema, route or lifecycle change. A normal package update and restart. Build provenance: rebuilt with `MARINARA_ENGINE_ROOT` at Engine `ead04150a`. With that root, an unchanged tree reproduces the published Noodle 1.4.0 byte for byte (zip, `server.mjs`, `client.js`, catalogs), so the artifact diff contains only this change. A second rebuild of this branch is byte-identical. Newer Engine staging adds unrelated Engine CSS to `client.js` (#6941 and the editor-header fix). ## Validation - [ ] `node scripts/validate-catalog.mjs` passes locally - [ ] `git diff --check` passes locally - [ ] Rebuilt every affected manifest, payload, artifact, and catalog entry - [ ] Installed or updated the affected package through Marinara Engine - [ ] Checked supported modes, restart behavior, and uninstall cleanup - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes Run by the agent: - Passed: `npm run check`, `npm run typecheck:packages`, `node scripts/test-catalog-lanes.mjs`, `node scripts/tests/ui-translation-retention.regression.mjs`, `node scripts/validate-package-locales.mjs`, `node scripts/validate-package-locale-keys.mjs`, `node scripts/validate-catalog.mjs`, `node scripts/tests/catalog-generatedat-determinism.regression.mjs`, `node scripts/tests/catalog-release-notes.regression.mjs`, `node scripts/tests/vendored-engine.regression.mjs`, `npm run test:security`, `node scripts/validate-pr-triage.mjs`, `git diff --check`. - The new regression passes, and fails if a timeline call bypasses the wrapper, if the fallback is wrapped too, if the guard stops lowering the budget, or if the slack is removed (all four mutations checked). - `npm run test:noodle:regressions` stops at the first failure: `noodle-public-only` fails on untouched staging. Run one by one, the same 46 Noodle/NoodleR/Slurp regressions fail on untouched `origin/staging` and on this branch; every other one passes. - End to end on the first commit: a real Engine (`ead04150a`, isolated data dir) with each artifact installed through `installPackageBrowserFixture`, a fake KoboldCpp backend recording every request, Max Context set to 16384 by the Engine's own `refresh-local-context`, and 4 characters with long cards. 1.4.0 sent only the system prompt and JSON format (`max_tokens` 8192), and so did its correction. 1.4.1 sent all three messages with a lowered `max_tokens` and created posts. A prompt too big for the window failed with the new message and sent nothing. At 128k the request was unchanged from 1.4.0. The fallback, image, slack and wording problems that run found are what the second commit fixes. - Local CodeRabbit (`coderabbit review --agent --committed --base staging`): 0 findings on the first commit and 0 on the second. Not run by the agent: - An update from 1.4.0 to 1.4.1 through Agents → Download Agents, offline restart and uninstall. This change touches no storage, permissions, entrypoints, routes or startup code. - A real KoboldCpp or llama.cpp with Gemma 4. The fake backend answers instantly, so how a real model uses a lowered limit is unverified. - A real-Engine run of the second commit's new paths: the fallback wrapper, the text-only retry when the images are what does not fit, the stop after an answer runs out of room, and the 15% slack. The first commit's end-to-end run covered the core fix; the second commit is covered by the regression, its four mutation checks, review and CodeRabbit only. - The "Noodle package browser" CI job fails on pre-existing vendored-Engine drift before its e2e step, as on #1188, so it provides no automated browser proof here. Still to verify by hand: - Update Noodle to 1.4.1 through Agents → Download Agents on an Engine staging checkout, restart, and confirm the timeline loads. - On a local KoboldCpp or llama.cpp connection with a 16k context and 4 or more active accounts, refresh the timeline. The backend should receive the full prompt (check its prompt token count) with a smaller `max_tokens`, and posts should appear. - With a prompt larger than the context (many accounts, chats with Allow Noodle references, Lorebook context on), confirm the refresh stops at once with the new message and nothing is sent to the backend. - With a fallback connection for main that has a larger context, and a prompt too big for the primary, confirm the fallback takes the refresh with the full prompt. - On a cloud connection with a large context, confirm refreshes behave as before. ## Documentation impact - [ ] No documentation changes needed - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation No README or Engine documentation change is made here: the 1.4.1 release notes describe the change, and no existing statement in the README or the Engine docs becomes wrong. Pre-existing Engine docs gap for a follow-up: `docs/noodle/settings.md` says All invited has no cap and never names Accounts per refresh. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Timeline refreshes now preserve the full prompt when it exceeds a local model’s context budget by reducing the space reserved for the answer. If too little answer space remains, refresh stops and explains what to reduce. * When image-based timeline generation cannot proceed because the prompt is too long or the model rejects image input, Noodle can retry using text-only content. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-21 05:09:12 +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-Agents#1340
No description provided.