[PR #5311] [MERGED] feat: let custom agents route active chat characters #6724

Closed
opened 2026-10-23 04:13:05 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5311
Author: @SpicyMarinara
Created: 8/20/2026
Status: ✅ Merged
Merged: 8/20/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/5310-custom-agent-character-routing


📝 Commits (5)

  • b94b3df feat: let agents route active chat characters
  • 2feff23 feat: route active characters before generation
  • 05639f5 fix: address character routing review
  • e4d8ce6 chore: clarify routing cadence diagnostics
  • b3a670a Merge remote-tracking branch 'origin/staging' into feat/5310-custom-agent-character-routing

📊 Changes

9 files changed (+524 additions, -75 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/client/src/components/agents/AgentEditor.tsx (+41 -7)
📝 packages/client/src/lib/custom-agent-result-examples.ts (+4 -0)
📝 packages/client/src/localization/locales/en.json (+5 -0)
📝 packages/server/src/routes/generate.routes.ts (+333 -68)
📝 packages/server/src/routes/generate/generate-route-utils.ts (+37 -0)
📝 packages/server/src/services/agents/agent-executor.ts (+18 -0)
📝 packages/shared/src/types/agent.ts (+9 -0)
➕ scripts/regressions/character-activity-agent.regression.ts (+76 -0)

📄 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

Closes #5310

Why this change

  • Custom routing agents could not use the chat's existing character activity controls, so every enabled card remained in the main prompt and eligible to reply.
  • Users need a small, explicit routing result so an Agent can select the relevant speakers before the expensive main generation.

What changed

  • Added the opt-in manage_chat_characters custom-Agent capability and character_activity_update result type.
  • Character Activity agents run before prompt assembly for fresh Conversation and Roleplay replies and return a nonempty activeCharacterIds list.
  • The server validates every returned ID against the chat, updates the existing inactiveCharacterIds metadata, and assembles the current reply with only the selected cards.
  • Swipes, continuations, impersonation, and Game mode keep their existing behavior.
  • Added localized Agent Editor guidance, result preview data, a changelog entry, and a focused regression proof.

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

Automated results:

  • pnpm check — passed.
  • pnpm localization:check — passed.
  • pnpm format:check — passed.
  • pnpm regression:node -- --filter character-activity-agent — passed.
  • pnpm smoke:ui — the custom-Agent result-format coverage passed on mobile and desktop. The complete suite reached all 360 cases but retained unrelated failures and did not exit cleanly during teardown.
  • pnpm regression:prompt — stopped at the existing Beholder message-order assertion; this branch does not change that code path and origin/staging has the same ordering.

Manual verification notes

  • Manually verify a custom Agent with Choose active chat characters can switch the enabled cards for the same reply in both Conversation and Roleplay modes.
  • Manually verify the chat settings reflect the Agent's selection after generation.
  • Manually verify invalid, empty, or unknown character IDs do not change chat metadata.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) 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)

The user-facing change is recorded under CHANGELOG.md [Unreleased]. No long-form docs or release metadata changed.

UI evidence (if applicable)

  • Automated desktop and mobile UI coverage confirms the selected result-format preview. An interactive browser session was unavailable for screenshot capture in this environment.

Summary by CodeRabbit

  • New Features

    • Added support for pre-generation agents that select active characters in Conversation and Roleplay replies.
    • Added a custom-agent capability for managing chat-character activity.
    • Added character activity results with active character IDs, validation, and JSON examples.
    • Added progress, warnings, and metadata for character activity processing.
  • Bug Fixes

    • Prevented character activity agents from running in unsupported modes, regenerations, and continuations.
    • Added validation for invalid or unavailable character selections.

🔄 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/5311 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 8/20/2026 **Status:** ✅ Merged **Merged:** 8/20/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/5310-custom-agent-character-routing` --- ### 📝 Commits (5) - [`b94b3df`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b94b3df468faf3aa8acf9b55718dd97872e5c559) feat: let agents route active chat characters - [`2feff23`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2feff230acbaf70f7b0fd5a47db48a21cec0a1f0) feat: route active characters before generation - [`05639f5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/05639f5b9e79eb369f4d82534bb9462d509f75aa) fix: address character routing review - [`e4d8ce6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e4d8ce60323d06645d62a731e09660c490c89cda) chore: clarify routing cadence diagnostics - [`b3a670a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b3a670a04c56fc9771d48d37f23523577bb35b41) Merge remote-tracking branch 'origin/staging' into feat/5310-custom-agent-character-routing ### 📊 Changes **9 files changed** (+524 additions, -75 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/client/src/components/agents/AgentEditor.tsx` (+41 -7) 📝 `packages/client/src/lib/custom-agent-result-examples.ts` (+4 -0) 📝 `packages/client/src/localization/locales/en.json` (+5 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+333 -68) 📝 `packages/server/src/routes/generate/generate-route-utils.ts` (+37 -0) 📝 `packages/server/src/services/agents/agent-executor.ts` (+18 -0) 📝 `packages/shared/src/types/agent.ts` (+9 -0) ➕ `scripts/regressions/character-activity-agent.regression.ts` (+76 -0) </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`. ## Linked issue Closes #5310 ## Why this change - Custom routing agents could not use the chat's existing character activity controls, so every enabled card remained in the main prompt and eligible to reply. - Users need a small, explicit routing result so an Agent can select the relevant speakers before the expensive main generation. ## What changed - Added the opt-in `manage_chat_characters` custom-Agent capability and `character_activity_update` result type. - Character Activity agents run before prompt assembly for fresh Conversation and Roleplay replies and return a nonempty `activeCharacterIds` list. - The server validates every returned ID against the chat, updates the existing `inactiveCharacterIds` metadata, and assembles the current reply with only the selected cards. - Swipes, continuations, impersonation, and Game mode keep their existing behavior. - Added localized Agent Editor guidance, result preview data, a changelog entry, and a focused regression proof. ## 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` Automated results: - `pnpm check` — passed. - `pnpm localization:check` — passed. - `pnpm format:check` — passed. - `pnpm regression:node -- --filter character-activity-agent` — passed. - `pnpm smoke:ui` — the custom-Agent result-format coverage passed on mobile and desktop. The complete suite reached all 360 cases but retained unrelated failures and did not exit cleanly during teardown. - `pnpm regression:prompt` — stopped at the existing Beholder message-order assertion; this branch does not change that code path and `origin/staging` has the same ordering. ### Manual verification notes - Manually verify a custom Agent with **Choose active chat characters** can switch the enabled cards for the same reply in both Conversation and Roleplay modes. - Manually verify the chat settings reflect the Agent's selection after generation. - Manually verify invalid, empty, or unknown character IDs do not change chat metadata. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) 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) The user-facing change is recorded under `CHANGELOG.md` `[Unreleased]`. No long-form docs or release metadata changed. ## UI evidence (if applicable) - Automated desktop and mobile UI coverage confirms the selected result-format preview. An interactive browser session was unavailable for screenshot capture in this environment. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for pre-generation agents that select active characters in Conversation and Roleplay replies. * Added a custom-agent capability for managing chat-character activity. * Added character activity results with active character IDs, validation, and JSON examples. * Added progress, warnings, and metadata for character activity processing. * **Bug Fixes** * Prevented character activity agents from running in unsupported modes, regenerations, and continuations. * Added validation for invalid or unavailable character selections. <!-- 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-23 04:13:05 +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#6724
No description provided.