mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2665] [Issue]: Connection max-output-tokens cap (maxTokensOverride) is ignored on Anthropic, Google, and Claude-subscription providers #1315
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#1315
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/2665
Originally assigned to: @SpicyMarinara on GitHub.
Summary
The connection-level max-output-tokens cap (
maxTokensOverride) is only enforced on OpenAI-family providers. Anthropic, Google, and Claude-subscription providers receive the override but never apply it, so the cap is silently ignored on 3 of the 4 provider families.Expected behavior
A connection's max-output-tokens cap should clamp the outgoing
max_tokens(downward) on every provider, so a user can reliably bound cost/latency regardless of which provider the connection uses.Actual behavior
BaseLLMProviderstores the cap (this.maxTokensOverride) and exposesapplyMaxTokensCap(tokens), but onlyOpenAIProvidercalls it. Anthropic/Google/Claude-subscription send the preset/per-chatmaxTokens(or the 4096 default) uncapped.How it breaks the pipeline
Code trace (staging @
b826f8f4):packages/server/src/services/llm/base-provider.ts:560—applyMaxTokensCap(tokens), populated from the connection'smaxTokensOverrideviaprovider-registry.ts(~:40–43).packages/server/src/services/llm/providers/openai.provider.ts:814,:821,:1051,:1058.anthropic.provider.tscomputesconfiguredMaxTokens = options.maxTokens ?? 4096(:324) and sendsbody.max_tokens(:382) with no cap.google.provider.tssendsmaxOutputTokens(~:458/:462) with no cap.claude-subscription.provider.ts(~:325) with no cap.A repo-wide search for
applyMaxTokensCapreturns only the OpenAI call sites plus the base definition — confirming Anthropic/Google/Claude-subscription never invoke it.Steps to reproduce
maxTokensOverrideof e.g.256.maxTokens=4096.max_tokensis4096(uncapped). On an OpenAI connection the same setup correctly caps to256.Suggested fix
Apply the cap in the Anthropic, Google, and Claude-subscription
chat()/chatComplete()paths, mirroringopenai.provider.ts:814/:821— e.g.const configuredMaxTokens = suppressModelParameters ? undefined : this.applyMaxTokensCap(options.maxTokens ?? 4096)and re-apply to the context-fitted value. Better still: centralize the cap inside the shared context-fit /max_tokensresolution so no provider can forget it.Environment
b826f8f4)Additional context
Identified via a systematic source-level review of the connection/preset → LLM-request pipeline on staging (refs @
b826f8f4), as a sibling of the auth/param Tier-1 bug set (#2656–#2658). The OpenAI provider already demonstrates the intended pattern.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 20, 2026):
Implemented on branch codex/spicymarinara-assigned-issues: maxTokensOverride is now applied outside the OpenAI provider family as well. Final validation will run after the full assigned sweep per maintainer request.