[PR #7066] [MERGED] fix(conversation): pace autonomous check-ins so group chats don't go silent (#7055) #7454

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7066
Author: @SpicyMarinara
Created: 10/4/2026
Status: ✅ Merged
Merged: 10/4/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/autonomous-messages-7055


📝 Commits (8)

  • 3b87954 fix(conversation): pace Individual group check-ins so the daily limit lasts (#7055)
  • 3d76d54 fix(conversation): rotate shared check-ins and keep long-absence check-ins chat-wide (#7055)
  • 8520bb6 Merge remote-tracking branch 'origin/staging' into fix/autonomous-messages-7055
  • d3e97dd fix(conversation): run Character Exchanges with schedules off (#7055)
  • 66a39bc fix(conversation): rotate server autonomous checks and count only saved messages (#7055)
  • ac01d1d fix(conversation): keep long-absence and handoff pacing on every path (#7055)
  • b6e905b Merge remote-tracking branch 'origin/staging' into fix/autonomous-messages-7055
  • 15347c1 fix(conversation): drop queued autonomous replies that no longer fit the shared limit (#7055)

📊 Changes

10 files changed (+483 additions, -51 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/chats/group-chats.md (+2 -0)
📝 docs/conversation/schedules.md (+2 -0)
📝 packages/server/src/routes/conversation.routes.ts (+49 -13)
📝 packages/server/src/routes/generate.routes.ts (+29 -3)
📝 packages/server/src/services/conversation/autonomous.service.ts (+49 -15)
📝 packages/server/src/services/conversation/server-autonomous-scheduler.service.ts (+41 -19)
➕ scripts/regressions/autonomous-individual-cadence.regression.ts (+211 -0)
📝 scripts/regressions/autonomous-scheduler-gate.regression.ts (+80 -1)
📝 scripts/regressions/group-mention-routing.regression.ts (+18 -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 #7055

Why this change

  • In a Conversation group set to Individual, autonomous messages stopped after the day a chat was created. The group shares one daily check-in limit. Once the user went quiet, every character could check in one after another, so the day's limit was spent within minutes, often right after midnight or after Marinara started. The chat then stayed silent for the rest of the day.
  • With Marinara closed in the browser, a character without a schedule could send the same long-absence check-in on every server poll. The server never recorded that reason's 36-hour cooldown, so the user came back to a burst and then a silent day. This also happened in one-on-one chats with schedules off.
  • @mention handoffs during an autonomous message could spend the rest of the shared limit at once.
  • Character Exchanges never ran with schedules off. The exchange route only looked at characters with a schedule.
  • The server scheduler only ever checked the first two eligible chats, so other conversations with autonomous messages starved.
  • The scheduler counted a generation that saved nothing as sent. It logged "Generated autonomous message" and marked the chat unread.

What changed

  • Shared pacing in Individual groups (autonomous.service.ts, /autonomous/check):
    • After any character checks in, the next check-in waits the doubled follow-up time, as in a one-on-one chat.
    • When a check-in is due, any character whose own wait has passed can send it, and whoever has checked in least today goes first. The chattiest character no longer sends them all.
  • Long-absence check-ins:
    • In a shared-limit group, the cooldown is chat-wide, so one character checks in, not each in turn.
    • The server scheduler now forwards the check's autonomousIntentKey for characters without a schedule, so the cooldown is recorded while Marinara is closed.
  • @mention handoffs: during an autonomous message, handoffs count against the daily limit together with replies already queued. With a shared limit they never take the day's last check-in, the same rule exchanges use.
  • Character Exchanges with schedules off: /autonomous/exchange uses the check route's fallback through a shared helper, withSchedulelessAutonomySchedules. Each character is paced by its card talkativeness. Status overrides, the 30-second quiet rule and the talkativeness roll still apply. In an Individual group, an exchange never takes the day's last check-in.
  • Scheduler fairness:
    • Each poll evaluates enabled chats least recently checked first, with the same cap of 2 evaluations per poll.
    • The tracking map is rebuilt every sweep, so deleted or disabled chats are dropped.
    • The idle-sweep gate (#4705) is unchanged, and its sawEligible is now exact.
  • Only saved messages count: the scheduler treats a generation as sent only when an assistant message_saved event arrives. A response with only done, or a discarded one, releases the claim, is not logged as generated and does not mark the chat unread.
  • Docs and CHANGELOG: docs/conversation/schedules.md, docs/chats/group-chats.md, and one CHANGELOG bullet for #7055.

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

Agent-run validation (not a substitute for the boxes above):

  • pnpm check: passes.
  • Full node regression suite (node ./scripts/run-regressions.mjs): 496 of 497. The one failure, decision-sidecar-runtime ("a model still to download needs the space"), also fails on staging.
  • New and extended regressions (autonomous-individual-cadence, autonomous-scheduler-gate, group-mention-routing): each assertion was confirmed to fail with its fix undone.
  • Fake-clock simulations, reporter's setup (12 characters, talkativeness 0.5, Individual/Smart, exchanges on, schedules off, 2 days, 2 restarts). These used the real scheduler, /autonomous/check and /autonomous/exchange:
    • Before: Ayla sends 5 check-ins at 03:00–03:04. The user writes at 10:00, and the rest of that day is silent.
    • After: one long-absence check-in at 03:00, then check-ins at 11:35, 14:00 and 17:10, with exchanges in between.
  • Other simulations:
    • One-on-one chat with schedules off: 5 in a row before, 1 after.
    • Chatty and mixed-talkativeness groups: hundreds of generations that saved nothing before, none after.
    • Schedules on: unchanged.
  • Live runs (real server, real scheduler and /api/generate, fake LLM):
    • Long absence with Marinara closed: one check-in, with its cooldown recorded.
    • A check-in whose replies keep @mentioning: stops at 4 of 5, leaving the last check-in.
    • An exchange reply that @mentions: the handoff is refused at 4 of 5.
    • Eight chats with Marinara closed: every chat is checked in turn, at most 2 per poll.
    • A chat whose generation saves nothing: not marked unread.

Manual verification notes

  • Manually verify in the browser: an Individual Conversation group with schedules off, autonomous messages on and Character Exchanges on. Go idle and confirm a check-in arrives, may be followed by an exchange, and later check-ins still arrive the same day.
  • Manually verify that with Marinara closed for more than 18 hours, the group or a one-on-one chat sends one long-absence check-in, not a burst, and that the unread badge matches.
  • Manually verify that an autonomous message with an @mention reply in an Individual group leaves at least one check-in for later that day.
  • Manually verify, with several Conversation chats that have autonomous messages on and Marinara closed, that chats other than the two most recent also receive messages.
  • Manually verify that a chat whose characters are all out of today's check-ins is not marked unread.
  • Manually verify Grouped mode and one-on-one chats with schedules on still behave as before.

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)

docs/conversation/schedules.md and docs/chats/group-chats.md changed. Both need mirroring on the docs-i18n branch, or a [docs-i18n] docs/conversation/schedules.md, docs/chats/group-chats.md issue.

Remaining follow-ups (out of scope here)

  • Exchanges count against the limit with schedules on: they still count against the daily limit. A burst can now use everything but the last check-in; whether exchanges should count at all is still open.
  • One check-in can still bring several handoffs: an autonomous message whose replies keep @mentioning can still produce several messages at once (up to the limit minus one). Capping autonomous messages at one handoff would stop that, but it changes how @mention handoffs work, so it needs a decision.
  • Grouped exchanges chain without pacing: in Grouped mode, exchanges chain every few seconds until each character's own limit is reached. This is the same with schedules on and off.
  • Daily limit mismatch: /api/generate uses talkativeness 50 for characters without a schedule (conversation-presence-runtime.ts), while /autonomous/check uses the card's talkativeness. Chatty cards are cut off at 5 a day, and the check keeps approving generations that save nothing. The same default feeds the Smart speaker picker, so the fix needs care.
  • Unread count per generation: one autonomous generation that saves several messages adds one unread on both the server and browser paths.
  • Follow-up counts reset on restart: they are kept in memory only, so a check-in can come right after a restart.

UI evidence (if applicable)

Not applicable. This changes server pacing only.

Summary by CodeRabbit

  • New Features
    • Individual group conversations now share a daily check-in limit and pacing sequence. After one character checks in, the next turn waits; eligible characters take turns, and only one character checks in after a long absence.
    • Character Exchanges work with schedules off. In Individual mode, exchanges and character replies to mentions leave the group’s final daily check-in available.
  • Bug Fixes
    • Conversations are marked unread only when a message is saved, and browser-closed messaging applies across conversations.

🔄 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/7066 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/4/2026 **Status:** ✅ Merged **Merged:** 10/4/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/autonomous-messages-7055` --- ### 📝 Commits (8) - [`3b87954`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3b8795426050d6917517ab5fad16a9b490a77d7e) fix(conversation): pace Individual group check-ins so the daily limit lasts (#7055) - [`3d76d54`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3d76d543d03ae6e99bced2cb4da2c2ecbbad01ed) fix(conversation): rotate shared check-ins and keep long-absence check-ins chat-wide (#7055) - [`8520bb6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8520bb6ba771ca8895d041826901158c7e1610e6) Merge remote-tracking branch 'origin/staging' into fix/autonomous-messages-7055 - [`d3e97dd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d3e97dd6b61a5f587eb6ad3cf44fa53d48f6e958) fix(conversation): run Character Exchanges with schedules off (#7055) - [`66a39bc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/66a39bc73189aeb56639c4994d155df8f328b21b) fix(conversation): rotate server autonomous checks and count only saved messages (#7055) - [`ac01d1d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ac01d1d4ce4dd4ac05293f299550dafd1bcec6d7) fix(conversation): keep long-absence and handoff pacing on every path (#7055) - [`b6e905b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b6e905ba537b71f09a5eb19d12214f6350fc6521) Merge remote-tracking branch 'origin/staging' into fix/autonomous-messages-7055 - [`15347c1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/15347c1b0631187064227adfc8dbf05310398416) fix(conversation): drop queued autonomous replies that no longer fit the shared limit (#7055) ### 📊 Changes **10 files changed** (+483 additions, -51 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/chats/group-chats.md` (+2 -0) 📝 `docs/conversation/schedules.md` (+2 -0) 📝 `packages/server/src/routes/conversation.routes.ts` (+49 -13) 📝 `packages/server/src/routes/generate.routes.ts` (+29 -3) 📝 `packages/server/src/services/conversation/autonomous.service.ts` (+49 -15) 📝 `packages/server/src/services/conversation/server-autonomous-scheduler.service.ts` (+41 -19) ➕ `scripts/regressions/autonomous-individual-cadence.regression.ts` (+211 -0) 📝 `scripts/regressions/autonomous-scheduler-gate.regression.ts` (+80 -1) 📝 `scripts/regressions/group-mention-routing.regression.ts` (+18 -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 #7055 ## Why this change - In a Conversation group set to **Individual**, autonomous messages stopped after the day a chat was created. The group shares one daily check-in limit. Once the user went quiet, every character could check in one after another, so the day's limit was spent within minutes, often right after midnight or after Marinara started. The chat then stayed silent for the rest of the day. - With Marinara closed in the browser, a character without a schedule could send the same long-absence check-in on every server poll. The server never recorded that reason's 36-hour cooldown, so the user came back to a burst and then a silent day. This also happened in one-on-one chats with schedules off. - @mention handoffs during an autonomous message could spend the rest of the shared limit at once. - **Character Exchanges** never ran with schedules off. The exchange route only looked at characters with a schedule. - The server scheduler only ever checked the first two eligible chats, so other conversations with autonomous messages starved. - The scheduler counted a generation that saved nothing as sent. It logged "Generated autonomous message" and marked the chat unread. ## What changed - **Shared pacing in Individual groups** (`autonomous.service.ts`, `/autonomous/check`): - After any character checks in, the next check-in waits the doubled follow-up time, as in a one-on-one chat. - When a check-in is due, any character whose own wait has passed can send it, and whoever has checked in least today goes first. The chattiest character no longer sends them all. - **Long-absence check-ins:** - In a shared-limit group, the cooldown is chat-wide, so one character checks in, not each in turn. - The server scheduler now forwards the check's `autonomousIntentKey` for characters without a schedule, so the cooldown is recorded while Marinara is closed. - **@mention handoffs:** during an autonomous message, handoffs count against the daily limit together with replies already queued. With a shared limit they never take the day's last check-in, the same rule exchanges use. - **Character Exchanges with schedules off:** `/autonomous/exchange` uses the check route's fallback through a shared helper, `withSchedulelessAutonomySchedules`. Each character is paced by its card talkativeness. Status overrides, the 30-second quiet rule and the talkativeness roll still apply. In an Individual group, an exchange never takes the day's last check-in. - **Scheduler fairness:** - Each poll evaluates enabled chats least recently checked first, with the same cap of 2 evaluations per poll. - The tracking map is rebuilt every sweep, so deleted or disabled chats are dropped. - The idle-sweep gate (#4705) is unchanged, and its `sawEligible` is now exact. - **Only saved messages count:** the scheduler treats a generation as sent only when an assistant `message_saved` event arrives. A response with only `done`, or a discarded one, releases the claim, is not logged as generated and does not mark the chat unread. - **Docs and CHANGELOG:** `docs/conversation/schedules.md`, `docs/chats/group-chats.md`, and one CHANGELOG bullet for #7055. ## 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` Agent-run validation (not a substitute for the boxes above): - **`pnpm check`:** passes. - **Full node regression suite** (`node ./scripts/run-regressions.mjs`): 496 of 497. The one failure, `decision-sidecar-runtime` ("a model still to download needs the space"), also fails on `staging`. - **New and extended regressions** (`autonomous-individual-cadence`, `autonomous-scheduler-gate`, `group-mention-routing`): each assertion was confirmed to fail with its fix undone. - **Fake-clock simulations, reporter's setup** (12 characters, talkativeness 0.5, Individual/Smart, exchanges on, schedules off, 2 days, 2 restarts). These used the real scheduler, `/autonomous/check` and `/autonomous/exchange`: - Before: Ayla sends 5 check-ins at 03:00–03:04. The user writes at 10:00, and the rest of that day is silent. - After: one long-absence check-in at 03:00, then check-ins at 11:35, 14:00 and 17:10, with exchanges in between. - **Other simulations:** - One-on-one chat with schedules off: 5 in a row before, 1 after. - Chatty and mixed-talkativeness groups: hundreds of generations that saved nothing before, none after. - Schedules on: unchanged. - **Live runs** (real server, real scheduler and `/api/generate`, fake LLM): - Long absence with Marinara closed: one check-in, with its cooldown recorded. - A check-in whose replies keep @mentioning: stops at 4 of 5, leaving the last check-in. - An exchange reply that @mentions: the handoff is refused at 4 of 5. - Eight chats with Marinara closed: every chat is checked in turn, at most 2 per poll. - A chat whose generation saves nothing: not marked unread. ### Manual verification notes - [ ] Manually verify in the browser: an Individual Conversation group with schedules off, autonomous messages on and Character Exchanges on. Go idle and confirm a check-in arrives, may be followed by an exchange, and later check-ins still arrive the same day. - [ ] Manually verify that with Marinara closed for more than 18 hours, the group or a one-on-one chat sends one long-absence check-in, not a burst, and that the unread badge matches. - [ ] Manually verify that an autonomous message with an @mention reply in an Individual group leaves at least one check-in for later that day. - [ ] Manually verify, with several Conversation chats that have autonomous messages on and Marinara closed, that chats other than the two most recent also receive messages. - [ ] Manually verify that a chat whose characters are all out of today's check-ins is not marked unread. - [ ] Manually verify Grouped mode and one-on-one chats with schedules on still behave as before. ## 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) `docs/conversation/schedules.md` and `docs/chats/group-chats.md` changed. Both need mirroring on the `docs-i18n` branch, or a `[docs-i18n] docs/conversation/schedules.md, docs/chats/group-chats.md` issue. ### Remaining follow-ups (out of scope here) - **Exchanges count against the limit with schedules on:** they still count against the daily limit. A burst can now use everything but the last check-in; whether exchanges should count at all is still open. - **One check-in can still bring several handoffs:** an autonomous message whose replies keep @mentioning can still produce several messages at once (up to the limit minus one). Capping autonomous messages at one handoff would stop that, but it changes how @mention handoffs work, so it needs a decision. - **Grouped exchanges chain without pacing:** in Grouped mode, exchanges chain every few seconds until each character's own limit is reached. This is the same with schedules on and off. - **Daily limit mismatch:** `/api/generate` uses talkativeness 50 for characters without a schedule (`conversation-presence-runtime.ts`), while `/autonomous/check` uses the card's talkativeness. Chatty cards are cut off at 5 a day, and the check keeps approving generations that save nothing. The same default feeds the Smart speaker picker, so the fix needs care. - **Unread count per generation:** one autonomous generation that saves several messages adds one unread on both the server and browser paths. - **Follow-up counts reset on restart:** they are kept in memory only, so a check-in can come right after a restart. ## UI evidence (if applicable) Not applicable. This changes server pacing only. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Individual group conversations now share a daily check-in limit and pacing sequence. After one character checks in, the next turn waits; eligible characters take turns, and only one character checks in after a long absence. * Character Exchanges work with schedules off. In Individual mode, exchanges and character replies to mentions leave the group’s final daily check-in available. * **Bug Fixes** * Conversations are marked unread only when a message is saved, and browser-closed messaging applies across conversations. <!-- 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:57 +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#7454
No description provided.