feat(provider): add custom body overrides#1789
Open
ayu-exorcist wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: 393972d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 356aadf4b5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
ayu-exorcist
force-pushed
the
feat/custom-body
branch
from
July 17, 2026 05:04
356aadf to
e38f92d
Compare
ayu-exorcist
force-pushed
the
feat/custom-body
branch
from
July 17, 2026 05:35
e38f92d to
393972d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue
Related to #1674. This PR delivers the provider-scoped part of that request; model-scoped overrides remain a follow-up design decision.
Problem / 背景
English
Provider APIs and compatible gateways expose request fields that Kimi Code does not generate itself. For example, OpenAI Priority processing uses
service_tier: "priority". Without a supported configuration surface, users need a reverse proxy or a local source patch to use those capabilities.中文
供应商 API 与兼容网关提供了 Kimi Code 不会自行生成的请求字段。例如,OpenAI Priority 处理需要
service_tier: "priority"。缺少受支持的配置入口时,用户只能借助反向代理或修改本地源码来使用这些能力。What changed / 改动内容
English
custom_bodyTOML field alongsidecustom_headers.service_tierandcache_controlunchanged.false,0, empty strings, and SDK/RPCnull.custom_body.streamas a transport-control override. It selects matching request serialization and response decoding for the OpenAI-compatible and Anthropic providers; for Google GenAI and Vertex AI, it selectsgenerateContentorgenerateContentStreamand is not forwarded to the SDK request object.__proto__,prototype, andconstructorat every nesting level, and use safe own-property writes while merging to prevent prototype pollution.customBodyround-trips through supported client transports.中文
custom_bodyTOML 字段,并与custom_headers配套使用。service_tier、cache_control等供应商原生键不变。false、0、空字符串以及 SDK/RPC 中的null。custom_body.stream视为传输控制覆盖。它会让 OpenAI 兼容供应商与 Anthropic 选择匹配的请求序列化和响应解码;对 Google GenAI 与 Vertex AI,则选择generateContent或generateContentStream,且不会透传到 SDK 请求对象。__proto__、prototype和constructor,并在合并时安全写入自有属性,防止原型污染。customBody可以在受支持的客户端传输中往返。Scope / 范围
English
This implementation intentionally uses provider scope: fields apply to every request sent through the configured provider. It does not add model-level
custom_bodyconfiguration. That work needs an explicit precedence model between provider defaults, model overrides, and generated request fields, and remains tracked by #1674.中文
本实现有意采用 Provider 级范围:字段会作用于该 Provider 发出的所有请求。它不新增模型级
custom_body配置。模型级能力需要先明确 Provider 默认值、模型覆盖和生成请求字段之间的优先级,因此仍由 #1674 跟踪。Validation / 验证
pnpm exec vitest run …: 120 focused tests passed after rebasing onto the latestupstream/main.@moonshot-ai/kosong,@moonshot-ai/agent-core-v2, and@moonshot-ai/klienttypecheck passed.@moonshot-ai/agent-core-v2 lint:domain, documentation build, andgit diff --checkpassed.Checklist
minorchangeset for@moonshot-ai/kimi-code.