aider-1h-ttl
Aider uses 5min TTL by default and works around long pauses with keepalive pings. Wire up the 1h TTL beta instead.
Cline's system prompt includes a timestamp that may be recomputed per request, invalidating the system-prompt cache.
$ npx -y skills add OnlyTerp/prompt-cache-skills --skill cline-pin-timestamp --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/cline-pin-timestampContext preview
The summary Claude sees to decide when to auto-load this skill.
Cline's system prompt includes a timestamp that may be recomputed per request, invalidating the system-prompt cache.
name: cline-pin-timestamp description: Cline's system prompt includes a timestamp that may be recomputed per request, invalidating the system-prompt cache. target_harness: Cline target_repo: cline/cline target_files: - src/core/prompts/system.ts target_commit: 65e9727c (verify current at apply time) estimated_savings: Restores system-prompt cache reads (large; system prompt is typically 5-15k tokens)
`src/core/prompts/system.ts` in `cline/cline`. PR #1168 added a current-time field to the system prompt.
The system prompt includes the current time. If the time is computed per-request (e.g. `new Date().toISOString()` evaluated at every call site), then the system prompt bytes differ on every request, which invalidates the system-prompt cache breakpoint. The cache write premium gets paid every turn for zero reads, on what's usually the largest single block in the prefix.
PR #1168 was merged despite a reviewer flagging exactly this: > "Just be aware that if the time is being calculated every time the > user sends a request, it invalidates Anthropic's cache."
Verify on the wire: if the system text changes between consecutive calls in the same task, this bug is present.
Compute the timestamp ONCE at task start, store it on the task, pass through to every system prompt build:
--- a/src/core/prompts/system.ts
+++ b/src/core/prompts/system.ts
@@
-export const SYSTEM_PROMPT = (...args) => `
- ...
- Current time: ${new Date().toISOString()}
- ...
-`
+export const SYSTEM_PROMPT = (args: SystemPromptArgs) => `
+ ...
+ Current time: ${args.taskStartedAt}
+ ...
+`Then in the task initialization code:
+ this.taskStartedAt = new Date().toISOString()
And pass `this.taskStartedAt` everywhere `SYSTEM_PROMPT` is built.
If date awareness is critical for the agent and you want it to drift during a long session, round to the nearest day or hour rather than the second — that bounds the cache invalidation rate.
1. Start mitmproxy. 2. Run a Cline task. Wait 10 seconds. Send a second prompt in the same task. 3. Diff the system prompt bytes between the two requests.
4. Confirm response `usage.cache_read_input_tokens` covers the system prompt on turn 2.
Anthropic caches the entire prefix UP TO AND INCLUDING the breakpoint. A single byte change before or at the breakpoint invalidates everything. Timestamps are the most common cache killer because they look innocent and few people think to check.
OpenAI's automatic prefix caching has the same vulnerability — same fix applies if Cline targets OpenAI as well.
See [docs/gotchas.md](../../docs/gotchas.md) #5 (byte-identity of tool definitions, same principle for system prompts) and #7 (OpenAI byte-identical prefix requirement).
Full audit: [audits/cline.md](../../audits/cline.md).
Drop-in prompt-caching fixes for the LLM agent harness you use. Point your AI coding agent at this repo and it ships the patches.
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.
Ladder-aware Cline Anthropic caching — verify the rolling read/write ladder on the wire, then add the tools breakpoint and tune…
Cline OpenAI native provider sends no prompt_cache_key. Add a stable per-task key so cached_tokens stops being zero.
Continue's prompt caching is opt-in via config and off by default. Flip the default to systemAndTools.
Ladder-aware Continue Anthropic caching — verify the rolling ladder on the wire, then enable it by default and add TTL coverage.