[PR #7637] [MERGED] fix(memory): keep Helper replies that end in Anthropic's "end_turn" #7849

Closed
opened 2026-10-24 04:08:08 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7637
Author: @SpicyMarinara
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/recollections-backfill-resume


📝 Commits (2)

  • 806f359 fix(memory): keep Helper replies that end in Anthropic's "end_turn"
  • e15ab07 Merge branch 'staging' into fix/recollections-backfill-resume

📊 Changes

4 files changed (+58 additions, -6 deletions)

View changed files

📝 packages/server/src/services/advanced-memory.ts (+4 -4)
📝 packages/server/src/services/agents/agent-progress.ts (+2 -1)
📝 packages/server/src/services/generation/empty-response-reason.ts (+12 -0)
📝 scripts/regressions/advanced-memory-recollections.regression.ts (+40 -1)

📄 Description

Important

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

Linked issue

No linked issue: reported by the maintainer on 2026-10-14. Follow-up to #7605 (#7602, character recollections).

Why this change

  • With a Claude model as the Advanced Memory Helper, Character recollections never finished. Every scene ended with "The summary model did not complete its summary", and Resume started all of them again. On the maintainer's chat, all 76 scenes failed on every run, and each failed scene had already paid for its Opus reply.
  • Cause: Advanced Memory accepted a Helper reply only when its finish reason was exactly "stop". The Anthropic provider passes Anthropic's own stop_reason through (provider-compat pins that), so a normal Claude reply ends in "end_turn". The same check guards the scene check, scene summaries, constant summaries, message visibility and the agent scene check. A Claude Helper therefore couldn't even get past the first scene check; it only worked before with Helpers that end in "stop", such as OpenAI models.

What changed

  • A reply is judged by its content. Only an ending that means the reply wasn't finished is refused: length (cut off), abort, error, content_filter, refusal, tool_calls. Any other ending is accepted when the reply has what was asked for (the JSON fields, a summary): Anthropic's end_turn and stop_sequence, a local server's own wording, or no reason at all. The existing format checks still refuse a reply that lacks them.
  • One shared helper, replyUnfinished (services/generation/empty-response-reason.ts), used by the four checks: askHelperJson (scene check and message visibility), summarize (scene summaries, constant summaries, recollections), the scene decision in classify, and the agent scene check in completeAgentCall.
  • Regression: advanced-memory-recollections section 10 runs a Helper that ends every reply in end_turn. Scene check, summaries and backfilled recollections are all kept, each scene is paid for once, and nothing is asked again. Against staging's code it fails at the first scene check: The scene helper did not complete its scene decision; retry preparation (advanced-memory.ts:2749).

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Commands run (results as reported, not a substitute for the boxes above):

  • pnpm check: exit 0, run before tool_calls was added back to the unfinished endings (a one-word change).
  • node scripts/run-regressions.mjs --filter advanced-memory: 18/18 passed, including advanced-memory-post-generation, which pins that length, error, abort, tool_calls and content_filter are still refused.
  • --filter agent-scene-check 1/1, --filter scene 4/4, --filter agent 19/19 passed.
  • Fail-before: the new section 10 fails against staging's code at the scene check (see above).

Manual verification notes

  • Manually verify, with a native Anthropic connection (for example claude-opus-5-5) as the Advanced Memory Helper in a Roleplay chat whose scenes are already summarized: turn on Character recollections. They should be written for every scene, and the run should end without an error.
  • Manually verify Resume after Cancel during that run continues with the remaining scenes only.
  • Manually verify the same Helper prepares a fresh chat: scene check and scene summaries finish.
  • Manually verify with a local Helper (KoboldCpp, llama.cpp or Ollama) that summaries still finish, and that a reply cut off by its output limit still shows "reached its output limit".

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Not in this PR: Delete for a single recollection in the Inspector, and keeping a paid reply that fails a later step. Those follow in a separate PR so this fix isn't held up.


🔄 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-Engine/pull/7637 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/recollections-backfill-resume` --- ### 📝 Commits (2) - [`806f359`](https://github.com/Pasta-Devs/Marinara-Engine/commit/806f3596d6294b02a84f7394ca5aa3e2e821d48e) fix(memory): keep Helper replies that end in Anthropic's "end_turn" - [`e15ab07`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e15ab07c8a20ab3db65669faea5d1c436fc972e0) Merge branch 'staging' into fix/recollections-backfill-resume ### 📊 Changes **4 files changed** (+58 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/advanced-memory.ts` (+4 -4) 📝 `packages/server/src/services/agents/agent-progress.ts` (+2 -1) 📝 `packages/server/src/services/generation/empty-response-reason.ts` (+12 -0) 📝 `scripts/regressions/advanced-memory-recollections.regression.ts` (+40 -1) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue No linked issue: reported by the maintainer on 2026-10-14. Follow-up to #7605 (#7602, character recollections). ## Why this change - With a Claude model as the Advanced Memory Helper, Character recollections never finished. Every scene ended with "The summary model did not complete its summary", and Resume started all of them again. On the maintainer's chat, all 76 scenes failed on every run, and each failed scene had already paid for its Opus reply. - Cause: Advanced Memory accepted a Helper reply only when its finish reason was exactly `"stop"`. The Anthropic provider passes Anthropic's own `stop_reason` through (`provider-compat` pins that), so a normal Claude reply ends in `"end_turn"`. The same check guards the scene check, scene summaries, constant summaries, message visibility and the agent scene check. A Claude Helper therefore couldn't even get past the first scene check; it only worked before with Helpers that end in `"stop"`, such as OpenAI models. ## What changed - A reply is judged by its content. Only an ending that means the reply wasn't finished is refused: `length` (cut off), `abort`, `error`, `content_filter`, `refusal`, `tool_calls`. Any other ending is accepted when the reply has what was asked for (the JSON fields, a summary): Anthropic's `end_turn` and `stop_sequence`, a local server's own wording, or no reason at all. The existing format checks still refuse a reply that lacks them. - One shared helper, `replyUnfinished` (`services/generation/empty-response-reason.ts`), used by the four checks: `askHelperJson` (scene check and message visibility), `summarize` (scene summaries, constant summaries, recollections), the scene decision in `classify`, and the agent scene check in `completeAgentCall`. - Regression: `advanced-memory-recollections` section 10 runs a Helper that ends every reply in `end_turn`. Scene check, summaries and backfilled recollections are all kept, each scene is paid for once, and nothing is asked again. Against staging's code it fails at the first scene check: `The scene helper did not complete its scene decision; retry preparation` (advanced-memory.ts:2749). ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Commands run (results as reported, not a substitute for the boxes above): - `pnpm check`: exit 0, run before `tool_calls` was added back to the unfinished endings (a one-word change). - `node scripts/run-regressions.mjs --filter advanced-memory`: 18/18 passed, including `advanced-memory-post-generation`, which pins that `length`, `error`, `abort`, `tool_calls` and `content_filter` are still refused. - `--filter agent-scene-check` 1/1, `--filter scene` 4/4, `--filter agent` 19/19 passed. - Fail-before: the new section 10 fails against staging's code at the scene check (see above). ### Manual verification notes - Manually verify, with a native Anthropic connection (for example `claude-opus-5-5`) as the Advanced Memory Helper in a Roleplay chat whose scenes are already summarized: turn on **Character recollections**. They should be written for every scene, and the run should end without an error. - Manually verify Resume after Cancel during that run continues with the remaining scenes only. - Manually verify the same Helper prepares a fresh chat: scene check and scene summaries finish. - Manually verify with a local Helper (KoboldCpp, llama.cpp or Ollama) that summaries still finish, and that a reply cut off by its output limit still shows "reached its output limit". ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Not in this PR: Delete for a single recollection in the Inspector, and keeping a paid reply that fails a later step. Those follow in a separate PR so this fix isn't held up. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:08:08 +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#7849
No description provided.