一键导入
cline-openai-cache-key
Cline OpenAI native provider sends no prompt_cache_key. Add a stable per-task key so cached_tokens stops being zero.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Cline OpenAI native provider sends no prompt_cache_key. Add a stable per-task key so cached_tokens stops being zero.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Aider uses 5min TTL by default and works around long pauses with keepalive pings. Wire up the 1h TTL beta instead.
Aider's --cache-prompts is off by default. Flip it on for supported models.
Stop Cline from burning a cache breakpoint on the volatile current user message every turn.
Cline's system prompt includes a timestamp that may be recomputed per request, invalidating the system-prompt cache.
Continue's prompt caching is opt-in via config and off by default. Flip the default to systemAndTools.
Continue inherits the Cline-family volatile-message cache bug. Same fix shape.
| name | cline-openai-cache-key |
| description | Cline OpenAI native provider sends no prompt_cache_key. Add a stable per-task key so cached_tokens stops being zero. |
| target_harness | Cline |
| target_repo | cline/cline |
| target_files | ["src/core/api/providers/openai-native.ts"] |
| target_commit | 65e9727c (verify current at apply time) |
| estimated_savings | 50-90% input discount on OpenAI calls (currently 0%) |
prompt_cache_key to OpenAI native providersrc/core/api/providers/openai-native.ts in cline/cline.
Permalink: https://github.com/cline/cline/blob/65e9727c/src/core/api/providers/openai-native.ts
Cline's OpenAI native provider only READS cache stats from responses, it never enables caching:
const cacheReadTokens = usage?.prompt_tokens_details?.cached_tokens || 0
const cacheWriteTokens = 0 // ← always 0
No prompt_cache_key set on the Responses API call, no work done to
verify prefix stability. OpenAI's automatic prefix caching may still
fire if the prefix happens to be byte-stable, but routing is random
across pods so hit rates are low and unpredictable.
Open issue #554 ("OpenAI Prompt Caching appears not enabled?") tracks user-side confusion. PR #1156 attempted a partial fix but was closed without merging.
Set a stable prompt_cache_key derived from the task ID (or a hash of
the system instructions if no task ID is available). NEVER use a
per-request UUID — that's worse than no key.
--- a/src/core/api/providers/openai-native.ts
+++ b/src/core/api/providers/openai-native.ts
@@
- const response = await client.responses.create({
+ // Stable cache key: same task = same pod = warm cache.
+ // NEVER use uuid() — random keys force random pod routing and
+ // kill cache hits.
+ const cacheKey = this.options.taskId
+ || this.options.ulid
+ || crypto.createHash("sha256")
+ .update(systemPrompt)
+ .digest("hex")
+ .slice(0, 16)
+
+ const response = await client.responses.create({
model: modelId,
input: messages,
+ prompt_cache_key: `cline:${modelId}:${cacheKey}`,
...
})
If the harness uses the legacy Chat Completions endpoint
(client.chat.completions.create), prompt_cache_key isn't a valid
field there. In that case the only knob is prefix stability — make
sure the system prompt has no per-request timestamps, session IDs, or
randomized content.
gpt-5.4, gpt-5-codex, etc.).prompt_cache_key field present and identical across bothusage.prompt_tokens_details.cached_tokens > 0cached_tokens / prompt_tokens ≥ 0.5 on a steady-state turnOpenAI's Responses API uses prompt_cache_key as a pod-routing hint.
Stable key = same pod = warm cache. Per-request UUIDs are the #1
silent killer of OpenAI cache hits.
See docs/gotchas.md #9b for the full
explanation, and docs/concepts/openai.md
"The prompt_cache_key trick".
Reference implementation: Codex CLI uses session thread_id as the
cache key and preserves it across compaction and sub-agents — see
audits/codex-cli.md.
Full audit: audits/cline.md.