mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7437] [MERGED] fix(roleplay): let every agent read whispers #7733
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#7733
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/7437
Author: @SpicyMarinara
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/11/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/agents-see-whispers📝 Commits (10+)
b29f589fix(roleplay): let every agent read whispersabeff2dfix(roleplay): replace a whisper-only placeholder by its position034cd7dfix(roleplay): give retried agents the reply with its whispers2f38cd1fix(roleplay): run post-generation agents on a whisper-only replya0188fafix(roleplay): keep whispers from agents for any unfinished room34054fafix(roleplay): skip rewrites when a turn has only blank public textfe4b231fix(roleplay): run rewrite agents only on a reply with public text52ec7c4fix(roleplay): keep whispers out of a reply's own tools and place a continuation's ownadd3d0bdocs(roleplay): name a rewritten reply among agent output that can carry a whisper099d62cfix(roleplay): let Smart speaker selection read whispers📊 Changes
10 files changed (+929 additions, -80 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
docs/development/multiplayer.md(+1 -1)📝
docs/roleplay/getting-started.md(+3 -1)📝
packages/server/src/routes/generate.routes.ts(+124 -33)📝
packages/server/src/routes/generate/retry-agents-route.ts(+35 -7)📝
packages/server/src/services/generation/roleplay-commands.ts(+128 -23)📝
packages/server/src/services/generation/tool-resolution-runtime.ts(+25 -10)📝
scripts/regressions/agent-activation.regression.ts(+4 -4)➕
scripts/regressions/agents-see-whispers.regression.ts(+602 -0)📝
scripts/regressions/roleplay-user-private-generation.regression.ts(+6 -1)📄 Description
Linked issue
Closes #7430
Why this change
[Private whisper], so Echo Chamber knew something was said but not what. Post-generation agents never saw what a character whispered in the reply they were processing, and a reply that was only a whisper skipped them entirely.What changed
appendRoleplayWhispersinroleplay-commands.ts:roleplayAgentTextrenders a message as agents read it: its text with each live whisper (not deleted, no error) at its saved place, as[Private whisper to <recipient>: <text>]. The recipient is the character's current name, or the persona's name.[Private whisper]placeholder.roleplayAgentPromptgives agents their own copy of a prompt and leaves the responder's prompt alone.appendRoleplayWhispers(placeRoleplayWhispers), so responders and agents put a whisper in the same spot.agentContext.recentMessages, which feeds every pipeline agent, capability packages, agents' tool calls, knowledge retrieval, Music DJ, Illustrator and the expression agent.[Private whisper].roleplayAgentText's optionallimit), so a long whisper cannot crowd out what was said aloud. A whisper whose place is cut off follows the cut text. A line with no whispers is cut exactly as before._mainPromptPreview), both before and during generation.mainResponse, group response segments and lorebook triggers), taken from the reply's saved activity.roleplayAgentContinuationgives it only the whispers written with that text, at their places. The message's earlier whispers stay in the agents' history, where they already were.response_queueevent); nothing the selector writes is shown to users or put into a responder's prompt. The regression checks that the responder, who is not the whisper's recipient, still gets neither whisper on that turn. The selector's raw reply is written to the server log only when it holds no valid character ID, as before.{{input}}(the script and webhook hidden context) is the latest user message's public text, as before. A tool that a non-recipient calls never gets someone else's whisper. Agents' own tool calls keep the agents' input, with whispers.roleplayAgentsSeeWhispersusescurrentRoomGeneration()during room generation, which is the existing room signal. For agent runs started outside it, such as retries, anymultiplayermetadata other than an ended room counts as a room. That includes guest data, a room with no status, and data that can't be read. This is documented in the code comment and the docs.docs/roleplay/getting-started.md(who reads whispers, and that agent output such as a rewritten reply can carry one) anddocs/development/multiplayer.md(room agents never read whispers). Comments that said private state never reaches agents are updated.[Unreleased].scripts/regressions/agents-see-whispers.regression.ts. It fails on staging and passes with this change. Each guard was also checked by reverting it and watching the regression fail. It covers:{{input}}is the public text, and none of that character's requests holds the whisper.Alice, what do you think?: the chat-model selector's line keeps the question and cuts the whisper to its own 900 characters. A helper check covers whispers whose places are cut off, in order.scripts/regressions/roleplay-user-private-generation.regression.ts:280, added by #6878, asserted that speaker selection never receives private activity. Updated with the maintainer's approval to the new rule, not deleted: the Smart selector's prompt must holdPublic Smart turn. [Private whisper to Bob: SMART_WHISPER_SECRET], and private notes must still stay out of it.scripts/regressions/agent-activation.regression.tsis a source-shape test. Four of its patterns now nameagentCompletedResponseinstead ofcompletedResponse, because post-processing agents get the completed reply with its whispers. Each pattern is as strict as before.Validation
pnpm checkpasses locallyCONTRIBUTING.mdCommands run by the agent on
b66c322, the head (results are not evidence for the boxes above):pnpm check: exit 0.pnpm regression:prompt: passed (3 suites).--filter agents-see-whispers: passed. With the selector's route change reverted, the long-whisper check fails (the line holds only the cut whisper). With the helper change reverted, the helper check fails.--filter roleplay-user-private-generation: passed with the updated assertion.--filter roleplay-: 14/14 passed.--filter smart: 1/1 passed.--filter group: 9/9 passed.--filter decision: 16/16 passed.--filter whisper: 3/3 passed.--filter multiplayer: 13/13 passed.--filter agent: 19/19 passed.--filter retry: 3/3 passed.Earlier heads also ran
advanced-memory(16/16),capability(18/18),illustrator(6/6),tool(9/9),generation-output, and 34 regressions that mentionagentContext,recentMessages,echo-chamber,hiddenContext,resolveGenerationTools,mainResponseSegmentsorcontinueMessageId, one by one: all passed. This round's only code change is the chat-model selector's per-line cap.Manual verification notes
[whisper: character="<name>" text="..."].DEBUG_AGENTS) as[Private whisper to <name>: ...], at its place in the reply.{{input}}only.[whisper: character="Bob" text="..."]. Bob should be a likely pick for the next reply, and a non-recipient's Peek Prompt should not contain the whisper.[decision] ... requestline should show[Private whisper to Bob: ...].DEBUG_AGENTS=truewith an Anthropic agents connection; OpenAI-compatible and Google connections don't log it.[whisper: character="Bob" text="<a long vision>"] Alice, what do you think?: with the chat-model selector, Alice should still be a likely pick.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)Docs changed:
docs/roleplay/getting-started.md,docs/development/multiplayer.md,CHANGELOG.md(no docs change this round). Translation follow-up: #7436 (updated for the rewritten-reply wording; this round's wording is in a comment there).Local CodeRabbit review
Eight runs on the branch before the third round (run 9 is under that round). Fixed:
Rejected, with reasons:
[docs-i18n]follow-up" (repeated): #7436 is open and linked above. The CLI doesn't see the PR body.appendRoleplayWhispersdrops anything. The regression shows the preview taken after the reply still holds a whisper-only turn meant for another character. The preview mirrors the main prompt that prompt-patch agents can edit, and the agents' history is unscoped.agent-activation.regression.tspins post-processing activation topostActivationMessageswithcontent: completedResponse. Changing that is a separate decision for the maintainer. It is not part of what agents read.Run 8, on the second-round fixes (
add3d0b), raised three findings. All are rejected:agent-activation.regression.ts.[docs-i18n]follow-up fordocs/roleplay/getting-started.md": #7436 covers that path and now includes this round's wording.{{input}}always came from the truncated agents' window (agentContext.recentMessages), and an empty value when that window held no user message.responderToolInputkeeps that rule and only removes the whispers. The one difference: with Advanced Memory on, a whisper-only message now takes a slot in that window. A public user message can drop out a turn earlier only when several whisper-only messages follow it inside a small window, so the suggested separate lookup is not worth it.Second review round
Fixed, each with a regression that fails without the fix:
buildCustomToolHiddenContexttookmacros.inputfromagentContext.recentMessages, which now holds whispers. The main reply's tool context now takesresponderInput, the latest user message's public text. Agents' tool calls keep the whisper-aware context.roleplayAgentContinuationnow places only the whispers written with the continuation, at their saved places in the whole message, and cuts off the earlier text.Not changed, with reasons:
prompt-decisions.ts), as well as the sticky and cooldown timers. An answer worked out from whispers for an agent's statement would be reused for a responder's identical statement on a swipe of the same turn, or held by its timer on later turns. That would hand a non-recipient a yes/no taken from a whisper. Doing it safely means separate cache and timer keys for agent statements, which is a follow-up.packages/memory-nag/.../scanner.ts), so its fix belongs there. Its recalls are also put into responder prompts, so storing whispers there would carry them to non-recipients. That needs the maintainer's decision first./encounter/init,/encounter/action). It is not an agent. It runs on the encounter's own connection (the chat's connection by default) and reads raw stored content, without even the hidden-from-AI filter. It saves its summary as a narrator message every character reads. Giving it whispers would be a separate change to the encounter feature. The Illustrator's animation prompt, which reads raw content, is left as is for the same reason.Not changed, for review
buildRoleplayCommandsReminderstill says "No one else will be able to access it, except for the appointed narrator."roleplay.commands.whisper.descriptionstill says "Hide part of a message from everyone but one character (and the narrator)."Third round: Smart speaker selection
generate.routes.ts: the Decision model's smart-order transcript and the chat-model selector's transcript now wrap each message inroleplayAgentText(..., message, agentWhisperNames), before timestamps are stripped, so whispers sit at their places in the text. Hosted rooms still give it none, becauseagentWhisperNamesis null there.roleplay-user-private-generation.regression.tsnow requires the labelled whisper in the selector prompt and still keeps private notes out (see What changed).agents-see-whispers.regression.tscovers both paths, the responder's privacy on that turn, and a hosted room's Smart turn.CHANGELOG.mdanddocs/roleplay/getting-started.mdname Smart response order among the readers, and the changelog says rooms give it none.Local CodeRabbit, run 9 (on
099d62c), raised four findings:9521bf4, "Give the whisper privacy warning its own short sentence" indocs/roleplay/getting-started.mdand "Shorten the changelog entry without losing the warning": the warning that agent output can carry a whisper is now its own sentence in both. The changelog entry keeps its other sentences, because each names a case users will notice (a just-typed whisper, a reply's whispers, a whisper-only message, Smart order, rooms). No rerun after this Markdown-only change.agentCompletedResponse": the same activation point rejected in earlier runs. Keyword activation decides whether an agent runs, reads the stored public text, and is pinned byagent-activation.regression.ts(postActivationMessageswithcontent: completedResponse). That is a separate maintainer decision.filterPromptMessagesForCharacterAudiencedrops only messages the user hid from the responder (hiddenFromAICharacterIds), keeping a stand-in when the hidden message carries a whisper to that responder. It does not drop whisper-only messages meant for others;appendRoleplayWhispersdoes that, after the agents' copy is made. The regression shows the preview taken after Alice's reply still holds the whisper-only turn meant for Bob. A message hidden from the responder is out of the responder's prompt, and so out of the preview that prompt-patch agents edit, as before; agents still read it in their unscoped history.Fourth round: review fixes
Two reviewer findings, both fixed:
[whisper: character="Bob" text="<1,050 characters>"] Alice, what do you think?reached the selector as the cut whisper alone and pushed the pick toward Bob. The turn's text and each whisper now get 900 characters apiece. The Decision model's transcript has no per-message cap and is unchanged. Fixed inb66c322, with a regression that fails without it.chatCompletecall passes nodebugMode, and only some providers log a request body underDEBUG_AGENTS. The manual check now points to the Decision model's logged request, and toDEBUG_AGENTSwith an Anthropic connection for the chat-model selector. The logging gap predates this PR and is left as is.Local CodeRabbit, run 10 (on
b66c322): no findings.UI evidence (if applicable)
Not applicable: no UI change.
🤖 Generated with Claude Code
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.