[PR #541] [MERGED] Fix agent Local Model fallback resolution #4663

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/541
Author: @cha1latte
Created: 5/8/2026
Status: ✅ Merged
Merged: 5/8/2026
Merged by: @cha1latte

Base: main ← Head: fix/issue-437-agent-local-fallback


📝 Commits (2)

  • 58509a0 Fix agent local model fallback resolution
  • aa45afc Tighten retry agent local fallback handling

📊 Changes

4 files changed (+120 additions, -20 deletions)

View changed files

📝 packages/server/src/routes/generate.routes.ts (+9 -4)
📝 packages/server/src/routes/generate/agent-connection-guards.ts (+12 -0)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+64 -16)
📝 packages/server/test/agent-connection-guards.test.ts (+35 -0)

📄 Description

Linked issue

Closes #437

Why this change

  • Agents that explicitly request Local Model could be skipped when the local sidecar was unavailable, even when the user had configured a default-for-agents paid API fallback.
  • The retry-agents path also needed to use the same fallback resolution so regenerate/force-continue does not behave differently from normal generation.

What changed

  • Added a shared agent connection resolver that falls back from unavailable Local Model to the configured default-for-agents connection when one exists.
  • Updated normal generation and retry-agent resolution to use the same fallback/skip decision.
  • Added focused server tests for Local Model fallback, skip-without-fallback, and sidecar-available behavior.

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

  • Machine proof before fix: node scratch/issue-437-repro.mjs failed in a clean upstream/main worktree with outcome: "skip-local-sidecar" and expected: "paid-agent-default".
  • Machine proof after fix: node scratch/issue-437-repro.mjs passed on this branch with outcome: "paid-agent-default".
  • Focused server test: pnpm --filter @marinara-engine/server exec tsx --test test/agent-connection-guards.test.ts passed.
  • Baseline validation: pnpm check passed.
  • Earlier broad pnpm --filter @marinara-engine/server test -- --test-name-pattern "falls back to the default agent connection" ran the full server suite because of argument forwarding and exposed unrelated Lorebook Keeper failures; the focused guard-file test above is the relevant proof for this fix.
  • Not manually verified in the browser because this is server-side agent connection resolution and does not require a UI layout/state check.
  • Container build not run.

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)

No docs or release metadata changes needed; this preserves the existing configured fallback behavior.

UI evidence (if applicable)

N/A - server-side agent connection resolution; no UI surface changed.


🔄 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/541 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/8/2026 **Status:** ✅ Merged **Merged:** 5/8/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `main` ← **Head:** `fix/issue-437-agent-local-fallback` --- ### 📝 Commits (2) - [`58509a0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/58509a0678ba8beece4af6a799ca569edd6d3699) Fix agent local model fallback resolution - [`aa45afc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aa45afc5e51f7e6b5caf5c22abd7c8b78d389bd4) Tighten retry agent local fallback handling ### 📊 Changes **4 files changed** (+120 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/generate.routes.ts` (+9 -4) 📝 `packages/server/src/routes/generate/agent-connection-guards.ts` (+12 -0) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+64 -16) 📝 `packages/server/test/agent-connection-guards.test.ts` (+35 -0) </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 #437 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Agents that explicitly request Local Model could be skipped when the local sidecar was unavailable, even when the user had configured a default-for-agents paid API fallback. - The retry-agents path also needed to use the same fallback resolution so regenerate/force-continue does not behave differently from normal generation. ## What changed <!-- List the key changes in this PR --> - Added a shared agent connection resolver that falls back from unavailable Local Model to the configured default-for-agents connection when one exists. - Updated normal generation and retry-agent resolution to use the same fallback/skip decision. - Added focused server tests for Local Model fallback, skip-without-fallback, and sidecar-available behavior. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [ ] `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 <!-- 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. --> - Machine proof before fix: `node scratch/issue-437-repro.mjs` failed in a clean `upstream/main` worktree with `outcome: "skip-local-sidecar"` and `expected: "paid-agent-default"`. - Machine proof after fix: `node scratch/issue-437-repro.mjs` passed on this branch with `outcome: "paid-agent-default"`. - Focused server test: `pnpm --filter @marinara-engine/server exec tsx --test test/agent-connection-guards.test.ts` passed. - Baseline validation: `pnpm check` passed. - Earlier broad `pnpm --filter @marinara-engine/server test -- --test-name-pattern "falls back to the default agent connection"` ran the full server suite because of argument forwarding and exposed unrelated Lorebook Keeper failures; the focused guard-file test above is the relevant proof for this fix. - Not manually verified in the browser because this is server-side agent connection resolution and does not require a UI layout/state check. - Container build not run. ## 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) No docs or release metadata changes needed; this preserves the existing configured fallback behavior. ## UI evidence (if applicable) N/A - server-side agent connection resolution; no UI surface changed. --- <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:36 +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#4663
No description provided.