[PR #352] [MERGED] feat: Enable Custom Chat Memory Agents #4575

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/352
Author: @adunato
Created: 5/2/2026
Status: ✅ Merged
Merged: 5/3/2026
Merged by: @SpicyMarinara

Base: main ← Head: upstream-main


📝 Commits (1)

  • da5cf51 feat: add CR004 custom chat summary agents

📊 Changes

10 files changed (+573 additions, -98 deletions)

View changed files

📝 packages/client/src/components/agents/AgentEditor.tsx (+74 -0)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+134 -63)
📝 packages/client/src/hooks/use-generate.ts (+5 -0)
➕ packages/client/src/lib/agent-cadence.ts (+72 -0)
📝 packages/server/src/routes/generate.routes.ts (+95 -33)
📝 packages/server/src/services/agents/agent-executor.ts (+2 -1)
📝 packages/server/src/services/storage/agents.storage.ts (+12 -0)
📝 packages/server/src/services/storage/chats.storage.ts (+53 -0)
📝 packages/server/src/services/tools/tool-executor.ts (+103 -1)
📝 packages/shared/src/types/agent.ts (+23 -0)

📄 Description

Linked issue

Closes #331

Why this change

Custom agents can participate in generation, but they did not have a clean way to maintain durable chat memory. This change lets users build their own memory agents that can read the current chat summary, append durable updates, and run on a configurable cadence without replacing the built-in summary agent. This change also add a general capability of a configurable execution cadence for custom agents and the ability for custom agents to return content by patching the chat meta data, both required to manage custom chat memory operations.

What changed

  • Added read_chat_summary and append_chat_summary built-in tool definitions and execution support.
  • Added route-owned chat metadata patching so summary tool updates persist and stream a metadata_patch event back to the client.
  • Passed summary-capable tool context through eligible custom agent execution.
  • Refreshed chat detail state on metadata patch events so summary UI can reflect background memory updates.
  • Added custom-agent cadence settings so agents can run every N eligible chat messages instead of on every generation. This setting coexists with the "Context Size" setting which is applied on top of cadence setting.
  • Preserved existing upstream Knowledge Router behavior and stripped local-only workflow artifacts from the PR branch.

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
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Create a custom agent with the documented memory-keeper prompt, allow it to use summary tools, generate a chat response, and verify the persisted summary updates.
  • Configure the custom agent to run every N eligible chat messages and verify it does not run before the cadence threshold is met.
  • Verify summary UI refreshes when the custom agent updates metadata.
  • Verify tools still execute for normal agents and do not regress existing custom-tool behavior.
  • Verify the existing built-in chat summary agent still works or remains unaffected.
  • Verify disabled custom memory-agent configuration has no side effects.
  • Verify generation still works when the custom memory agent is disabled.
  • Verify a summary update persists to chat metadata.
  • Verify unrelated tools and custom tools still execute.

Docs and release impact

  • No docs changes needed. Not applicable: this PR does not change install, update, release, or user-facing documentation behavior.
  • [n/a] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • [n/a] Version/release files updated. Not applicable: this PR does not include a version bump or release metadata change.

UI evidence (if applicable)

New Trigger Cadence field added to: pop-up screen when adding a new custom agent to the chat, custom agent configuration. Built-in agent configuration is not affected.

image

Summary by CodeRabbit

  • New Features

    • Cadence-aware run-interval inputs for custom agents with keyboard/step controls and improved add-agent/edit UIs.
    • Two built-in agent tools to read and append per-chat summaries; agents can persist and update durable chat summaries.
    • Server now enforces agent cadences so custom agents only trigger when their interval is met.
    • Reliable queued chat-metadata patching and propagation ensures summary updates persist and broadcast.
  • Bug Fixes

    • Metadata updates now trigger UI refreshes so summaries and metadata-dependent views stay current.

🔄 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/352 **Author:** [@adunato](https://github.com/adunato) **Created:** 5/2/2026 **Status:** ✅ Merged **Merged:** 5/3/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `main` ← **Head:** `upstream-main` --- ### 📝 Commits (1) - [`da5cf51`](https://github.com/Pasta-Devs/Marinara-Engine/commit/da5cf51038727640443a69227dc38543c51635b5) feat: add CR004 custom chat summary agents ### 📊 Changes **10 files changed** (+573 additions, -98 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/agents/AgentEditor.tsx` (+74 -0) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+134 -63) 📝 `packages/client/src/hooks/use-generate.ts` (+5 -0) ➕ `packages/client/src/lib/agent-cadence.ts` (+72 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+95 -33) 📝 `packages/server/src/services/agents/agent-executor.ts` (+2 -1) 📝 `packages/server/src/services/storage/agents.storage.ts` (+12 -0) 📝 `packages/server/src/services/storage/chats.storage.ts` (+53 -0) 📝 `packages/server/src/services/tools/tool-executor.ts` (+103 -1) 📝 `packages/shared/src/types/agent.ts` (+23 -0) </details> ### 📄 Description ## Linked issue Closes #331 ## Why this change Custom agents can participate in generation, but they did not have a clean way to maintain durable chat memory. This change lets users build their own memory agents that can read the current chat summary, append durable updates, and run on a configurable cadence without replacing the built-in summary agent. This change also add a general capability of a configurable execution cadence for custom agents and the ability for custom agents to return content by patching the chat meta data, both required to manage custom chat memory operations. ## What changed - Added `read_chat_summary` and `append_chat_summary` built-in tool definitions and execution support. - Added route-owned chat metadata patching so summary tool updates persist and stream a `metadata_patch` event back to the client. - Passed summary-capable tool context through eligible custom agent execution. - Refreshed chat detail state on metadata patch events so summary UI can reflect background memory updates. - Added custom-agent cadence settings so agents can run every N eligible chat messages instead of on every generation. This setting coexists with the "Context Size" setting which is applied on top of cadence setting. - Preserved existing upstream Knowledge Router behavior and stripped local-only workflow artifacts from the PR branch. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Create a custom agent with the documented memory-keeper prompt, allow it to use summary tools, generate a chat response, and verify the persisted summary updates. - Configure the custom agent to run every N eligible chat messages and verify it does not run before the cadence threshold is met. - Verify summary UI refreshes when the custom agent updates metadata. - Verify tools still execute for normal agents and do not regress existing custom-tool behavior. - Verify the existing built-in chat summary agent still works or remains unaffected. - Verify disabled custom memory-agent configuration has no side effects. - Verify generation still works when the custom memory agent is disabled. - Verify a summary update persists to chat metadata. - Verify unrelated tools and custom tools still execute. ## Docs and release impact - [x] No docs changes needed. Not applicable: this PR does not change install, update, release, or user-facing documentation behavior. - [n/a] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [n/a] Version/release files updated. Not applicable: this PR does not include a version bump or release metadata change. ## UI evidence (if applicable) New Trigger Cadence field added to: pop-up screen when adding a new custom agent to the chat, custom agent configuration. Built-in agent configuration is not affected. <img width="335" height="105" alt="image" src="https://github.com/user-attachments/assets/e68be7e3-5686-4072-b2bc-c4fd443eb11b" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Cadence-aware run-interval inputs for custom agents with keyboard/step controls and improved add-agent/edit UIs. * Two built-in agent tools to read and append per-chat summaries; agents can persist and update durable chat summaries. * Server now enforces agent cadences so custom agents only trigger when their interval is met. * Reliable queued chat-metadata patching and propagation ensures summary updates persist and broadcast. * **Bug Fixes** * Metadata updates now trigger UI refreshes so summaries and metadata-dependent views stay current. <!-- 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-22 04:08:51 +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#4575
No description provided.