fix: forward maxOutputSize to OpenAI-compatible providers#438
fix: forward maxOutputSize to OpenAI-compatible providers#438RTCartist wants to merge 3 commits into
Conversation
The `toKosongProviderConfig` function forwarded `maxOutputSize` as `defaultMaxTokens` for Anthropic providers but omitted it for `openai` and `openai_responses` providers. This caused OpenAI-compatible providers like DeepSeek to receive the full `max_context_size` (e.g. 1,000,000) as `max_tokens`, exceeding the model's actual limit and triggering a 400 error. Forward `maxOutputSize` as `maxTokens` for the `openai` provider and as `maxOutputTokens` for the `openai_responses` provider, matching the constructor interfaces of their respective chat provider classes. Closes MoonshotAI#306
🦋 Changeset detectedLatest commit: 305e962 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Source changes live in `packages/agent-core/src/session/provider-manager.ts`, so the agent-core package needs to bump alongside `@moonshot-ai/kimi-code` to match the repo convention used by prior internal-package changes.
|
Sorry, we currently do not accept PRs submitted in batches using AI |
I think you at least need to review the pr and make decision. All prs have been checked and reviewed by myself. I have worked for it for hours, no logic |
I am using v0.10.1, and the problem do not exist. #365 this pr may has solved this, i think. |
Thanks for your reply. So nice of you. Much better now. |
Related Issue
Resolve #306
Problem
toKosongProviderConfigforwardsmaxOutputSizeasdefaultMaxTokensfor the Anthropic provider but omits it foropenaiandopenai_responses. As a result, OpenAI-compatible providers like DeepSeek receive the fullmax_context_size(1,000,000) asmax_tokensvia the completion-budget fallback, exceeding the model's actual cap and triggering400 Invalid max_tokens value.What changed
Forward
maxOutputSizeasmaxTokensto theopenaiprovider config and asmaxOutputTokenstoopenai_responses, matching the constructor signatures of the respectiveChatProviderclasses. Added three tests inruntime-provider.test.tscovering both providers (set / unset).Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.Verification
pnpm -C packages/agent-core exec vitest run test/harness/runtime-provider.test.tsNote: PR #318 by @qkunio addresses #306 at the budget-resolution layer; this PR addresses the provider-construction layer. The two fixes are complementary.