[PR #6907] [MERGED] fix(agents): attribute group speakers in agent history and keep mobile Echo pinned #7376

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6907
Author: @SpicyMarinara
Created: 9/30/2026
Status: ✅ Merged
Merged: 9/30/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/echo-chamber-attribution-mobile-scroll


📝 Commits (4)

  • 3252442 fix(agents): attribute group speakers in agent history and keep mobile Echo pinned
  • a4bb6d4 fix(agents): strip agent history markup to a fixed point
  • 653077d test(e2e): reproduce Echo reactions revealed while the mobile composer hides it
  • 12c8809 Merge branch 'staging' into fix/echo-chamber-attribution-mobile-scroll

📊 Changes

9 files changed (+831 additions, -643 deletions)

View changed files

📝 CHANGELOG.md (+3 -0)
📝 e2e/core-flows.e2e.ts (+700 -610)
📝 packages/client/src/styles/globals.css (+10 -2)
📝 packages/server/src/routes/generate.routes.ts (+18 -0)
📝 packages/server/src/routes/generate/generate-route-utils.ts (+29 -21)
📝 packages/server/src/services/agents/agent-executor.ts (+16 -6)
📝 packages/shared/src/types/agent.ts (+2 -0)
📝 scripts/regressions/agent-runtime.regression.ts (+47 -3)
📝 scripts/regressions/open-issues.regression.ts (+6 -1)

📄 Description

Fixes #6906

Why

Echo Chamber reactions in group chats often say one character said a line that another character actually said. Agent history reached the model without speaker names:

  • buildAgentMessages sent each message's text on its own and merged consecutive same-role turns. In individual group mode, Alice's and Bob's turns became one unlabeled assistant block.
  • In merged mode, the only record of who said each line is the <speaker="Name"> tags, and the agent history stripper removed them.

On mobile, Echo sometimes showed an empty box until you scrolled up inside it. Focusing the composer or editing a message hid agent windows with display: none. Echo keeps revealing reactions while hidden, but a hidden box has no scroll height, so auto-scroll did nothing. When the panel came back, the browser restored the old scroll offset instead of showing the newest reaction. A WebKit + Chromium probe reproduced this: the offset stayed at 226 after the scroll height grew to 306.

What changed

  • Individual group turns get a speaker name. The generate route adds a resolved speakerName to agent recentMessages, using the same resolver as the main prompt's group speaker prefixes. The resolver was extracted as resolveGroupIndividualHistorySpeaker, so both paths label speakers the same way. Agent history then prefixes Name: and never doubles an existing prefix.
  • Merged mode isn't labeled by characterId. Merged replies are saved under the first character (characterIds[0]), so labeling by ID would create misattribution. Agent history instead keeps <speaker> tags and still strips other markup.
  • Mobile Echo stays laid out while hidden. While the composer is active or a message is being edited, the Echo window now uses visibility: hidden, so its scroll box keeps working. Other agent windows keep display: none, because some of them sit in the page flow and would otherwise leave gaps.
  • Regressions:
    • agent-runtime now checks labeled group history, that an existing prefix isn't doubled, and that <speaker> tags survive while other markup is stripped. This check fails without the fix.
    • The pinned CSS assertion in open-issues was updated.
    • The mobile composer e2e now asserts that Echo keeps its layout box while hidden.
    • A new mobile e2e reveals reactions while the composer hides Echo, then requires the newest one to be in view. It fails on staging in mobile Chromium and WebKit and passes with the fix.
    • agent-runtime also covers nested markup such as <scr<b>ipt>, which history now strips to a fixed point (CodeQL).

This change is Engine-owned: it touches agent context and history formatting plus Engine UI CSS. The Echo Chamber package in Marinara-Agents is unchanged.

Manual verification

  • In an individual-mode group Roleplay chat with Echo Chamber on, send a message after two characters reply. Confirm the reactions name the right speaker for each line.
  • In a merged-mode group chat with speaker colors on, confirm the reactions credit lines to the right characters.
  • On a phone, with a slow Echo message delay, start typing while reactions are being revealed, then send or dismiss the keyboard. Confirm Echo shows its newest reaction, not an empty box.
  • On a phone, edit a message while Echo reactions arrive, then save. Confirm Echo is pinned to the newest reaction.

Summary by CodeRabbit

  • Bug Fixes
    • Group conversation turns and merged replies now identify their speakers, helping ensure reactions are attributed to the correct character.
    • On mobile, the latest Echo Chamber reaction stays in view after typing or editing.
    • During mobile composition or message editing, the Echo Chamber remains invisible while retaining its layout space; other agent windows are hidden.

🔄 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/6907 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/30/2026 **Status:** ✅ Merged **Merged:** 9/30/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/echo-chamber-attribution-mobile-scroll` --- ### 📝 Commits (4) - [`3252442`](https://github.com/Pasta-Devs/Marinara-Engine/commit/32524426d764ec6ae09244b6f058d1caae6b31b9) fix(agents): attribute group speakers in agent history and keep mobile Echo pinned - [`a4bb6d4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a4bb6d4dbe42983a139cc3c040ac3ae9278e53b4) fix(agents): strip agent history markup to a fixed point - [`653077d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/653077dfeca29b1cc8d37904928368daef9971ca) test(e2e): reproduce Echo reactions revealed while the mobile composer hides it - [`12c8809`](https://github.com/Pasta-Devs/Marinara-Engine/commit/12c8809a9de4824845a056b5f75d625e399935b8) Merge branch 'staging' into fix/echo-chamber-attribution-mobile-scroll ### 📊 Changes **9 files changed** (+831 additions, -643 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -0) 📝 `e2e/core-flows.e2e.ts` (+700 -610) 📝 `packages/client/src/styles/globals.css` (+10 -2) 📝 `packages/server/src/routes/generate.routes.ts` (+18 -0) 📝 `packages/server/src/routes/generate/generate-route-utils.ts` (+29 -21) 📝 `packages/server/src/services/agents/agent-executor.ts` (+16 -6) 📝 `packages/shared/src/types/agent.ts` (+2 -0) 📝 `scripts/regressions/agent-runtime.regression.ts` (+47 -3) 📝 `scripts/regressions/open-issues.regression.ts` (+6 -1) </details> ### 📄 Description Fixes #6906 ## Why Echo Chamber reactions in group chats often say one character said a line that another character actually said. Agent history reached the model without speaker names: - `buildAgentMessages` sent each message's text on its own and merged consecutive same-role turns. In individual group mode, Alice's and Bob's turns became one unlabeled assistant block. - In merged mode, the only record of who said each line is the `<speaker="Name">` tags, and the agent history stripper removed them. On mobile, Echo sometimes showed an empty box until you scrolled up inside it. Focusing the composer or editing a message hid agent windows with `display: none`. Echo keeps revealing reactions while hidden, but a hidden box has no scroll height, so auto-scroll did nothing. When the panel came back, the browser restored the old scroll offset instead of showing the newest reaction. A WebKit + Chromium probe reproduced this: the offset stayed at 226 after the scroll height grew to 306. ## What changed - **Individual group turns get a speaker name.** The generate route adds a resolved `speakerName` to agent `recentMessages`, using the same resolver as the main prompt's group speaker prefixes. The resolver was extracted as `resolveGroupIndividualHistorySpeaker`, so both paths label speakers the same way. Agent history then prefixes `Name:` and never doubles an existing prefix. - **Merged mode isn't labeled by `characterId`.** Merged replies are saved under the first character (`characterIds[0]`), so labeling by ID would create misattribution. Agent history instead keeps `<speaker>` tags and still strips other markup. - **Mobile Echo stays laid out while hidden.** While the composer is active or a message is being edited, the Echo window now uses `visibility: hidden`, so its scroll box keeps working. Other agent windows keep `display: none`, because some of them sit in the page flow and would otherwise leave gaps. - **Regressions:** - `agent-runtime` now checks labeled group history, that an existing prefix isn't doubled, and that `<speaker>` tags survive while other markup is stripped. This check fails without the fix. - The pinned CSS assertion in `open-issues` was updated. - The mobile composer e2e now asserts that Echo keeps its layout box while hidden. - A new mobile e2e reveals reactions while the composer hides Echo, then requires the newest one to be in view. It fails on staging in mobile Chromium and WebKit and passes with the fix. - `agent-runtime` also covers nested markup such as `<scr<b>ipt>`, which history now strips to a fixed point (CodeQL). This change is Engine-owned: it touches agent context and history formatting plus Engine UI CSS. The Echo Chamber package in Marinara-Agents is unchanged. ## Manual verification - [ ] In an individual-mode group Roleplay chat with Echo Chamber on, send a message after two characters reply. Confirm the reactions name the right speaker for each line. - [ ] In a merged-mode group chat with speaker colors on, confirm the reactions credit lines to the right characters. - [ ] On a phone, with a slow Echo message delay, start typing while reactions are being revealed, then send or dismiss the keyboard. Confirm Echo shows its newest reaction, not an empty box. - [ ] On a phone, edit a message while Echo reactions arrive, then save. Confirm Echo is pinned to the newest reaction. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Group conversation turns and merged replies now identify their speakers, helping ensure reactions are attributed to the correct character. * On mobile, the latest Echo Chamber reaction stays in view after typing or editing. * During mobile composition or message editing, the Echo Chamber remains invisible while retaining its layout space; other agent windows are hidden. <!-- 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:19:10 +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#7376
No description provided.