mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2684] [Issue]: Agent API requests omit connection customParameters/stop and don't finite-guard temperature (agent-only failures) #1328
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#1328
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 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2684
Originally assigned to: @SpicyMarinara on GitHub.
Summary
The agent path never threads the connection's
customParameters(nordefaultParameters/stop) into agent requests, and it doesn't finite-guard the agenttemperature. So a connection that requires a mandatory provider param works on main chat but fails on every agent call, and a non-numeric/out-of-range storedtemperature(via API/import) reaches the provider — and on the batch path poisons every co-grouped agent viaMath.min.Expected behavior
Agent requests on a given connection should carry the same mandatory provider parameters the main chat path sends, and should never send a non-finite/out-of-range
temperature.Actual behavior
createLLMProvider(provider, baseUrl, apiKey, maxContext, openrouterProvider, maxTokensOverride)— which has no parameter for the connection'scustomParameters/defaultParameters/stop. The executor'schatCompleteoption literals pass only{ model, temperature, maxTokens, stream, tools?, onToken?, signal }and never setcustomParameters, soapplyCustomParameters(which only mergesoptions.customParameters) is a no-op on the agent path. The main path threadscustomParametersend-to-end.temperatureis read as(config.settings.temperature as number) ?? 0.3with noNumber.isFiniteguard (unlikemaxTokens/contextSize, which are normalized).settingsisz.record(z.unknown())with no numeric validation, so a stored"high"/-1passes through. On the batch path,Math.min(...)over a non-numeric/NaN member yieldsNaN, poisoning the whole batch request.How it breaks the pipeline
Code trace (staging @
b826f8f4):agent-resolution.ts:135/:203(createLLMProvider);provider-registry.ts:26-35(no customParameters param);agent-executor.ts:333,:375,:467,:547,:696(option literals omitcustomParameters);base-provider.ts:590-593(applyCustomParametersonly mergesoptions.customParameters). Main path threads it atgenerate.routes.ts:5839/:5993/:6049.agent-executor.ts:299(single),:654(batchMath.min),:430(error path); schemaagent.schema.ts:53(settings: z.record(z.unknown())). ComparenormalizeAgentMaxTokens(:194,Number.isFinite). On Anthropic aNaN→nulltemperature 400s; the batchMath.min(...NaN)= NaN fails every batched agent.Steps to reproduce
customParameters: Configure a connection whose
customParameterscarries an upstream-required field (e.g. OpenRouter{"provider":{"order":[...]}}or a proxy-required body key) and use it for agents. Main chat sends it and succeeds; agent/batchchatCompleteomits it → 400 / mis-routed. Agent results come back as errors while the main response is fine.temperature: Persist a custom agent whose settings JSON has
"temperature":"high"(or a negative value) via the REST API/import. Run it in a batch with another agent →Math.min(..., "high"/NaN)poisons the batch temperature → the whole batch 400s.Suggested fix
customParameters(anddefaultParameters/stopwhere applicable) into the agent path — bake them into the provider increateLLMProvider, or pass them throughResolvedAgentinto eachexecuteAgent/executeAgentBatchchatCompleteoptions object soapplyCustomParametersmerges them like the main path.normalizeAgentTemperature(value, fallback=0.3)helper (mirroringnormalizeAgentMaxTokens: coerce, fall back when!Number.isFinite, clamp to range) and use it atagent-executor.ts:299,:430, and the batch reducer:654beforeMath.min; optionally validatetemperatureinagent.schema.ts.Environment
b826f8f4)Additional context
Found via a systematic multi-agent audit of the agent subsystem. The temperature path is mainly a power-user/import hardening gap (no UI field); the dropped-
customParameterspath affects any agent on a connection that needs a mandatory provider param. Part of a set of agent-pipeline issues filed together.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@kolacheee commented on GitHub (Jun 21, 2026):
Clarification after re-verifying against the current tree. The customParameters and temperature claims are confirmed accurate and still present. Three corrections to keep a fixer on track:
The
stop/stopSequencesparenthetical overstates parity and should be de-scoped (or split into its own issue).stopSequencesis parsed/stored (generate-route-utils.ts:867-868, prompt.schema.ts:63) andChatOptions.stopexists (base-provider.ts:96) and providers sendbody.stop = options.stop(openai.provider.ts:854, 1089) — BUT a full-tree search shows nothing ever setsstop:in a ChatOptions object on the MAIN path either (the main-path override block at generate.routes.ts:3265-3279 never readsparams.stopSequences; the onlystop:matches in server/src are the unrelated haptic service). Sostopis a no-op on BOTH paths today. Threadingstopinto the agent path alone changes nothing — the main-path stopSequences→options.stop conversion would have to be built first. Recommend droppingstopfrom this agent-parity fix. (customParameters parity is genuinely broken and stays in scope: main threads it at generate.routes.ts:5839 from conn.defaultParameters parsed at :3260/merged at :3279; agent path never sets options.customParameters.)Minor line-number drift (claims still valid): batch
Math.minis at agent-executor.ts:650 (not :654 — that is thetry {); error-path temperature read is at :426 (not :430 — that isdurationMs); single-agent read at :299 is correct.Scope note for the temperature fix: a stored non-numeric temperature (e.g. "high") breaks the SINGLE agent path too, not just batch —
(config.settings.temperature as number) ?? 0.3returns the string unchanged because??only catches null/undefined, and it is passed straight to the provider (anthropic.provider.ts:270 sends it whenever!== undefined; NaN serializes to null → 400). So normalizeAgentTemperature must wrap :299 and :426 as well as the batch map at :650 — which the suggested fix already lists, so the fix stays complete. Note the main path already guards this viaif (typeof params.temperature === "number")at generate.routes.ts:3265, which is the disparity. Also:customParameters/stopSequencesare nested fields inside the connection'sdefaultParametersJSON blob (prompt.schema.ts:59, :63), not separate connection columns.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Addressed on the issue-sweep branch. Agent resolution now carries connection default customParameters for chat fallback, default-for-agents, per-agent connections, and manual agent retry; every agent executor chatComplete call (single, retry, tools, final tool fallback, batch) passes them through. Agent temperatures now normalize to a finite 0..2 range with the existing 0.3 fallback before single-agent, error-debug, and batch Math.min paths. I intentionally left stop/stopSequences out per the verifier comment because the main path does not wire stop today either. Final repo checks will run after the sweep.