[PR #4654] [CLOSED] fix(noodle): improve stage profile prompt and unwrap LLM arrays #6458

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4654
Author: @MetzeVanDeus
Created: 8/5/2026
Status: ❌ Closed

Base: staging ← Head: fix/noodler-stage-profile-prompt


📝 Commits (4)

  • 4c41b01 fix(noodle): improve stage profile prompt and unwrap LLM arrays
  • 7faae61 fix(noodle): improve stage profile draft robustness
  • bb491a9 fix(noodle): improve stage profile draft robustness
  • 4c83158 Merge branch 'staging' into fix/noodler-stage-profile-prompt

📊 Changes

2 files changed (+56 additions, -2 deletions)

View changed files

➕ packages/server/scripts/regressions/noodle-stage-profile-draft.regression.ts (+47 -0)
📝 packages/server/src/services/noodle/noodle-stage-profile-draft.service.ts (+9 -2)

📄 Description

Linked issue

Closes #4626 (second half the first half was PR #4604)

Why this change

Two recurring Zod errors when creating Noodler stage profiles:

  • Expected object, received array — local LLMs wrap responses in [{…}]
  • Invalid enum value. Expected 'open' | 'hinted' | 'secret', received 'Always' — the disclosureMode field in the LLM response uses an invalid enum value, crashing the entire request even though it's always overridden from the request

What changed

  • noodle-stage-profile-draft.service.ts: Use .omit({ disclosureMode: true }) before Zod validation so invalid enum values don't block the run; add .strip() to drop extra keys the LLM emits; strip leading @ from handle to avoid @@ display bug; update prompt with explicit enum values
  • packages/server/scripts/regressions/noodle-stage-profile-draft.regression.ts: Two test cases pin the exact failure modes from #4626 so future prompt changes can't quietly bring them back

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

  • noodle-stage-profile-draft.regression.ts passes locally (tests both failure modes)
  • pnpm regression:noodle runs the existing noodler regression suite without issues
  • Prompt explicitly specifies enum values ("open", "hinted", "secret") and "single JSON object only, no arrays" to reduce future LLM wrapping
  • tested array-wrapped LLM response [{…}] → unwrapped correctly, no Zod crash; tested disclosureMode: "Always" → dropped before validation, no crash; tested extra keys in response → .strip() drops them.

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)

UI evidence (if applicable)

Update the system prompt to tell LLMs to return a single JSON object
(no arrays) and specify valid disclosureMode enum values. Also add
a minimal array unwrap guard for when local models still wrap the
object in brackets.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of generated stage profiles, including single-object and single-item array responses.
    • Unknown fields are now removed, while expected profile details are preserved and validated consistently.
    • Generated handles no longer retain an unintended leading “@”.
    • Disclosure settings are applied reliably using supported values.
  • Tests
    • Added regression coverage for profile parsing, validation, field cleanup, and successful completion.

🔄 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/4654 **Author:** [@MetzeVanDeus](https://github.com/MetzeVanDeus) **Created:** 8/5/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `fix/noodler-stage-profile-prompt` --- ### 📝 Commits (4) - [`4c41b01`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4c41b0124628146da79929b0f99f6fce569cd669) fix(noodle): improve stage profile prompt and unwrap LLM arrays - [`7faae61`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7faae618747be07b1c2f65e6007316b301e55f25) fix(noodle): improve stage profile draft robustness - [`bb491a9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bb491a9d60e59bfa5367111149dd508ed032451c) fix(noodle): improve stage profile draft robustness - [`4c83158`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4c83158dfa38ef1070b61f9f340c7c9ff5fce11d) Merge branch 'staging' into fix/noodler-stage-profile-prompt ### 📊 Changes **2 files changed** (+56 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `packages/server/scripts/regressions/noodle-stage-profile-draft.regression.ts` (+47 -0) 📝 `packages/server/src/services/noodle/noodle-stage-profile-draft.service.ts` (+9 -2) </details> ### 📄 Description ## Linked issue <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> Closes #4626 (second half the first half was PR #4604) ## Why this change <!-- What user problem, bug, or goal does this solve? --> Two recurring Zod errors when creating Noodler stage profiles: - Expected object, received array — local LLMs wrap responses in [{…}] - Invalid enum value. Expected 'open' | 'hinted' | 'secret', received 'Always' — the disclosureMode field in the LLM response uses an invalid enum value, crashing the entire request even though it's always overridden from the request ## What changed <!-- List the key changes in this PR --> - noodle-stage-profile-draft.service.ts: Use .omit({ disclosureMode: true }) before Zod validation so invalid enum values don't block the run; add .strip() to drop extra keys the LLM emits; strip leading @ from handle to avoid @@ display bug; update prompt with explicit enum values - packages/server/scripts/regressions/noodle-stage-profile-draft.regression.ts: Two test cases pin the exact failure modes from #4626 so future prompt changes can't quietly bring them back ## 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. --> - noodle-stage-profile-draft.regression.ts passes locally (tests both failure modes) - pnpm regression:noodle runs the existing noodler regression suite without issues - Prompt explicitly specifies enum values ("open", "hinted", "secret") and "single JSON object only, no arrays" to reduce future LLM wrapping - tested array-wrapped LLM response [{…}] → unwrapped correctly, no Zod crash; tested disclosureMode: "Always" → dropped before validation, no crash; tested extra keys in response → .strip() drops them. ## 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) ## UI evidence (if applicable) <!-- Add before/after screenshots or recordings for UI changes --> Update the system prompt to tell LLMs to return a single JSON object (no arrays) and specify valid disclosureMode enum values. Also add a minimal array unwrap guard for when local models still wrap the object in brackets. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved handling of generated stage profiles, including single-object and single-item array responses. * Unknown fields are now removed, while expected profile details are preserved and validated consistently. * Generated handles no longer retain an unintended leading “@”. * Disclosure settings are applied reliably using supported values. * **Tests** * Added regression coverage for profile parsing, validation, field cleanup, and successful completion. <!-- 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:10:37 +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#6458
No description provided.