Repository navigation
Prompt cache
English | 简体中文
This page explains how the plugin keeps OpenAI's prompt cache warm across a DSH conversation, what has been measured, and what is still unproven. It matters because the plan route runs with store: false: every request re-sends the whole conversation, so the cache decides whether long sessions are practical.
This section lists the five things the request builder does to keep the request prefix identical from turn to turn.
-
A stable cache key.
prompt_cache_keyis the DSH session id. An id longer than 64 characters is replaced by its SHA-256 hex digest, not cut, so the key is still stable. -
The same key as a request header. When there is a session id, the request also carries a
session-idheader with exactly the value ofprompt_cache_key. Without a session id, neither is sent. The code treats the header as an affinity hint; see What is not proven for what is and is not known about it. -
The system prompt stays where it was. Only the system messages at the very start of the conversation become
instructions. A system message that appears later becomes adeveloperinput item at its position. The adapter declaressystemPromptUpdate: 'in-history'to DSH, so when the system prompt changes, DSH appends the change in the history instead of rewriting the first message, which would invalidate the entire cached prefix. -
Reasoning is replayed, not redone. When a reasoning effort other than
noneis in effect, the request asks forreasoning.encrypted_content. Each completed reasoning item is kept on the DSH message and sent back before its tool call on later turns. It is replayed only when its replay key matches the current account and model:sha256(JSON [client_id, subject, model]), first 32 hex characters. The key holds no token or email. If no effort is set, no encrypted reasoning is requested and nothing is replayed. -
Nothing else enters the body. Catalog metadata,
serviceTier(when it resolves todefault),contextBudget,modelOverrides,includeHiddenModels, and usage telemetry never changeinstructionsorinput. A test builds the same conversation under all of those changes and requires byte-identical request bodies;service_tier: "priority"is the only field that may differ. Forty golden fixtures pin the exact request bytes and stream chunks.
prompt_cache_key = sessionId (sha256 hex when longer than 64 chars)
session-id header = prompt_cache_key
replay key = sha256(JSON [client_id, subject, model]).slice(0, 32)
instructions = leading system messages only; later ones become developer items in place
This section shows where to see the cache working on your account.
The card's account panel has a Local spend meter: requests, input, cached-read, and output tokens that OpenAI reported to this plugin, recorded locally. It shows Cache hit as:
cache hit % = cacheReadTokens / (inputTokens + cacheReadTokens)
inputTokens here is the uncached part: the plugin subtracts cached tokens from the raw input count before reporting usage to DSH. The meter is a local record of what this app spent, not your remaining plan budget; the card links to ChatGPT's Manage usage for that.
This section records every measurement that exists for this plugin, with its conditions, date, and source.
Live DSH sessions (recorded 2026-12-02 by the maintainer, in the 2.2.0 changelog and the repository's CONTEXT.md; the session logs themselves are not published):
| Session | Total tokens | Cached | Uncached | Cached share |
|---|---|---|---|---|
| A | 10,353,568 | not recorded | not recorded | not verifiable: the record gives a rate of 98% with no cached or uncached breakdown |
| B | 17,641,483 | 17,071,616 | 491,419 | 96.8% (17,071,616 of 17,641,483) |
For session B, cached plus uncached is 17,563,035, which falls 78,448 short of the recorded total. Nothing in the record explains the gap, so the breakdown is incomplete and 96.8% is stated against the recorded total. The changelog rounds this session to 97% and session A to 98%; neither rounding is backed by a full breakdown.
Mid-session switch probe (scripts/probe-v220.mjs, not shipped in the npm package; run 2026-12-02 23:43 UTC). One conversation with a fixed session-id and prompt_cache_key, a static prefix of 23,546 characters (10,661 system, 12,885 user), and 10 seconds between turns:
| Turn | Model | Tier sent | Input tokens | Cached | Hit | Latency |
|---|---|---|---|---|---|---|
| 1 | gpt-6.2-astra |
default | 4,135 | 0 | cold start | 2,075 ms |
| 2 | gpt-6.2-astra |
default | 4,159 | 2,176 | 52.32% | 1,458 ms |
| 3 | gpt-6.2-astra |
priority | 4,183 | 0 | cold | 1,842 ms |
| 4 | gpt-6.2-sol |
default | 4,207 | 0 | cold | 1,212 ms |
Reading: the second identical-prefix turn hit the cache; changing service_tier or the model put that turn on a cold cache. Turn 3 also completed as default (see below). The probe writes a redacted JSON report to /tmp/siwc-v220-probe-report.json on the machine that ran it; that report is not in the repository.
Independent benchmark. Kogen Bench round chatgpt-session-cache-1 (2026-10-25, a different client on the same api.openai.com/v1/responses plan route) sent a synthetic 8-turn conversation in several request shapes. With the body key only, the median cached share was 0.00 in 6 of 6 runs; with a session_id header, 0.91 to 0.98 in 6 of 6 runs on two models. Source: bench.kogen.dev/rounds/chatgpt-session-cache-1. That round used the header spelling session_id; this plugin sends session-id.
Offline tests. tests/prompt-cache.test.ts checks the key, the header, the in-place system prompt, the in-history declaration, encrypted reasoning round-tripping through DSH's own message assembler, and the byte-identical body under configuration changes.
This section records the one live test of service_tier: "priority", because the result does not yet show the tier being applied.
On 2026-12-02 23:43 UTC, one request to gpt-6.2-astra (whose catalog lists priority) with service_tier: "priority" returned HTTP 200 in 1,391 ms with 11 input, 0 cached, and 5 output tokens. The response.created event reported service_tier: "auto" and response.completed reported service_tier: "default". The response carried x-codex-safety-buffering-enabled: true and x-codex-safety-buffering-faster-model: gpt-6-luna.
So the request is sent as designed and accepted, but this run does not show that the plan applied the Fast tier.
This section lists the open questions plainly, so the numbers above are not read as more than they are.
-
The Fast tier. The one live probe completed as
default. Whether priority is ever honored on the plan route is unconfirmed. -
Header spelling. The plugin's live sessions show high hit rates with the
session-idheader. The independent benchmark testedsession_id. Whether OpenAI treats the two spellings identically has not been tested separately. - Cause. There is no with-header and without-header comparison run through this plugin. The live sessions show the combined effect of all five mechanisms.
- Session A detail. Only the total and the rate were recorded, so its 98% cannot be checked.
- Session B gap. Cached plus uncached falls 78,448 tokens short of the recorded total, and nothing explains the difference.
- Comparison with the Codex CLI. A same-task A/B against the Codex CLI has not been run, so no comparison is claimed.
- Plan accounting. How the plan's usage meter weighs cached tokens is not measured here. The independent benchmark's attempt at it was inconclusive.
dsh-chatgpt-siwc
English
- Home
- Install
- Sign-in and accounts
- Configuration
- Models and catalog
- Prompt cache
- Route and compliance
- Architecture
- CLI and doctor
- Troubleshooting
- FAQ
- Changelog
- Contributing
简体中文