mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #204] [MERGED] feat: add Card Evolution Auditor agent with user-approval modal #4504
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4504
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/204
Author: @cha1latte
Created: 4/23/2026
Status: ✅ Merged
Merged: 4/23/2026
Merged by: @SpicyMarinara
Base:
main← Head:feat/card-evolution-auditor📝 Commits (3)
2ed22abfeat: add Card Evolution Auditor agent with user-approval modal5271d2fMerge branch 'main' into feat/card-evolution-auditorb91b390fix: address Card Evolution Auditor review comments📊 Changes
9 files changed (+586 additions, -6 deletions)
View changed files
📝
packages/client/src/components/layout/ModalRenderer.tsx(+6 -0)➕
packages/client/src/components/modals/CharacterCardUpdateModal.tsx(+238 -0)📝
packages/client/src/hooks/use-generate.ts(+164 -0)📝
packages/client/src/stores/agent.store.ts(+31 -1)📝
packages/server/src/routes/generate.routes.ts(+2 -0)📝
packages/server/src/services/agents/agent-executor.ts(+39 -3)📝
packages/shared/src/constants/agent-prompts.ts(+30 -0)📝
packages/shared/src/schemas/agent.schema.ts(+1 -0)📝
packages/shared/src/types/agent.ts(+75 -2)📄 Description
Summary
Adds a new post-processing agent — Card Evolution Auditor — that watches the roleplay for durable changes to a character (dropped out of school, moved cities, changed hair, etc.) and proposes targeted edits to the character card's fields. Unlike the Lorebook Keeper, which writes back automatically, character card edits require the user's explicit approval via a confirmation modal showing the old → new diff per field.
This introduces a new
character_card_updateagent result type in the shared schemas and wires it through the full pipeline: server-side parsing and emission, a client-side pending-approval queue, a confirmation modal, and a surgical field-level apply path that preserves everything around the edited sentence.Why
Character cards drift from what's actually true in long roleplays. A character graduates, quits their job, changes their appearance — but the card still describes them the old way, which then contaminates future generations. This agent closes that loop without risking silent card rewrites that the user didn't sign off on.
Architecture
packages/sharedcharacter_card_updateenum value, built-in agent registration, default prompt,CharacterCardUpdateResult+CharacterCardFieldUpdatetypes.AgentContext.characterswidened to optionally carry richer card fields.packages/servercard-evolution-auditorto the new result type and marks it JSON-output.buildAgentExtrasemits a<character_cards>block with full fields only when this agent is in the batch — no token cost for other agents. No auto-apply: the server only emits the SSE event.packages/clientpendingCardUpdatesqueue inagent.store.use-generatehandles the SSE event, resolves the target character by matchingoldTextagainst each chat character's fields, and opens the modal. NewCharacterCardUpdateModalwith per-edit diff, stale detection, andfield.replace(oldText, newText)apply logic.Known limitations
ChatSettingsDrawer.tsxhides the "Enable Agents" section in Conversation mode, so this agent (like all agents) isn't reachable from Convo chats today. This predates this PR; not a regression. Backend already supportschatMode=conversation. Happy to follow up with a one-line change if you want the toggle exposed there.oldTextagainst each chat character's fields to pick the owner. Works cleanly for single-character chats and for multi-character chats where the edited text is unambiguous. A future prompt change to emit explicitcharacterNameper edit would remove the heuristic — left out of this PR to keep scope tight.Test plan
pnpm checkpasses (lint + production build across all packages).updatesarray, modal appeared with correct character name and old→new diff, approval applied the edit surgically (surrounding description preserved), rejection dismissed without changes.buildAgentExtrasemits<character_cards>only whencard-evolution-auditoris in the agent batch — other agents' context is unchanged.oldTextno longer matches the current field value are flagged and excluded from the approve action.Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.