mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2765] [Issue]: Sampler params silently dropped per provider/path — Anthropic top_p, Gemini default topK=0 (400), dry-run minP/stop/top_p, Responses stop, claude-subscription all #1403
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#1403
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/2765
Originally assigned to: @SpicyMarinara on GitHub.
Summary
The same class as the already-fixed #2668 (minP) / #2658 (stop): a configured sampler param is silently dropped on a specific provider or send-path, diverging from preset intent and from the same preset's behavior elsewhere. Several distinct missed instances remain.
Sub-bug 1: Anthropic never sends top_p (missed-instance)
(a)
options.topPis resolved and clamped by the pipeline but the Anthropic body builder only sets temperature, top_k, stop_sequences — nevertop_p. The onlytop_preference isdelete body.top_pinstripAnthropicSamplingParameters(a defensive delete that never fires from topP). OpenAI and Google both send it, so the same preset behaves differently on Claude.(b) Set a non-default topP in a preset/connection; run a native Anthropic generation; top_p is absent from the request.
(c) anthropic.provider.ts:284-294 (chatComplete body — VERIFIED: temperature/top_k/stop_sequences only at 291-293, no top_p), 413-441 (chat body), 30-34 (strip). topP reaches options via generate.routes.ts:3468/6083. Kind: missed-instance.
Sub-bug 2: Gemini sends default topK=0 sentinel (new-bug)
(a)
DEFAULT_GENERATION_PARAMS.topK = 0is the 'disabled' sentinel.resolveProviderTopKreturnsnormalized(0) for google/google_vertex while every other provider maps 0 -> undefined. The Google body builder's guard istypeof number && Number.isFinite(true for 0), so it emitsgenerationConfig.topK: 0. NOTE: this is partly documented (CHANGELOG 1.6.1 intentionally sends 0 as 'disabled'); the public Gemini API appears lenient, but Vertex documents topK min 1, so this is a real risk on google_vertex and an inconsistency worth resolving.(b) Use a google_vertex connection with a default preset (topK unset); generate.
(c) generate-route-utils.ts:199-206 (VERIFIED — google branch returns
normalizedwithout> 0guard); google.provider.ts:459-461 (VERIFIED — guard passes for 0) and 614-616 (streaming). Kind: new-bug (disputed-intentional for public Gemini, real for Vertex).Sub-bug 3: Dry-run never forwards minP (missed-instance)
(a) The dry-run/prompt-preview path has no minP variable at all; the real path declares/applies/sends it. Preview diverges from real generation on min_p-honoring backends.
(c) dry-run-route.ts has zero minP references (defaults block, applyParameterOverrides, both chatComplete calls); contrast generate.routes.ts:1684/2076/3470/6087. Kind: missed-instance.
Sub-bug 4: Dry-run drops stopSequences (missed-instance)
(a) Dry-run applyParameterOverrides has no stopSequences branch and neither chatComplete call passes
stop. Preset stop sequences don't truncate the preview.(c) dry-run-route.ts:534-548 (no stop branch), 1572-1591 / 1635-1653 (no
stop); contrast generate.routes.ts:2086-2088/3482-3484/6088. Kind: missed-instance.Sub-bug 5: Dry-run local normalizeChatTopP regresses top_p=0 -> 1 (regression)
(a) dry-run-route.ts defines a STALE local copy
if (value <= 0) return 1, while the canonicalservices/generation/generation-parameters.tswas fixed for #2663 (if (value < 0) return undefined; return Math.min(value, 1)). The dry-run path (preview AND its real streaming/non-streaming chatComplete calls) rewrites a stored top_p of 0 to 1.(c) dry-run-route.ts:394-398 (local copy), 538 (applied); canonical generation-parameters.ts:28-32. Kind: regression (the #2663 fix did not propagate to the duplicated helper).
Sub-bug 6: OpenAI Responses API drops stop sequences (missed-instance)
(a)
buildResponsesBodynever readsoptions.stop. Models forced onto /responses (GPT-5.5, gpt-5.4, codex, openai-chatgpt) silently ignore preset stop sequences honored on the Chat Completions path. (Caveat: the Responses API's stop support is limited; at minimum surface a warning if it cannot be honored.)(c) openai.provider.ts:1511-1614 (no stop); contrast 858/1104. Kind: missed-instance.
Sub-bug 7: claude_subscription drops all sampler params (new-bug, SDK-bounded)
(a) The Agent-SDK provider only forwards model/thinking/effort/maxTokens; temperature/topP/topK/minP/penalties are never forwarded (the SDK exposes no such knobs — VERIFIED against the bundled
@anthropic-ai/claude-agent-sdktype defs). Same preset honors samplers on the API-key Anthropic connection but silently ignores them here, with no warning logged.(c) claude-subscription.provider.ts:340-424. Kind: new-bug (forced SDK limitation; fix is a one-time warn, not a wire change).
Suggested Fix
if (typeof options.topP === "number") body.top_p = options.topPto both chat()/chatComplete() bodies (use typeof not truthy so 0 survives), keeping the strip for adaptive-only models.resolveProviderTopKreturnundefinedwhennormalized <= 0for google too (or change the provider guard tooptions.topK > 0).normalizeChatTopP(delete the local copy); add minP and stopSequences resolution+forwarding mirroring generate.routes.ts.Template
pnpm checkpassesAffected files
packages/server/src/services/llm/providers/anthropic.provider.tspackages/server/src/services/llm/providers/google.provider.tspackages/server/src/routes/generate/generate-route-utils.tspackages/server/src/routes/generate/dry-run-route.tspackages/server/src/services/llm/providers/openai.provider.tspackages/server/src/services/llm/providers/claude-subscription.provider.tsAudit provenance
Found by a multi-agent re-review of the connection/preset subsystem (editors UI + send-pipeline) against the merged
stagingtree (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified). The prior #2656-#2668 fixes were re-verified as HELD on their primary paths. Severity: HIGH.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Anthropic doesn't support Top P at all.
@SpicyMarinara commented on GitHub (Jun 21, 2026):
Let's do only Gemini one, skip the others.
@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed the maintainer-approved subset in PR #2747.\n\nApplied:\n- Gemini/Google Vertex now treats topK <= 0 as the disabled sentinel in resolveProviderTopK, so default topK=0 is omitted instead of serialized into generationConfig.topK.\n\nSkipped intentionally:\n- Anthropic top_p, dry-run minP/stop/top_p, OpenAI Responses stop, and claude_subscription sampler warnings were left unchanged per maintainer comment: "Let's do only Gemini one, skip the others."\n\nDeferred pnpm/check validation until the end of the issue sweep per maintainer request.