mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2766] [Issue]: Provider response & body-merge defects — Anthropic multi-block truncation, OpenAI Responses penalty 400, deepMergeRequestBody prototype pollution, empty-stream #1404
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#1404
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/2766
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Four serialization/response-handling defects: two cause hard failures or truncated output, one is a prototype-pollution security hole reachable via the agent customParameters salvage path, one silently returns blank output.
Sub-bug 1: Anthropic chat() drops all but the first text block (new-bug)
(a) The non-streaming branch yields
json.content.find(c => c.type === 'text')?.text ?? ''— only the FIRST text block. Claude can return multiple text blocks (interleaved with thinking), so later text is silently discarded -> truncated responses. The parallelchatCompletecorrectly joins all text blocks, so the two paths disagree.(b) Run an Anthropic generation with streaming OFF and interleaved-thinking that produces text/thinking/text segments (also the connection test-message path).
(c) anthropic.provider.ts:502-521 (line 512 the buggy
.find); contrast chatComplete join at 342-345; reachable via generate.routes.ts:6292 (provider.chatwithstream: input.streaming). Kind: new-bug.Sub-bug 2: OpenAI Responses API sends penalties -> 400 (new-bug)
(a)
buildResponsesBodyemitsfrequency_penalty/presence_penalty(gated only byshouldSendPenaltyParamswhich only excludes xAI). The Responses API has no such params (VERIFIED: openai-nodeResponseCreateParamscontains zero penalty fields), so a non-zero preset penalty on a Responses-routed model (codex-*, *-codex, gpt-5.4 with effort none/unset) yields HTTP 400 'Unknown parameter' with NO salvage/retry — generation aborts.(b) Use a codex / gpt-5.4 model with a preset that sets a non-zero frequency or presence penalty; generate.
(c) openai.provider.ts:1564-1576 (VERIFIED — penalty branch at 1572-1575 inside the
!isNoTemperatureModelgate), 543-545 (shouldSendPenaltyParams), 553-562 (isNoTemperatureModel), 679-694 (routing); contrast valid Chat-Completions siblings 893-896/1138-1139. Kind: new-bug.Sub-bug 3: Prototype pollution via deepMergeRequestBody + agent salvage path (security, new-bug)
(a)
deepMergeRequestBodyhas no__proto__/constructorguard: a JSON-parsedcustomParameterswith an own-enumerable__proto__key recurses intotarget['__proto__'] === Object.prototypeand mutates it in place. The happy path is protected (Zodz.recordstrips__proto__;mergeCustomParameters's spread drops it), but the AGENT path bypasses both:resolveConnectionCustomParameters->parseStoredGenerationParametersSALVAGE branch copiescustomParametersRAW (VERIFIED at generate-route-utils.ts:965-966) when any sibling field fails full-schema validation, and that raw object flows verbatim intoapplyCustomParameters->deepMergeRequestBody.(b) Import/craft a connection whose
defaultParameters.customParametershas__proto__:{...}plus one out-of-range sampler (to force the salvage branch); back an executed agent with it; run the agent.(c) base-provider.ts:598-601 (applyCustomParameters), 713-723 (VERIFIED no guard); generate-route-utils.ts:965-967 (raw copy); agent-resolution.ts:124-126/192; agent-executor.ts:217-221/392. Kind: new-bug (security). Local single-user app, requires crafted import -> medium-high, not remote-critical.
Sub-bug 4: Anthropic streaming returns silently empty on blocked/empty completion (new-bug)
(a) The streaming loop yields text only on
content_block_delta; if a stream finishes with no text delta (refusal/content-filter stop_reason with no text block) it returns usage-or-nothing with NO error. Gemini and the claude-subscription provider both throw a 'no content' terminal guard, so this is an error-surfacing asymmetry. Distinct from #2659 (which only covers explicit mid-streamtype:errorevents).(c) anthropic.provider.ts:523-612 (no terminal no-content guard at 606-612); contrast google.provider.ts:786-792 and claude-subscription.provider.ts:631-645. Kind: new-bug. Low frequency -> low/medium.
Suggested Fix
buildResponsesBody(penalties are Chat-Completions only); optionally add a 400 'Unknown parameter' salvage-and-retry.if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;; also validate the salvage-branch customParameters through Zod instead of copying raw.Template
pnpm checkpassesAffected files
packages/server/src/services/llm/providers/anthropic.provider.tspackages/server/src/services/llm/providers/openai.provider.tspackages/server/src/services/llm/base-provider.tspackages/server/src/routes/generate/generate-route-utils.tspackages/server/src/services/generation/agent-resolution.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):
Fixed in PR #2747.\n\nWhat changed:\n- Anthropic non-stream chat now joins every returned text block instead of taking only the first one, while still forwarding thinking blocks.\n- OpenAI Responses body construction no longer sends frequency_penalty/presence_penalty, avoiding Responses API unknown-parameter failures.\n- customParameters merge paths now skip proto, constructor, and prototype keys, including the stored-parameter salvage path and final request-body deep merge.\n- Anthropic streaming now throws a descriptive error when the stream completes without any text and was not aborted, instead of silently returning blank output.\n\nDeferred pnpm/check validation until the end of the issue sweep per maintainer request.