Skip to content

docs: document promptCacheKey for custom openai-chat providers (#2541) - #2625

Merged
lidge-jun merged 5 commits into
devfrom
codex/2541-prompt-cache-key-docs
Aug 25, 2026
Merged

lidge-jun merged 5 commits into
devfrom
codex/2541-prompt-cache-key-docs

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Aug 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Carries #2541 by @wssfk12138 onto dev with one factual correction, plus the privacy:scan fix the gate needs.

The correction

The submitted prose said opencodex never generates the key. That is true of the adapter and false of the request path. Claude Messages translation derives a prompt_cache_key from metadata.user_id (src/claude/inbound.ts:523-531), or from a model/system/tools cohort when the client sends no metadata (:532-552) — because the OpenAI backends report cached_tokens: 0 on every keyless turn, which is the whole reason that code exists.

That matters for the reader this page is written for: someone who enables the option, sees a prompt_cache_key they never sent, and goes looking for a bug. The docs now say what actually holds — the adapter forwards the key it is given and never invents one, but the key is not always the caller's.

Everything else in the PR checked out against the code: the config field, the opt-in default, the reload requirement, and the HTTP 400 hazard for strict gateways.

The privacy:scan fix

bun run privacy:scan is a CI gate and it is red on dev — the per-account quota example added in #2587 carries two real-looking addresses, one on a real domain. This PR could not be verified green without fixing it, so the masking is carried here: the local part was already elided, so the domain is elided the same way. Masking rather than swapping in example.com keeps it passing on its own terms instead of relying on a domain the regex happens not to match.

Verification

bun run privacy:scan            Privacy scan passed
cd docs-site && bun run build   393 page(s) built, Complete!
bun x tsc --noEmit              exit 0

Reviewed claim-by-claim against the implementing source; the reviewer also confirmed the seven translated locale guides retain deny-by-default wording and do not contradict the English source.

Checklist

  • Targets dev
  • Every added claim checked against the code that implements it
  • privacy:scan green
  • No credential leakage; the only key in the examples is a ${EXAMPLE_API_KEY} placeholder

Closes #2541.

Summary by CodeRabbit

  • New Features

    • Added optional prompt caching configuration for custom OpenAI-compatible providers.
    • Documented how cache keys are forwarded or derived, along with validation guidance and troubleshooting for incompatible upstreams.
  • Documentation

    • Updated provider configuration reference with the disabled-by-default caching option.
    • Redacted email domains and usernames in OAuth account examples.

wssfk12138 and others added 5 commits August 25, 2026 15:57
Carries wssfk12138's docs onto dev with one factual correction and the
privacy:scan fix the gate needs.

The submitted prose said opencodex never generates the key. That is true of the
adapter and false of the request path: Claude Messages translation derives a
prompt_cache_key from metadata.user_id (claude/inbound.ts:523-531), or from a
model/system/tools cohort when the client sends none (:532-552), because the
OpenAI backends report cached_tokens:0 for every keyless turn. A reader
debugging an unexpected key would have been sent the wrong way. Reworded to say
what actually holds: the adapter forwards and never invents, but the key is not
always the caller's.

Also carries the providers-accounts.md example masking, because privacy:scan is
red on dev and this PR cannot be verified green without it.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner August 25, 2026 20:53
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@lidge-jun
lidge-jun merged commit 6f3b5af into dev Aug 25, 2026
11 of 12 checks passed
@lidge-jun
lidge-jun deleted the codex/2541-prompt-cache-key-docs branch August 25, 2026 20:54
@coderabbitai

coderabbitai Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 18711d28-cfb6-4b88-ab9b-72a5e137a736

📥 Commits

Reviewing files that changed from the base of the PR and between 0523239 and 17c6f63.

📒 Files selected for processing (3)
  • docs-site/src/content/docs/guides/providers.md
  • docs-site/src/content/docs/reference/cli/providers-accounts.md
  • docs-site/src/content/docs/reference/configuration/providers.md

📝 Walkthrough

Walkthrough

The documentation adds optional promptCacheKey configuration guidance for custom openai-chat providers, including Claude Messages key derivation and upstream compatibility. The OAuth account listing now uses more strongly redacted sample email addresses.

Changes

Prompt cache key documentation

Layer / File(s) Summary
Prompt cache key configuration guidance
docs-site/src/content/docs/reference/configuration/providers.md, docs-site/src/content/docs/guides/providers.md
Documents the optional promptCacheKey setting, forwarding behavior, Claude Messages key derivation, validation steps, and possible upstream HTTP 400 responses.

OAuth example redaction

Layer / File(s) Summary
Redacted OAuth account examples
docs-site/src/content/docs/reference/cli/providers-accounts.md
Updates sample OAuth account rows with redacted domains and usernames.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: ingwannu, luvs01

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/2541-prompt-cache-key-docs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 25, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17c6f63daa

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +147 to +151
The adapter forwards the key it is given and never invents one. It can still receive a key the
caller did not send: Claude Messages translation derives one from `metadata.user_id`, or from a
model/system/tools cohort when the client sends no metadata, because the OpenAI backends report
`cached_tokens: 0` for every keyless turn. So "forwarded, not fabricated" describes this adapter,
not the whole request path.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reconcile the Kimi key-generation guidance

For Claude Messages requests routed to either canonical Kimi preset, src/claude/inbound.ts derives a key and the promptCacheKey: true registry entries forward it, so the immediately preceding claim that Kimi receives only caller-supplied keys and that keyless requests remain keyless is false; the seven translated provider guides repeat that claim as well. Revise the Kimi paragraph and its translations to distinguish adapter behavior from the complete request path, rather than leaving this new qualification contradicting them.

AGENTS.md reference: docs-site/AGENTS.md:L8-L9

Useful? React with 👍 / 👎.

Comment on lines +148 to +149
caller did not send: Claude Messages translation derives one from `metadata.user_id`, or from a
model/system/tools cohort when the client sends no metadata, because the OpenAI backends report

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge State the system-prompt condition for cohort keys

For a valid Claude Messages request with neither metadata.user_id nor a system message, translation does not derive a cohort key: anthropicToResponsesTranslation gates this branch on systemParts.length > 0, and the no-metadata/no-system regression test expects prompt_cache_key to remain absent. Qualify this sentence with the system-prompt requirement so users do not expect every metadata-free request to receive a generated key.

AGENTS.md reference: docs-site/AGENTS.md:L7-L8

Useful? React with 👍 / 👎.

tarunravi pushed a commit to tarunravi/opencodex that referenced this pull request Sep 14, 2026
…-jun#2541) (lidge-jun#2625)

* docs: document promptCacheKey for custom providers

* docs: clarify prompt cache validation steps

* docs: clarify prompt cache validation prerequisite

* docs: document promptCacheKey for custom openai-chat providers (lidge-jun#2541)

Carries wssfk12138's docs onto dev with one factual correction and the
privacy:scan fix the gate needs.

The submitted prose said opencodex never generates the key. That is true of the
adapter and false of the request path: Claude Messages translation derives a
prompt_cache_key from metadata.user_id (claude/inbound.ts:523-531), or from a
model/system/tools cohort when the client sends none (:532-552), because the
OpenAI backends report cached_tokens:0 for every keyless turn. A reader
debugging an unexpected key would have been sent the wrong way. Reworded to say
what actually holds: the adapter forwards and never invents, but the key is not
always the caller's.

Also carries the providers-accounts.md example masking, because privacy:scan is
red on dev and this PR cannot be verified green without it.

---------

Co-authored-by: wssfk12138 <79346097+wssfk12138@users.noreply.github.com>
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
…-jun#2541) (lidge-jun#2625)

* docs: document promptCacheKey for custom providers

* docs: clarify prompt cache validation steps

* docs: clarify prompt cache validation prerequisite

* docs: document promptCacheKey for custom openai-chat providers (lidge-jun#2541)

Carries wssfk12138's docs onto dev with one factual correction and the
privacy:scan fix the gate needs.

The submitted prose said opencodex never generates the key. That is true of the
adapter and false of the request path: Claude Messages translation derives a
prompt_cache_key from metadata.user_id (claude/inbound.ts:523-531), or from a
model/system/tools cohort when the client sends none (:532-552), because the
OpenAI backends report cached_tokens:0 for every keyless turn. A reader
debugging an unexpected key would have been sent the wrong way. Reworded to say
what actually holds: the adapter forwards and never invents, but the key is not
always the caller's.

Also carries the providers-accounts.md example masking, because privacy:scan is
red on dev and this PR cannot be verified green without it.

---------

Co-authored-by: wssfk12138 <79346097+wssfk12138@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants