[GH-ISSUE #3106] [Issue]: conversation-summary / autonomous generation retries permanent failures (e.g. Gemini 404) every tick forever — no backoff, unbounded log spam #1666

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

Originally created by @kolacheee on GitHub (Jun 30, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3106

Originally assigned to: @SpicyMarinara on GitHub.

What's wrong

When the conversation-summary "day summary" generation fails with a permanent error (e.g. a 4xx like Gemini API error 404: Not Found because a connection's model id is stale/invalid), the failure is only logged — it is never recorded — so the same missing day stays "missing" and is re-attempted on every generation tick, forever. For a chat with autonomous messaging and/or summaries enabled on a misconfigured connection, this produces an unbounded stream of identical warnings (and wasted upstream API calls) every ~30–60s for as long as the chat exists. There is no backoff, no max-attempt cap, and no distinction between transient and permanent failures. The server-side autonomous scheduler exhibits the same no-backoff pattern (it re-attempts the failing generation every poll).

This is log spam + pointless network traffic, not a crash — but on a long-lived install it floods the logs and hammers a dead endpoint indefinitely.

How to reproduce (try it yourself)

  1. Create/keep a chat with conversation summaries (and/or autonomous messaging) enabled.
  2. Point its connection at a model that returns a hard 4xx — easiest is a Gemini connection with a retired/typo'd model id (Google retires Gemini model names regularly), which returns 404 Not Found.
  3. Leave the chat idle and watch the server console.

You'll see, repeating every ~30–60s indefinitely:

{"level":40,...,"chatId":"...","date":"...","err":"Gemini API error 404: Not Found","msg":"[conversation-summary] failed to generate day summary"}

(and, from the scheduler, [autonomous-scheduler] Generate failed for chat <id>: Gemini API error 404).

Expected: after a few consecutive hard failures for a given day (especially permanent 4xx), the engine should stop re-attempting that day-summary (and/or back off), instead of retrying it on every tick forever.

Where it is

packages/server/src/routes/generate.routes.ts:

  • :2685 — const summaryRun = await generateMissingConversationSummaries({ ..., maxMissingDays: 2 }). "Missing" days are days without a stored summary.
  • :2697-2701 — failed days are only logger.warn'd ("[conversation-summary] failed to generate day summary"); :2703-2707 same for failed weeks.
  • :~2708-2712 — metadata is patched only if (hasNewSummaries) (i.e. only on success), so a failed day is never recorded as attempted/failed → it remains "missing" → re-attempted on the next generation.

packages/server/src/services/conversation/server-autonomous-scheduler.service.ts:

  • SERVER_AUTONOMOUS_POLL_MS = 60_000 (:18) — the scheduler re-evaluates eligible chats every 60s.
  • :149, :160 — generation failures are logged and the chat is simply re-evaluated next poll; no per-chat backoff/cooldown after repeated hard failures.

What's happening

The summary generator treats "no summary stored for this day" as "still needs generating," but a failed attempt writes nothing, so a permanently-failing day (dead model, revoked key, removed endpoint) is indistinguishable from a never-attempted day and is retried every tick. A 404/401/403 will not self-heal, yet the code retries it identically to a transient network blip.

Suggested fix

Record failed attempts and stop hammering permanent failures. Options (any combination):

  1. In generateMissingConversationSummaries, persist a small failedDaySummaries / failedWeekSummaries record in chat metadata (date → { lastAttempt, attempts, lastError }) and skip re-attempting a day whose last failure was recent / whose attempt count exceeds a cap — with a longer cooldown (or permanent skip until the connection changes) for hard 4xx errors. Clear the record when the connection/model changes or on a successful run.
  2. Add exponential backoff per (chat, day) so retries slow down instead of firing every tick.
  3. In server-autonomous-scheduler.service.ts, apply a per-chat cooldown after N consecutive hard failures so autonomous evaluation pauses for that chat instead of retrying every 60s.

Distinguish transient (5xx/network → retry with backoff) from permanent (4xx → stop and surface once) so a misconfigured connection produces one clear warning, not an endless stream.

Note: observed live on a maintainer dev install — a chat with autonomous messaging + summaries enabled on a Gemini connection whose model 404s logged this warning continuously every ~30s. It is distinct from the tracker-panel freeze and the regex-script ReDoS reports.


AI-investigated against v2.0.8 (main); cited lines read and confirmed. Please verify before fixing.

Originally created by @kolacheee on GitHub (Jun 30, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3106 Originally assigned to: @SpicyMarinara on GitHub. **What's wrong** When the conversation-summary "day summary" generation fails with a **permanent error** (e.g. a `4xx` like `Gemini API error 404: Not Found` because a connection's model id is stale/invalid), the failure is only logged — it is **never recorded** — so the same missing day stays "missing" and is **re-attempted on every generation tick, forever**. For a chat with autonomous messaging and/or summaries enabled on a misconfigured connection, this produces an unbounded stream of identical warnings (and wasted upstream API calls) every ~30–60s for as long as the chat exists. There is no backoff, no max-attempt cap, and no distinction between transient and permanent failures. The server-side autonomous scheduler exhibits the same no-backoff pattern (it re-attempts the failing generation every poll). This is log spam + pointless network traffic, not a crash — but on a long-lived install it floods the logs and hammers a dead endpoint indefinitely. **How to reproduce (try it yourself)** 1. Create/keep a chat with **conversation summaries** (and/or **autonomous messaging**) enabled. 2. Point its connection at a model that returns a hard 4xx — easiest is a **Gemini connection with a retired/typo'd model id** (Google retires Gemini model names regularly), which returns `404 Not Found`. 3. Leave the chat idle and watch the server console. You'll see, repeating every ~30–60s indefinitely: ``` {"level":40,...,"chatId":"...","date":"...","err":"Gemini API error 404: Not Found","msg":"[conversation-summary] failed to generate day summary"} ``` (and, from the scheduler, `[autonomous-scheduler] Generate failed for chat <id>: Gemini API error 404`). Expected: after a few consecutive **hard** failures for a given day (especially permanent 4xx), the engine should stop re-attempting that day-summary (and/or back off), instead of retrying it on every tick forever. **Where it is** `packages/server/src/routes/generate.routes.ts`: - `:2685` — `const summaryRun = await generateMissingConversationSummaries({ ..., maxMissingDays: 2 })`. "Missing" days are days without a stored summary. - `:2697-2701` — failed days are only `logger.warn`'d (`"[conversation-summary] failed to generate day summary"`); `:2703-2707` same for failed weeks. - `:~2708-2712` — metadata is patched **only** `if (hasNewSummaries)` (i.e. only on success), so a failed day is never recorded as attempted/failed → it remains "missing" → re-attempted on the next generation. `packages/server/src/services/conversation/server-autonomous-scheduler.service.ts`: - `SERVER_AUTONOMOUS_POLL_MS = 60_000` (`:18`) — the scheduler re-evaluates eligible chats every 60s. - `:149`, `:160` — generation failures are logged and the chat is simply re-evaluated next poll; no per-chat backoff/cooldown after repeated hard failures. **What's happening** The summary generator treats "no summary stored for this day" as "still needs generating," but a failed attempt writes nothing, so a permanently-failing day (dead model, revoked key, removed endpoint) is indistinguishable from a never-attempted day and is retried every tick. A `404`/`401`/`403` will not self-heal, yet the code retries it identically to a transient network blip. **Suggested fix** Record failed attempts and stop hammering permanent failures. Options (any combination): 1. In `generateMissingConversationSummaries`, persist a small `failedDaySummaries` / `failedWeekSummaries` record in chat metadata (date → `{ lastAttempt, attempts, lastError }`) and **skip** re-attempting a day whose last failure was recent / whose attempt count exceeds a cap — with a longer cooldown (or permanent skip until the connection changes) for hard `4xx` errors. Clear the record when the connection/model changes or on a successful run. 2. Add exponential backoff per (chat, day) so retries slow down instead of firing every tick. 3. In `server-autonomous-scheduler.service.ts`, apply a per-chat cooldown after N consecutive hard failures so autonomous evaluation pauses for that chat instead of retrying every 60s. Distinguish transient (5xx/network → retry with backoff) from permanent (4xx → stop and surface once) so a misconfigured connection produces one clear warning, not an endless stream. Note: observed live on a maintainer dev install — a chat with autonomous messaging + summaries enabled on a Gemini connection whose model 404s logged this warning continuously every ~30s. It is distinct from the tracker-panel freeze and the regex-script ReDoS reports. --- *AI-investigated against v2.0.8 (`main`); cited lines read and confirmed. Please verify before fixing.*
bsakaguchi 2026-10-21 05:41:31 +07:00
  • closed this issue
  • added the
    in-pr
    label
Author
Owner

@SpicyMarinara commented on GitHub (Jun 30, 2026):

Taking this in branch codex/issue-sweep-3098-3105; I’ll add bounded failure tracking/backoff for conversation summaries and autonomous scheduler retries, then close it after the fix lands.

<!-- gh-comment-id:4845395182 --> @SpicyMarinara commented on GitHub (Jun 30, 2026): Taking this in branch `codex/issue-sweep-3098-3105`; I’ll add bounded failure tracking/backoff for conversation summaries and autonomous scheduler retries, then close it after the fix lands.
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#1666
No description provided.