[GH-ISSUE #2198] [Issue]: Lorebook Maker drops parse-retry recovery for malformed batches #1100

Closed
opened 2026-10-21 05:26:39 +07:00 by bsakaguchi · 0 comments
Owner

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

Summary

Parityscan row 07-LB-API-lorebook-maker found that the refactor Lorebook Maker no longer retries a batch when the model output cannot be parsed into valid lorebook entries. Legacy retried one malformed or empty batch before continuing, which made the maker more resilient to transient JSON formatting failures.

Expected behavior

When Lorebook Maker generates a batch that cannot be parsed into entries, it should retry that batch once before accepting a partial/empty batch result or reporting failure.

Actual behavior

The refactor engine generator parses each batch once with parseGameJsonish. If the parsed batch has no valid entries, it emits a batch_warning and continues to the next batch. There is no retry loop for the failed batch, so a transient malformed response can silently reduce the generated entry count.

Legacy main handled the same route with a two-attempt loop: after an empty parse on the first attempt, it emitted a warning, added a retry separator to the stream, and retried the same batch once.

Steps to reproduce

  1. On refactor, open Lorebook Maker and request enough entries to generate at least one batch.
  2. Use a connection/model response that returns malformed JSON or JSON without an entries array for a batch.
  3. Observe that the batch reports a warning and generation continues without retrying the batch.
  4. Compare against legacy main, where the Lorebook Maker route retried the failed batch once before continuing.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor at 577de008; legacy comparison was local main at 77a30fa4
  • Run mode: Tauri desktop / web shell through shared LLM and storage APIs; static trace only
  • OS + version: not recorded
  • Node + pnpm versions: not recorded
  • Rust version, if relevant: not relevant
  • Remote Runtime URL configured? not relevant to static trace
  • Provider, model, or integration, if relevant: any chat/completion provider used by Lorebook Maker

Logs, screenshots, or video

Static trace evidence:

  • Refactor maker path: src/features/catalog/lorebooks/components/dialogs/LorebookMakerModal.tsx
    • Calls generateLorebookMaker({ llm: llmApi, storage: storageApi }, ...).
    • Handles batch_warning, saved, and done events.
  • Refactor engine path: src/engine/generation/makers.ts
    • generateLorebookMaker parses each batch once.
    • If entries.length === 0, it yields batch_warning.
    • No retry loop exists around runMakerRequest / parseObject for the same batch.
  • Legacy comparison: main:packages/server/src/routes/lorebook-maker.routes.ts
    • The /lorebook-maker/generate route looped attempt < 2.
    • On first parse failure it emitted batch_warning, wrote a retry token separator, and retried the batch.

Targeted checks run during parityscan:

pnpm check:architecture
✔ no dependency violations found (817 modules, 2988 dependencies cruised)
Rust structure check passed.

cargo test --manifest-path src-tauri/Cargo.toml lorebook
34 passed

Regression notes

Legacy main was more resilient for malformed Lorebook Maker batch output. The refactor still supports streaming, batching, and saving generated entries into an existing or new lorebook, but it dropped the parse-retry recovery behavior.

Additional context

Parityscan batch: API / Remote / Maker / Architecture.

Rows scanned:

  • 07-LB-API-focused-wrappers
  • 07-LB-API-lorebook-maker
  • 07-LB-REMOTE-command-routing
  • 07-LB-ERROR-vector-image-validation
  • 07-LB-CONTRACT-core-schema

Only 07-LB-API-lorebook-maker produced a parity gap in this slice. Suggested fix direction: restore a one-retry batch loop inside generateLorebookMaker, preserving the current engine-owned maker path and existing batch_warning event shape.

Related tracker: #2181.

Template check

Please uncheck 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 @Promansis on GitHub (Jun 4, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2198 ## Summary Parityscan row `07-LB-API-lorebook-maker` found that the refactor Lorebook Maker no longer retries a batch when the model output cannot be parsed into valid lorebook entries. Legacy retried one malformed or empty batch before continuing, which made the maker more resilient to transient JSON formatting failures. ## Expected behavior When Lorebook Maker generates a batch that cannot be parsed into entries, it should retry that batch once before accepting a partial/empty batch result or reporting failure. ## Actual behavior The refactor engine generator parses each batch once with `parseGameJsonish`. If the parsed batch has no valid `entries`, it emits a `batch_warning` and continues to the next batch. There is no retry loop for the failed batch, so a transient malformed response can silently reduce the generated entry count. Legacy `main` handled the same route with a two-attempt loop: after an empty parse on the first attempt, it emitted a warning, added a retry separator to the stream, and retried the same batch once. ## Steps to reproduce 1. On `refactor`, open Lorebook Maker and request enough entries to generate at least one batch. 2. Use a connection/model response that returns malformed JSON or JSON without an `entries` array for a batch. 3. Observe that the batch reports a warning and generation continues without retrying the batch. 4. Compare against legacy `main`, where the Lorebook Maker route retried the failed batch once before continuing. ## Impact area <!-- Check the areas you think are relevant. Leave uncertain items unchecked. --> - [ ] App shell, navigation, startup, or providers - [x] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [x] React-free engine behavior, contracts, agents, or capability ports - [x] Shared API wrapper or remote runtime routing - [ ] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: `refactor` at `577de008`; legacy comparison was local `main` at `77a30fa4` - Run mode: Tauri desktop / web shell through shared LLM and storage APIs; static trace only - OS + version: not recorded - Node + pnpm versions: not recorded - Rust version, if relevant: not relevant - Remote Runtime URL configured? not relevant to static trace - Provider, model, or integration, if relevant: any chat/completion provider used by Lorebook Maker ## Logs, screenshots, or video Static trace evidence: - Refactor maker path: `src/features/catalog/lorebooks/components/dialogs/LorebookMakerModal.tsx` - Calls `generateLorebookMaker({ llm: llmApi, storage: storageApi }, ...)`. - Handles `batch_warning`, `saved`, and `done` events. - Refactor engine path: `src/engine/generation/makers.ts` - `generateLorebookMaker` parses each batch once. - If `entries.length === 0`, it yields `batch_warning`. - No retry loop exists around `runMakerRequest` / `parseObject` for the same batch. - Legacy comparison: `main:packages/server/src/routes/lorebook-maker.routes.ts` - The `/lorebook-maker/generate` route looped `attempt < 2`. - On first parse failure it emitted `batch_warning`, wrote a retry token separator, and retried the batch. Targeted checks run during parityscan: ```text pnpm check:architecture ✔ no dependency violations found (817 modules, 2988 dependencies cruised) Rust structure check passed. cargo test --manifest-path src-tauri/Cargo.toml lorebook 34 passed ``` ## Regression notes Legacy `main` was more resilient for malformed Lorebook Maker batch output. The refactor still supports streaming, batching, and saving generated entries into an existing or new lorebook, but it dropped the parse-retry recovery behavior. ## Additional context Parityscan batch: API / Remote / Maker / Architecture. Rows scanned: - `07-LB-API-focused-wrappers` - `07-LB-API-lorebook-maker` - `07-LB-REMOTE-command-routing` - `07-LB-ERROR-vector-image-validation` - `07-LB-CONTRACT-core-schema` Only `07-LB-API-lorebook-maker` produced a parity gap in this slice. Suggested fix direction: restore a one-retry batch loop inside `generateLorebookMaker`, preserving the current engine-owned maker path and existing `batch_warning` event shape. Related tracker: #2181. ## Template check Please uncheck 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-21 05:26:39 +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#1100
No description provided.