Skip to content

fix(agent-core-v2): only send prompt_cache_key to official OpenAI endpoints - #3660

Closed
creatiVision wants to merge 1 commit into
MoonshotAI:mainfrom
creatiVision:fix/v2-prompt-cache-key-gate
Closed

creatiVision wants to merge 1 commit into
MoonshotAI:mainfrom
creatiVision:fix/v2-prompt-cache-key-gate

Conversation

@creatiVision

Copy link
Copy Markdown

Related Issue

Resolves #2166 (NVIDIA NIM: 400 Validation: Unsupported parameter(s): prompt_cache_key). Related: #2611 (Azure Foundry: 400 Unrecognized request argument supplied: prompt_cache_key).

Supersedes and replaces #2240 and #2761, which are closed in favor of this single reconciled branch.

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, Azure Foundry) reject the unknown parameter with HTTP 400, making custom openai / openai_responses providers unusable for agent sessions.

What changed

The field is now only sent when the effective base URL targets the official OpenAI API (api.openai.com or a regional *.api.openai.com variant, or unset → client default):

  • Added isOfficialOpenAIBaseUrl() helper in packages/agent-core-v2/src/human/llm/requester/bases/openai-base-url.ts.
  • Gated the prompt_cache_key fallback behind it in both the OpenAI chat-completions and Responses bases (openai/format.ts, openai-responses/format.ts). A vendor that supports the field on other hosts keeps encoding it via the cacheKey trait hook (e.g. Kimi), which is unaffected.
  • Tests: cache-key.test.ts (official endpoint keeps the key; third-party endpoint omits it) and response-format.test.ts (Responses base omits it for third-party endpoints).

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0c0ae57

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/agent-core-v2 Patch
@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

@creatiVision

Copy link
Copy Markdown
Author

Superseded by #2240 — the same reconciled fix lives on fix/latest-with-prompt-cache. Closing this one.

1 similar comment
@creatiVision

Copy link
Copy Markdown
Author

Superseded by #2240 — the same reconciled fix lives on fix/latest-with-prompt-cache. Closing this one.

@creatiVision
creatiVision deleted the fix/v2-prompt-cache-key-gate branch September 8, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error with models not supporting prompt cache

1 participant