[GH-ISSUE #3299] [Issue]: Autonomous messages in merged (default) group conversations count against the first character, so per-character caps never bind #1787

Closed
opened 2026-10-21 05:42:41 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Magiwarriorx on GitHub (Jul 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3299

Originally assigned to: @SpicyMarinara on GitHub.

Summary

In a merged-mode group Conversation (the default), every autonomous message is saved and
counted against characterIds[0] regardless of which character the poller selected. The
per-character follow-up cap and daily budget are keyed to the selected character, whose
counter never moves — so neither cap binds. With schedules disabled (no offline gate),
autonomous messaging becomes unbounded.

Expected behavior

The poller selects one character X per trigger; the follow-up cap (stop after 2–3 until the
user replies) and the daily budget (5–8/day) then throttle X. The message and both counters
should be attributed to X.

Actual behavior

Here "attribution" means both (a) the saved message's characterId and (b) the
follow-up/budget counters — both go to characterIds[0], not X. The visible dialogue is still
voiced as X (the prompt is scoped to X, and merged <speaker> tags label the lines), so this is
a bookkeeping bug, not a wrong-speaker-in-chat bug.

Merged generation hardcodes the responder to characterIds[0] (packages/server/src/routes/generate.routes.ts:7927);
input.forCharacterId (the selected X) scopes only the prompt (:2502), never the save (:7627)
or the counters (:7636-7637). So every character other than [0] never accumulates a count: its
follow-up count and budget stay 0, so it stays eligible and is never capped
(services/conversation/autonomous.service.ts:356,360; the budget check reads the selected char at
routes/conversation.routes.ts:161 and generate.routes.ts:2925). [0] absorbs the counts and does
get capped, but the priority sort ranks un-throttled characters above it (autonomous.service.ts:376
vs :391), so the poller keeps picking a fresh one and the chat never falls silent.

Steps to reproduce

  1. Group Conversation, ≥2 characters, default response order (resolves to merged — generate.routes.ts:5058-5063).
  2. Enable autonomous messaging; configure no schedules.
  3. Leave the chat idle past the inactivity threshold.
  4. Autonomous messages keep firing with neither cap stopping them; each is stored against the
    first character in the group.

Environment

  • Marinara Engine version: 2.1.0
  • Install type: source
  • OS + version: N/A — source review at staging @ 4499d4e3
  • Browser or app shell: N/A

Logs, screenshots, or video

None.

Additional context

  • Merged is the default for Conversation groups (generate.routes.ts:5058-5063). Manual order uses
    the individual loop, which honors forCharacterId (:6725-6727); DMs are unaffected ([0] is the
    selected character).
  • Predates recent schedule work — git blame puts :7927 at 881aff26 (2026-05-17).
  • Suggested fix: seed targetCharId from forCharacterId in the merged branch, falling back to [0]:
    let targetCharId =
      (typeof input.forCharacterId === "string" && characterIds.includes(input.forCharacterId)
        ? input.forCharacterId
        : characterIds[0]) ?? null;
    
    The @mention and regen paths reassign targetCharId after this line, so they are unaffected.
    Not verified against a running server.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Magiwarriorx on GitHub (Jul 6, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3299 Originally assigned to: @SpicyMarinara on GitHub. ## Summary In a merged-mode group Conversation (the default), every autonomous message is saved and counted against `characterIds[0]` regardless of which character the poller selected. The per-character follow-up cap and daily budget are keyed to the selected character, whose counter never moves — so neither cap binds. With schedules disabled (no offline gate), autonomous messaging becomes unbounded. ## Expected behavior The poller selects one character X per trigger; the follow-up cap (stop after 2–3 until the user replies) and the daily budget (5–8/day) then throttle X. The message and both counters should be attributed to X. ## Actual behavior Here "attribution" means **both** (a) the saved message's `characterId` and (b) the follow-up/budget counters — both go to `characterIds[0]`, not X. The visible dialogue is still voiced as X (the prompt is scoped to X, and merged `<speaker>` tags label the lines), so this is a bookkeeping bug, not a wrong-speaker-in-chat bug. Merged generation hardcodes the responder to `characterIds[0]` (`packages/server/src/routes/generate.routes.ts:7927`); `input.forCharacterId` (the selected X) scopes only the prompt (`:2502`), never the save (`:7627`) or the counters (`:7636-7637`). So every character other than `[0]` never accumulates a count: its follow-up count and budget stay 0, so it stays eligible and is never capped (`services/conversation/autonomous.service.ts:356,360`; the budget check reads the selected char at `routes/conversation.routes.ts:161` and `generate.routes.ts:2925`). `[0]` absorbs the counts and does get capped, but the priority sort ranks un-throttled characters above it (`autonomous.service.ts:376` vs `:391`), so the poller keeps picking a fresh one and the chat never falls silent. ## Steps to reproduce 1. Group Conversation, ≥2 characters, default response order (resolves to merged — `generate.routes.ts:5058-5063`). 2. Enable autonomous messaging; configure no schedules. 3. Leave the chat idle past the inactivity threshold. 4. Autonomous messages keep firing with neither cap stopping them; each is stored against the first character in the group. ## Environment - Marinara Engine version: 2.1.0 - Install type: source - OS + version: N/A — source review at `staging` @ `4499d4e3` - Browser or app shell: N/A ## Logs, screenshots, or video None. ## Additional context - Merged is the default for Conversation groups (`generate.routes.ts:5058-5063`). Manual order uses the individual loop, which honors `forCharacterId` (`:6725-6727`); DMs are unaffected (`[0]` is the selected character). - Predates recent schedule work — `git blame` puts `:7927` at `881aff26` (2026-05-17). - Suggested fix: seed `targetCharId` from `forCharacterId` in the merged branch, falling back to `[0]`: ```ts let targetCharId = (typeof input.forCharacterId === "string" && characterIds.includes(input.forCharacterId) ? input.forCharacterId : characterIds[0]) ?? null; ``` The @mention and regen paths reassign `targetCharId` after this line, so they are unaffected. Not verified against a running server. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:42:41 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Jul 6, 2026):

Fixed in staging via #3305.

<!-- gh-comment-id:4891619970 --> @SpicyMarinara commented on GitHub (Jul 6, 2026): Fixed in staging via #3305.
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#1787
No description provided.