[PR #2072] [MERGED] feat(otome-forge): a fixed-size story memory and cache-friendly story prompts (0.7.0) #2101

Closed
opened 2026-11-07 16:39:30 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: staging ← Head: feat/otome-memory-rework


📝 Commits (2)

  • 5958367 feat(otome-forge): a fixed-size story memory and cache-friendly story prompts (0.7.0)
  • a50f11a Merge remote-tracking branch 'origin/staging' into feat/otome-memory-rework

📊 Changes

64 files changed (+1790 additions, -1300 deletions)

View changed files

➕ artifacts/otome-forge-0.7.0.zip (+0 -0)
📝 catalog/preview/catalog.json (+8 -8)
📝 catalog/preview/notes.json (+6 -6)
📝 catalog/preview/v2/catalog.json (+8 -8)
📝 catalog/preview/v2/notes.json (+6 -6)
📝 catalog/preview/v3/catalog.json (+8 -8)
📝 catalog/preview/v3/notes.json (+6 -6)
📝 packages/otome-forge/CHANGELOG.md (+9 -0)
📝 packages/otome-forge/client.js (+305 -311)
📝 packages/otome-forge/manifest.json (+5 -5)
📝 packages/otome-forge/server.mjs (+157 -150)
📝 packages/otome-forge/src/engine/packages/client/src/features/otome-forge/hooks/use-engine-resources.ts (+3 -0)
📝 packages/otome-forge/src/engine/packages/client/src/features/otome-forge/locales/en.json (+1 -1)
➖ packages/otome-forge/src/engine/packages/client/src/features/otome-forge/screens/phone/SuggestionChips.tsx (+0 -33)
📝 packages/otome-forge/src/engine/packages/client/src/features/otome-forge/screens/phone/Thread.tsx (+3 -22)
📝 packages/otome-forge/src/engine/packages/client/src/features/otome-forge/screens/setup/ConnectionsStep.tsx (+10 -1)
📝 packages/otome-forge/src/engine/packages/client/src/features/otome-forge/screens/setup/parts.tsx (+22 -2)
📝 packages/otome-forge/src/engine/packages/client/src/features/otome-forge/shared/api-types.ts (+0 -3)
📝 packages/otome-forge/src/engine/packages/client/src/features/otome-forge/theme/styles.ts (+1 -8)
📝 packages/otome-forge/src/engine/packages/server/src/services/otome-forge/generation.ts (+36 -10)

...and 44 more files

📄 Description

Pull request

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 #2066

Why this change

  • One player's Otome Hearth story sent 1.72M prompt tokens in an hour. The story memory's overview was sized at a tenth of the model's context, so on a 1M-token model it grew to about 100k tokens. It was then re-sent with every scene and rewritten by a model call for every chapter.
  • The maintainer's spec for what a story prompt carries: the prompt; the persona, the love interests and the world; a timeline of what happened so far; a few recent small memories; and the last chapter in full, with only the choices that were picked. Summaries stay small, and the large context that never changes should be cached so the calls cost less.

What changed

Package: otome-forge 0.7.0 (rebuilt server.mjs, client.js, artifact, catalog preview entries).

  • Summaries.
    • Each chapter is summarized once. The prompt asks for at most 500 words, the key lines quoted with who said them, and every choice the protagonist made.
    • Every summary call keeps 10,240 tokens of reply room, for thinking models.
    • A love interest's private chapter opens with "Private: only and the protagonist know this."
  • Timeline (memory/timeline.ts).
    • The kit's overview is now a timeline: a condensed head, plus each chapter's summary appended with no model call.
    • Only once the timeline crosses 10k tokens is everything but the newest entry condensed, in one call, into at most 3,000 words.
    • The kit is told a fixed context, so the timeline's size no longer follows the model.
    • A prompt leaves out the previous chapter's own entry, because that chapter goes in full.
  • Stories in progress. An older overview reads as none. The background job rebuilds the timeline from the saved summaries with no new summary call; the regression proves 0 calls.
  • Recalls.
    • Ranked details and embeddings are gone, so no vector calls are made.
    • Beside the timeline go the newest small memories the prompt may know, newest first, within 5,000 tokens, with the oldest left out:
      • phone sessions;
      • Snapshots;
      • Read Him sets and Claw rounds;
      • Read Me notebook sets;
      • dates, Character Stories and Moments, by their summaries.
    • Dates, Character Stories and Moments stay out of the shared timeline, so each reaches only its own love interest.
  • No irrevocable-decisions list. The canon carries each pick as [Canonical player choice: …], and the summaries name every choice.
  • Cache-friendly prompts.
    • P5 (chapter plan), P6 (scene), P12 (Confrontation) and P12c (Closer) open with one shared story context: the rules, the content contract for the whole cast, the world, the protagonist, this chapter's arc purpose (never the reveal or the later purposes, which only P5 sees), the timeline, and the previous chapter in full.
    • That is followed by the prompt's own instructions, then each settled scene of the chapter as its own message.
    • Each of those parts is marked with cacheBreakpoint (capability API 1.814; older Engines ignore it).
    • Everything that changes comes last: the newest scene, cast cards, recalls and the task.
    • Debug mode logs the provider's cache reads and writes.
  • Messages: suggested replies are removed end to end. The player writes their own, and saved threads still read.
  • Stickers: the prompt asks for no white outline, and the negative prompt names it.
  • Settings → Connections and Setup: a warning, never a block, when a story connection's context window is under 32k tokens.

Package and security impact

  • Affected package IDs: otome-forge
  • Engine compatibility impact: none required. The cache marks need capability API 1.814 to take effect and are ignored before it; the floor stays 1.386.
  • New or changed permissions/entrypoints: none
  • Restart, storage, update, or uninstall impact: the memory document gets a new overview form (overviewStyle 3). The first maintenance after the update rebuilds it from saved summaries with no model calls.

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

Agent-run checks:

  • Typecheck: no errors.
  • tests/otome-forge-*.regression.ts: 634/634 pass.
  • tests/otome-forge-*.regression.mjs: 12/12 pass.
  • Catalog release-notes, determinism, store and translation-retention checks: pass.
  • git diff --check: pass.
  • validate-catalog could not run in this sparse worktree (other packages' artifacts aren't checked out); CI runs it.
  • Prettier and ESLint: clean (4 existing warnings in story/chapters.ts).
  • The browser suite has not been run yet.

Manual verification notes

  • Manually verify, in an existing story, that after updating, Settings → Debug's memory status goes to ready without new summary calls in the debug log.
  • Manually verify that "What happened so far…" shows the chapter summaries.
  • Manually verify, on a Claude connection with debug mode on, that the second scene of a chapter logs Prompt cache: N tokens read with N close to the story context's size.
  • Manually verify that a long story (more than about 10k tokens of summaries) makes one memory-timeline call and then keeps appending.
  • Manually verify in Messages that no suggestion chips appear and that an old thread still opens.
  • Manually verify in Settings → Connections that a connection set to a 16k context shows the warning, and that Save still works.
  • Manually verify that newly painted stickers have no white outline.

Documentation impact

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

UI evidence (if applicable)

  • Removed the suggestion chips under the Messages composer; added a warning line under a connection picker. No screenshots attached.

🤖 Generated with Claude Code


🔄 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/2072 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/otome-memory-rework` --- ### 📝 Commits (2) - [`5958367`](https://github.com/Pasta-Devs/Marinara-Agents/commit/5958367985d237ede25406b01e203b97f3d4586a) feat(otome-forge): a fixed-size story memory and cache-friendly story prompts (0.7.0) - [`a50f11a`](https://github.com/Pasta-Devs/Marinara-Agents/commit/a50f11a7c1696c5b2011ca5d3054fc732918b354) Merge remote-tracking branch 'origin/staging' into feat/otome-memory-rework ### 📊 Changes **64 files changed** (+1790 additions, -1300 deletions) <details> <summary>View changed files</summary> ➕ `artifacts/otome-forge-0.7.0.zip` (+0 -0) 📝 `catalog/preview/catalog.json` (+8 -8) 📝 `catalog/preview/notes.json` (+6 -6) 📝 `catalog/preview/v2/catalog.json` (+8 -8) 📝 `catalog/preview/v2/notes.json` (+6 -6) 📝 `catalog/preview/v3/catalog.json` (+8 -8) 📝 `catalog/preview/v3/notes.json` (+6 -6) 📝 `packages/otome-forge/CHANGELOG.md` (+9 -0) 📝 `packages/otome-forge/client.js` (+305 -311) 📝 `packages/otome-forge/manifest.json` (+5 -5) 📝 `packages/otome-forge/server.mjs` (+157 -150) 📝 `packages/otome-forge/src/engine/packages/client/src/features/otome-forge/hooks/use-engine-resources.ts` (+3 -0) 📝 `packages/otome-forge/src/engine/packages/client/src/features/otome-forge/locales/en.json` (+1 -1) ➖ `packages/otome-forge/src/engine/packages/client/src/features/otome-forge/screens/phone/SuggestionChips.tsx` (+0 -33) 📝 `packages/otome-forge/src/engine/packages/client/src/features/otome-forge/screens/phone/Thread.tsx` (+3 -22) 📝 `packages/otome-forge/src/engine/packages/client/src/features/otome-forge/screens/setup/ConnectionsStep.tsx` (+10 -1) 📝 `packages/otome-forge/src/engine/packages/client/src/features/otome-forge/screens/setup/parts.tsx` (+22 -2) 📝 `packages/otome-forge/src/engine/packages/client/src/features/otome-forge/shared/api-types.ts` (+0 -3) 📝 `packages/otome-forge/src/engine/packages/client/src/features/otome-forge/theme/styles.ts` (+1 -8) 📝 `packages/otome-forge/src/engine/packages/server/src/services/otome-forge/generation.ts` (+36 -10) _...and 44 more files_ </details> ### 📄 Description # Pull request > [!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 #2066 ## Why this change - One player's Otome Hearth story sent 1.72M prompt tokens in an hour. The story memory's overview was sized at a tenth of the model's context, so on a 1M-token model it grew to about 100k tokens. It was then re-sent with every scene and rewritten by a model call for every chapter. - The maintainer's spec for what a story prompt carries: the prompt; the persona, the love interests and the world; a timeline of what happened so far; a few recent small memories; and the last chapter in full, with only the choices that were picked. Summaries stay small, and the large context that never changes should be cached so the calls cost less. ## What changed Package: `otome-forge` 0.7.0 (rebuilt `server.mjs`, `client.js`, artifact, catalog preview entries). - **Summaries.** - Each chapter is summarized once. The prompt asks for at most 500 words, the key lines quoted with who said them, and every choice the protagonist made. - Every summary call keeps 10,240 tokens of reply room, for thinking models. - A love interest's private chapter opens with "Private: only <name> and the protagonist know this." - **Timeline** (`memory/timeline.ts`). - The kit's overview is now a timeline: a condensed head, plus each chapter's summary appended with no model call. - Only once the timeline crosses 10k tokens is everything but the newest entry condensed, in one call, into at most 3,000 words. - The kit is told a fixed context, so the timeline's size no longer follows the model. - A prompt leaves out the previous chapter's own entry, because that chapter goes in full. - **Stories in progress.** An older overview reads as none. The background job rebuilds the timeline from the saved summaries with no new summary call; the regression proves 0 calls. - **Recalls.** - Ranked details and embeddings are gone, so no vector calls are made. - Beside the timeline go the newest small memories the prompt may know, newest first, within 5,000 tokens, with the oldest left out: - phone sessions; - Snapshots; - Read Him sets and Claw rounds; - Read Me notebook sets; - dates, Character Stories and Moments, by their summaries. - Dates, Character Stories and Moments stay out of the shared timeline, so each reaches only its own love interest. - **No irrevocable-decisions list.** The canon carries each pick as `[Canonical player choice: …]`, and the summaries name every choice. - **Cache-friendly prompts.** - P5 (chapter plan), P6 (scene), P12 (Confrontation) and P12c (Closer) open with one shared story context: the rules, the content contract for the whole cast, the world, the protagonist, this chapter's arc purpose (never the reveal or the later purposes, which only P5 sees), the timeline, and the previous chapter in full. - That is followed by the prompt's own instructions, then each settled scene of the chapter as its own message. - Each of those parts is marked with `cacheBreakpoint` (capability API 1.814; older Engines ignore it). - Everything that changes comes last: the newest scene, cast cards, recalls and the task. - Debug mode logs the provider's cache reads and writes. - **Messages:** suggested replies are removed end to end. The player writes their own, and saved threads still read. - **Stickers:** the prompt asks for no white outline, and the negative prompt names it. - **Settings → Connections and Setup:** a warning, never a block, when a story connection's context window is under 32k tokens. ## Package and security impact - Affected package IDs: `otome-forge` - Engine compatibility impact: none required. The cache marks need capability API 1.814 to take effect and are ignored before it; the floor stays 1.386. - New or changed permissions/entrypoints: none - Restart, storage, update, or uninstall impact: the memory document gets a new overview form (`overviewStyle` 3). The first maintenance after the update rebuilds it from saved summaries with no model calls. ## Validation <!-- These are human tasks. Never tick a box for a check that was not actually performed. --> - [ ] `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` Agent-run checks: - Typecheck: no errors. - `tests/otome-forge-*.regression.ts`: 634/634 pass. - `tests/otome-forge-*.regression.mjs`: 12/12 pass. - Catalog release-notes, determinism, store and translation-retention checks: pass. - `git diff --check`: pass. - `validate-catalog` could not run in this sparse worktree (other packages' artifacts aren't checked out); CI runs it. - Prettier and ESLint: clean (4 existing warnings in `story/chapters.ts`). - The browser suite has not been run yet. ### Manual verification notes - Manually verify, in an existing story, that after updating, Settings → Debug's memory status goes to ready without new summary calls in the debug log. - Manually verify that "What happened so far…" shows the chapter summaries. - Manually verify, on a Claude connection with debug mode on, that the second scene of a chapter logs `Prompt cache: N tokens read` with N close to the story context's size. - Manually verify that a long story (more than about 10k tokens of summaries) makes one `memory-timeline` call and then keeps appending. - Manually verify in Messages that no suggestion chips appear and that an old thread still opens. - Manually verify in Settings → Connections that a connection set to a 16k context shows the warning, and that Save still works. - Manually verify that newly painted stickers have no white outline. ## Documentation impact - [ ] No documentation changes needed - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation ## UI evidence (if applicable) - Removed the suggestion chips under the Messages composer; added a warning line under a connection picker. No screenshots attached. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:39:30 +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#2101
No description provided.