[PR #8952] [MERGED] feat(capability): tell Long-Term Memory when a chat is branched #8907

Closed
opened 2026-11-07 23:47:24 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8952
Author: @Promansis
Created: 11/7/2026
Status: ✅ Merged
Merged: 11/7/2026
Merged by: @Promansis

Base: staging ← Head: feature(capability)/ltm-chat-branched


📝 Commits (1)

  • 731e794 feat(capability): tell Long-Term Memory when a chat is branched (#8951)

📊 Changes

6 files changed (+107 additions, -3 deletions)

View changed files

📝 docs/development/optional-agent-packages.md (+11 -0)
📝 packages/server/src/routes/chats.routes.ts (+3 -0)
📝 packages/server/src/services/generation/long-term-memory-runtime.ts (+22 -0)
📝 packages/shared/src/schemas/capability-package.schema.ts (+4 -1)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+2 -2)
📝 scripts/regressions/chat-branch-lineage.regression.ts (+65 -0)

📄 Description

Linked issue

Closes #8951

Why this change

When a chat is branched, the Engine copies the parent's messages with their "hidden from the AI" flags. The Long-Term Memory package hides messages it has already turned into memories, so a branch made from inside a hidden stretch opens with every copied message hidden. LTM can only show the last few again once it is asked about that chat, and that first happens at the branch's first recall, after the Engine has already read the history. The branch opens with recent messages shown as hidden, and the first reply is written without them. Packages are told nothing about new chats, so LTM cannot fix this itself.

  • Gives LTM a hook that runs after the branch copy and before the new chat is returned, so it can fix up the copy before the first read.

What changed

  • Capability API 1.817: new optional chatBranched?({ chatId, parentChatId }) on the host-only long-term-memory:runtime service. A package without it is unaffected. No manifest field or permission.
  • POST /:id/branch awaits it once, after messages, metadata and snapshots are copied and before getById(newChat.id).
  • A thrown error or a call slower than 3 seconds is logged with logger.warn and never fails the branch (new notifyLongTermMemoryChatBranched helper, reusing withLongTermMemoryRuntimeTimeout).
  • supportedCapabilityApi bumped to 1.817 and the two 1.816 pins in capability-package-lifecycle.regression.ts moved with it.
  • Documented in docs/development/optional-agent-packages.md.
  • chat-branch-lineage.regression.ts covers: called once with the new and parent ids, with copied messages and branchParentChatId readable inside the call; a throwing service and a never-resolving service still return the branch; a service without the method branches as before.
  • The package side that runs LTM's branch pass from chatBranched lives in Marinara-Agents and is not part of this PR.

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 locally on this head (all exit 0): build:shared; the chat-branch-lineage, capability-package-lifecycle and capability-runtime-host-services regressions; prettier --check on the changed .ts files; tsc --noEmit -p packages/server/tsconfig.json; root tsc (check:e2e-types); server lint; git diff --check. Not run locally: whole-repo pnpm check, the full regression suite, localization checks and a local CodeRabbit review (CLI not installed). Hosted CI covers the rest.

Manual verification notes

  • Manually verify in the app, with a Long-Term Memory package that implements chatBranched: branch a chat from inside a hidden stretch and confirm the branch opens with its recent messages shown.
  • Manually verify that branching still works with a package that has no chatBranched, and with one whose chatBranched throws or hangs (the branch returns after at most about 3 seconds).

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)

No version bump and no CHANGELOG.md edit (release PRs only). The docs change is developer documentation under docs/development/, not a user guide.

UI evidence (if applicable)

None: no client changes.


🔄 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/8952 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 11/7/2026 **Status:** ✅ Merged **Merged:** 11/7/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `feature(capability)/ltm-chat-branched` --- ### 📝 Commits (1) - [`731e794`](https://github.com/Pasta-Devs/Marinara-Engine/commit/731e79425e33ab650cb4f2fa9009c7c0f91a5932) feat(capability): tell Long-Term Memory when a chat is branched (#8951) ### 📊 Changes **6 files changed** (+107 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `docs/development/optional-agent-packages.md` (+11 -0) 📝 `packages/server/src/routes/chats.routes.ts` (+3 -0) 📝 `packages/server/src/services/generation/long-term-memory-runtime.ts` (+22 -0) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+4 -1) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+2 -2) 📝 `scripts/regressions/chat-branch-lineage.regression.ts` (+65 -0) </details> ### 📄 Description ## Linked issue Closes #8951 ## Why this change When a chat is branched, the Engine copies the parent's messages with their "hidden from the AI" flags. The Long-Term Memory package hides messages it has already turned into memories, so a branch made from inside a hidden stretch opens with every copied message hidden. LTM can only show the last few again once it is asked about that chat, and that first happens at the branch's first recall, after the Engine has already read the history. The branch opens with recent messages shown as hidden, and the first reply is written without them. Packages are told nothing about new chats, so LTM cannot fix this itself. - Gives LTM a hook that runs after the branch copy and before the new chat is returned, so it can fix up the copy before the first read. ## What changed - Capability API 1.817: new optional `chatBranched?({ chatId, parentChatId })` on the host-only `long-term-memory:runtime` service. A package without it is unaffected. No manifest field or permission. - `POST /:id/branch` awaits it once, after messages, metadata and snapshots are copied and before `getById(newChat.id)`. - A thrown error or a call slower than 3 seconds is logged with `logger.warn` and never fails the branch (new `notifyLongTermMemoryChatBranched` helper, reusing `withLongTermMemoryRuntimeTimeout`). - `supportedCapabilityApi` bumped to 1.817 and the two 1.816 pins in `capability-package-lifecycle.regression.ts` moved with it. - Documented in `docs/development/optional-agent-packages.md`. - `chat-branch-lineage.regression.ts` covers: called once with the new and parent ids, with copied messages and `branchParentChatId` readable inside the call; a throwing service and a never-resolving service still return the branch; a service without the method branches as before. - The package side that runs LTM's branch pass from `chatBranched` lives in Marinara-Agents and is not part of this PR. ## 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 locally on this head (all exit 0): `build:shared`; the `chat-branch-lineage`, `capability-package-lifecycle` and `capability-runtime-host-services` regressions; `prettier --check` on the changed .ts files; `tsc --noEmit -p packages/server/tsconfig.json`; root `tsc` (check:e2e-types); server `lint`; `git diff --check`. Not run locally: whole-repo `pnpm check`, the full regression suite, localization checks and a local CodeRabbit review (CLI not installed). Hosted CI covers the rest. ### Manual verification notes - Manually verify in the app, with a Long-Term Memory package that implements `chatBranched`: branch a chat from inside a hidden stretch and confirm the branch opens with its recent messages shown. - Manually verify that branching still works with a package that has no `chatBranched`, and with one whose `chatBranched` throws or hangs (the branch returns after at most about 3 seconds). ## 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) No version bump and no `CHANGELOG.md` edit (release PRs only). The docs change is developer documentation under `docs/development/`, not a user guide. ## UI evidence (if applicable) None: no client changes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 23:47:24 +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#8907
No description provided.