mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2719] [Issue]: Local sidecar params not backend-aware (min_p dropped; MLX allows tool calls with no support, ignores contextSize/thinking-disable/json_schema) #1364
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1364
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2719
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Local request building is not parameter-complete or backend-aware.
top_kis plumbed for the local backend but its sibling samplermin_pis dropped; and the MLX backend is handed tool requests, llama.cpp-specific params, and a non-standard json_schema envelope it cannot honor, plus its context-size setting and restart signature ignore the user's config.1. Preset min_p silently dropped for the local sidecar (medium)
How it breaks the pipeline: Min-P is a primary sampler for local models, but
ChatOptionshas nominPfield andOpenAIProvidernever emitsbody.min_p, so a user's preset Min-P is ignored on the only backend (llama-server/v1/chat/completions) that natively honors it — diverging from SillyTavern and the preset display.Steps to replicate: Set Min-P in a preset, generate via the local sidecar; sampling ignores it (top_k, the sibling sampler, is honored).
Trace:
ChatOptionsdeclarestopKbut nominP(base-provider.ts:85-135). The body special-casestop_kfor local viashouldSendTopK()(openai.provider.ts:871/1104, true forapiKey==='local-sidecar') but has nomin_pbranch.applyRuntimeSettingsonly forwards maxTokens/temperature/topP/topK (local-sidecar.provider.ts:41-56). The preset value is salvaged (generate-route-utils.ts:829) and imported (st-prompt.importer.ts:97) but never read back out.Suggested Fix: Add
minPtoChatOptions, plumb it throughapplyRuntimeSettings, and emitbody.min_pguarded by ashouldSendMinP()(true for local-sidecar) whenoptions.minPis finite in [0,1].2. MLX accepts tool requests with no tool support (low)
How it breaks the pipeline:
assertToolCallsAvailableonly blocks tools forllama_cpp; formlxit returns without checking, so tools flow tomlx_lm.server(launched with no jinja/tools flags). For the curated default Gemma model, emitted tool delimiters are never parsed, sotool_callsstays empty and agents silently produce no tool actions — unlike the clear guard llama.cpp users get.Steps to replicate: On Apple Silicon with the default MLX model, run a tool-bearing agent; no tool calls ever happen, with no actionable error.
Trace:
assertToolCallsAvailableearly-returns unless backend is 'llama_cpp' (local-sidecar.provider.ts:31-39).buildMlxArgslaunches with no tool/jinja flags (sidecar-process.service.ts:358-360).OpenAIProviderstill attachesbody.toolsand parsestool_calls; with none returned,toolCallsis[].Suggested Fix: Extend
assertToolCallsAvailableto reject/warn whenbackend==='mlx'andoptions.tools?.length, mirroring the llama.cpp guard.3. config.contextSize dropped on MLX (medium)
How it breaks the pipeline:
buildMlxArgsnever translatescontextSizeto an MLX flag, somlx_lm.serverruns at its built-in default while the client budgets prompts to the configured window. Worse,contextSizeis omitted from the MLX restart signature, so changing it never restarts the server.Steps to replicate: On MLX, raise contextSize and run a long scene/tracker; it truncates/rejects, and the running server is not restarted by the change.
Trace:
buildMlxArgsreturns only-m/--model/--host/--port(sidecar-process.service.ts:358-360); the MLX signature is{backend, pythonPath, modelRef}with no contextSize (411-418), so the early-return guard (273) skips the restart. The chat path budgets toconfig.contextSizeviaOpenAIProvider.fitMessagesToContext(local-sidecar.provider.ts:20-21).Suggested Fix: Map
contextSizeto the appropriatemlx_lm.serverargument (and include it in the MLX restart signature so a change triggers a restart), or clamp Marinara's prompt budget to mlx_lm.server's actual default.4. MLX startup-failure auto-restart re-download loop (low)
How it breaks the pipeline: Because MLX
markReady()fires on the early/v1/models200 (before the model loads), a load-time crash (OOM, slow partial HF download) lands >30s after ready, so thecrashedSoonAfterReadyguard resetsunexpectedCrashCountto 1 every cycle and never trips the >1 cap — an unbounded restart/re-fetch loop instead of a stable error.Steps to replicate: On MLX, cause a slow load failure (OOM after a multi-GB load); the sidecar keeps re-launching and re-fetching weights.
Trace:
crashedSoonAfterReady = lastReadyAt>0 && now-lastReadyAt<30_000(sidecar-process.service.ts:721);unexpectedCrashCount = crashedSoonAfterReady ? +1 : 1(722);if (>1) server_error; return;(724) never trips; line 731 restarts.markReadyrefresheslastReadyAteach cycle.Suggested Fix: Tie readiness to a real MLX load so
lastReadyAtreflects a loaded model, and/or use a wall-clock/backoff repeated-failure guard that accounts for MLX's long load window.5. MLX request bodies not backend-aware (low)
How it breaks the pipeline: Scene/tracker/test bodies send llama.cpp-shaped params verbatim to
mlx_lm.server. The decisive defect is the structured-output envelope:analyzeScenesends{type:'json_schema', schema}(schema at top level), and mlx_lm.server has no structured-output support at all, so the constraint is dropped and scene analysis degrades to unconstrained JSON on MLX.Steps to replicate: On Apple Silicon run Game-Mode scene analysis; output is unconstrained prose-ish JSON that intermittently fails to parse.
Trace:
runTestMessagealways sendsreasoning_format:'none'+chat_template_kwargs(sidecar-inference.service.ts:282-283);analyzeScenepasses{type:'json_schema', schema: SCENE_ANALYSIS_SCHEMA}(499-502);streamChatCompletionforwards verbatim with no backend branch (170). mlx_lm.server (upstream main) never readsresponse_format.Suggested Fix: Branch request bodies on
getResolvedBackend(); for MLX emit only supported params and either the standard OpenAI envelope or document that schema enforcement is unavailable so callers degrade gracefully.Affected files
packages/server/src/services/llm/providers/openai.provider.tspackages/server/src/services/llm/base-provider.tspackages/server/src/services/llm/providers/local-sidecar.provider.tspackages/server/src/services/sidecar/sidecar-process.service.tspackages/server/src/services/sidecar/sidecar-inference.service.tspackages/server/src/services/sidecar/sidecar-launch-plan.tsAudit provenance
Found by a multi-agent static audit of the sidecar/local-model subsystem (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified). Severity: MEDIUM. Line numbers are against the
stagingworking tree.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Addressed in
f7a371daon the issue-sweep branch. Current code already had ChatOptions.minP and OpenAI/local min_p emission; this change makes the local sidecar wrapper preserve Min-P explicitly, blocks MLX tool calls with a clear error, strips unsupported structured-output envelopes from MLX requests, removes llama.cpp-only thinking-disable fields from MLX smoke tests, includes contextSize in the MLX runtime signature so config changes are not treated as the same process, and adds a repeated-crash window so ready/crash/restart loops are capped. I did not add a fake MLX context-size CLI flag: upstream MLX server docs list supported request fields and do not expose a context-size server option.@kolacheee commented on GitHub (Jun 21, 2026):
Claim 3's headline defect persists on the MLX backend: the client budgets prompts to config.contextSize while mlx_lm.server runs at its built-in default. buildMlxArgs (C:/Users/Alyssa/Documents/GitHub/_marinara_staging_verify/packages/server/src/services/sidecar/sidecar-process.service.ts:433-435) sends only -m/--model/--host/--port — no context flag. Both prompt-budget paths remain backend-agnostic: inference at sidecar-inference.service.ts:209-212 (maxContext:config.contextSize) and chat at local-sidecar.provider.ts:20-21 (delegate built with config.contextSize). No MLX clamp exists in sidecar-model.service.ts getConfig() (494-496). The maintainer justifiably declined the nonexistent MLX context CLI flag but did not implement the offered alternative (clamp the prompt budget to mlx_lm.server's default), so long scenes/trackers on MLX can still over-budget and truncate/reject. Only the restart-signature sub-part is fixed (contextSize added to MLX signature at sidecar-process.service.ts:522).