fix(agent-core): only send prompt_cache_key to official OpenAI endpoints
Related Issue
Tracking / backup of #2203 (original by @B143KC47).
Resolve #2166
If #2203 is merged first, this PR can be closed with no further action.
Problem
Since v0.29.0 (#1970), every OpenAI-compatible provider receives the session prompt_cache_key in the request body. Strictly-validating endpoints (e.g. NVIDIA NIM at integrate.api.nvidia.com) reject the unknown parameter with:
400 Validation: Unsupported parameter(s): `prompt_cache_key`
That makes custom openai / openai_responses providers unusable for agent sessions.
What changed
Same fix as #2203, rebased onto current main:
- Only send
prompt_cache_keywhen the effective base URL targets the official OpenAI API (api.openai.comor*.api.openai.com, or unset → client default). - v1: gate in
toKosongProviderConfigforopenaiandopenai_responses(isOfficialOpenAIBaseUrl). - v2: same gate on the bare
cacheKey→prompt_cache_keyfallback in OpenAI chat-completions and Responses bases. - Kimi protocol branch untouched (Kimi endpoints support the field).
- Tests: custom endpoint omits the field; official endpoint keeps it.
Checklist
- [x] Based on upstream #2203
- [x] Rebased on latest
main - [x] Changeset included (from #2203)
- [x] Tests included (from #2203)
Note
This is a tracking/backup PR so the fix stays visible on the creatiVision fork if #2203 stalls. Prefer merging #2203 if it is ready; maintainers should not need both.
🦋 Changeset detected
Latest commit: eadb1d120079c692966b815600e0465d66fbdc2b
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| @moonshot-ai/kimi-code | Patch |
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