[GH-ISSUE #182] [Issue]: Autonomous messages not triggering #65

Closed
opened 2026-10-20 17:24:42 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @shinishiho on GitHub (Apr 22, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/182

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Hi there, I am not receiving any autonomous messages. I think there are two issues:

  1. The client/UI sends an API call to resets the timer on message history loading (explained below).
  2. The server/backend doesn't have any mechanism to trigger autonomous messages. I don't know whether this is intentional. Which means, (after the 1st mentioned bug is fixed), whenever I open the UI, my characters will start messaging me one after another, not while I am offline.

Edit: If I just keep the UI open, the characters will send messages.

(I removed some sections in the issue template that I think is unnecessary. Sorry if that causes some issues.)

Expected behavior

I think autonomous messages should be sent even when I'm offline (not using the UI).

Actual behavior

When the chat UI loads (or page refreshes), while loading messages in a chat, it also sends an API call to /conversation/activity/assistant (usually the AI's message is the latest), even though there is no new messages.
That resets the inactivity timer, I believe.
(This is observed in Network tab in browser's Inspect window)

Environment

  • Marinara Engine version: 1.5.4
  • Install type: docker
  • OS + version:
  • Browser or app shell:

Additional context

Copilot's explanation is: when the messages are being loaded, it starts with zero count.
Then the messages history arrives, which updates the count to something greater than zero, and that triggers the check in useEffect().
I replaced this section in packages/client/src/components/chat/ConversationAutonomousEffects.tsx and it seems to fix the issue.

  const prevMsgCountRef = useRef(messages?.length ?? 0);

  useEffect(() => {
    if (!messages) return;
    const count = messages.length;
    if (count > prevMsgCountRef.current) {
      const newest = messages[count - 1];
      if (newest?.role === "user") {
        recordUserActivity();
      } else if (newest?.role === "assistant") {
        recordAssistantActivity(newest.characterId ?? undefined);
      }
    }
    prevMsgCountRef.current = count;
  }, [messages, recordAssistantActivity, recordUserActivity]);

is replaced with

  // Init as undefined
  const prevMsgCountRef = useRef<number | undefined>(undefined);

  useEffect(() => {
    if (!messages) return;
    const count = messages.length;
    
    // Update when 'undefined', message history loaded
    if (prevMsgCountRef.current === undefined) {
      prevMsgCountRef.current = count;
      return;
    }

    // Real new messages
    if (count > prevMsgCountRef.current) {
      const newest = messages[count - 1];
      if (newest?.role === "user") {
        recordUserActivity();
      } else if (newest?.role === "assistant") {
        recordAssistantActivity(newest.characterId ?? undefined);
      }
    }
    prevMsgCountRef.current = count;
  }, [messages, recordAssistantActivity, recordUserActivity]);

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @shinishiho on GitHub (Apr 22, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/182 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Hi there, I am not receiving any autonomous messages. I think there are two issues: 1. The client/UI sends an API call to resets the timer on message history loading (explained below). 2. The server/backend doesn't have any mechanism to trigger autonomous messages. I don't know whether this is intentional. Which means, (after the 1st mentioned bug is fixed), whenever I open the UI, my characters will start messaging me one after another, not while I am offline. Edit: If I just keep the UI open, the characters will send messages. (I removed some sections in the issue template that I think is unnecessary. Sorry if that causes some issues.) ## Expected behavior I think autonomous messages should be sent even when I'm offline (not using the UI). ## Actual behavior When the chat UI loads (or page refreshes), while loading messages in a chat, it also sends an API call to `/conversation/activity/assistant` (usually the AI's message is the latest), even though there is no new messages. That resets the inactivity timer, I believe. (This is observed in Network tab in browser's Inspect window) ## Environment - Marinara Engine version: 1.5.4 - Install type: docker - OS + version: - Browser or app shell: ## Additional context Copilot's explanation is: when the messages are being loaded, it starts with zero count. Then the messages history arrives, which updates the count to something greater than zero, and that triggers the check in `useEffect()`. I replaced this section in `packages/client/src/components/chat/ConversationAutonomousEffects.tsx` and it seems to fix the issue. ```typescript const prevMsgCountRef = useRef(messages?.length ?? 0); useEffect(() => { if (!messages) return; const count = messages.length; if (count > prevMsgCountRef.current) { const newest = messages[count - 1]; if (newest?.role === "user") { recordUserActivity(); } else if (newest?.role === "assistant") { recordAssistantActivity(newest.characterId ?? undefined); } } prevMsgCountRef.current = count; }, [messages, recordAssistantActivity, recordUserActivity]); ``` is replaced with ```typescript // Init as undefined const prevMsgCountRef = useRef<number | undefined>(undefined); useEffect(() => { if (!messages) return; const count = messages.length; // Update when 'undefined', message history loaded if (prevMsgCountRef.current === undefined) { prevMsgCountRef.current = count; return; } // Real new messages if (count > prevMsgCountRef.current) { const newest = messages[count - 1]; if (newest?.role === "user") { recordUserActivity(); } else if (newest?.role === "assistant") { recordAssistantActivity(newest.characterId ?? undefined); } } prevMsgCountRef.current = count; }, [messages, recordAssistantActivity, recordUserActivity]); ``` ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:24:42 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@SpicyMarinara commented on GitHub (Apr 23, 2026):

Autonomous messages will only be sent to you if you're online. They cannot be sent to you when you're offline, when you're offline since tha tmeans your frontend is off, but I'll look into the other issue.

<!-- gh-comment-id:4303107423 --> @SpicyMarinara commented on GitHub (Apr 23, 2026): Autonomous messages will only be sent to you if you're online. They cannot be sent to you when you're offline, when you're offline since tha tmeans your frontend is off, but I'll look into the other issue.
Author
Owner

@SpicyMarinara commented on GitHub (Apr 23, 2026):

Fixed in v1.5.5.

<!-- gh-comment-id:4304528525 --> @SpicyMarinara commented on GitHub (Apr 23, 2026): Fixed in v1.5.5.
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#65
No description provided.