[PR #432] [MERGED] fix: persist Narrative Director runs so run interval gating works #4619

Closed
opened 2026-10-22 04:09:13 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/432
Author: @Xelvanis
Created: 5/5/2026
Status: ✅ Merged
Merged: 5/5/2026
Merged by: @SpicyMarinara

Base: main ← Head: fix/narrative-director-run-interval


📝 Commits (1)

  • 1bdb4e3 fix(server): persist Narrative Director runs so run interval gating works

📊 Changes

1 file changed (+34 additions, -4 deletions)

View changed files

📝 packages/server/src/routes/generate.routes.ts (+34 -4)

📄 Description

Linked issue

https://discord.com/channels/1417099416812392641/1499815860733477016

Closes #

Why this change

  • Fixes Narrative Director run interval gating so the agent does not keep running every generation after its first successful run.
  • The interval check already looked for the director’s last successful agent_runs row, but pre-generation director runs were not being persisted, so there was no saved message anchor to count from.

What changed

  • Parses the Narrative Director runInterval setting more defensively before applying interval gating.
  • Persists successful Narrative Director pre-generation runs after the assistant message is saved.
  • Anchors the saved director run to the generated assistant message ID so future turns can count assistant messages since the last director run.
  • Logs a warning if persisting the director run fails, without failing the whole generation.

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

Manual verification notes

  • Ran pnpm check locally. It passed, including impeccable:check, lint, and build.
  • Started new chat with Narrative Director agent activated.
  • Verified successful Narrative Director output.
  • Exchanged messages, checking to ensure no farther output.
  • Confirmed next Narrative Director output only generated at the correct interval.
  • Confirmed Narrative Director runs every turn when interval is set to 1.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

Summary by CodeRabbit

Release Notes

Bug Fixes

  • Improved interval setting validation with automatic fallback to defaults when invalid values are provided
  • Fixed data persistence issue for pre-execution operations that were previously not being recorded

🔄 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/432 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/5/2026 **Status:** ✅ Merged **Merged:** 5/5/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `main` ← **Head:** `fix/narrative-director-run-interval` --- ### 📝 Commits (1) - [`1bdb4e3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1bdb4e3e92f3322f149d924fcfa73cce4e845659) fix(server): persist Narrative Director runs so run interval gating works ### 📊 Changes **1 file changed** (+34 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/generate.routes.ts` (+34 -4) </details> ### 📄 Description ## Linked issue https://discord.com/channels/1417099416812392641/1499815860733477016 Closes # ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Fixes Narrative Director run interval gating so the agent does not keep running every generation after its first successful run. - The interval check already looked for the director’s last successful `agent_runs` row, but pre-generation director runs were not being persisted, so there was no saved message anchor to count from. ## What changed <!-- List the key changes in this PR --> - Parses the Narrative Director `runInterval` setting more defensively before applying interval gating. - Persists successful Narrative Director pre-generation runs after the assistant message is saved. - Anchors the saved director run to the generated assistant message ID so future turns can count assistant messages since the last director run. - Logs a warning if persisting the director run fails, without failing the whole generation. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [X] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [X] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [X] Above manual verification completed (describe below) - [X] Read and followed `CONTRIBUTING.md` ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> - Ran `pnpm check` locally. It passed, including `impeccable:check`, lint, and build. - Started new chat with Narrative Director agent activated. - Verified successful Narrative Director output. - Exchanged messages, checking to ensure no farther output. - Confirmed next Narrative Director output only generated at the correct interval. - Confirmed Narrative Director runs every turn when interval is set to 1. ## Docs and release impact - [X] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes **Bug Fixes** - Improved interval setting validation with automatic fallback to defaults when invalid values are provided - Fixed data persistence issue for pre-execution operations that were previously not being recorded <!-- 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-22 04:09:13 +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#4619
No description provided.