anthropics / anthropics/claude-agent-sdk-typescript
Agent SDK defaults to 1-hour cache TTL instead of 5-minute
- Vorherrschende Sprache
- Shell
- Sterne
- 1.8k
- Forks
- 226
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
## Description
The Agent SDK appears to have changed its default prompt cache TTL from 5 minutes to 1 hour. All `cache_creation_input_tokens` are now being allocated to `ephemeral_1h_input_tokens` with zero going to `ephemeral_5m_input_tokens`. This was not the previous behavior — it previously used the 5-minute TTL.
This has a significant cost impact since 1h cache writes are **2x base input price** vs **1.25x for 5m writes**.
## Reproduction
```typescript
import { query } from "@anthropic-ai/claude-agent-sdk";
const SYSTEM_PROMPT = "e".repeat(2500); // to trigger cache
async function main() {
const response = query({
prompt: "What is 2 + 2?",
options: {
maxTurns: 1,
systemPrompt: SYSTEM_PROMPT,
model: "sonnet",
},
});
for await (const message of response) {
if (message.type === "result") {
console.log(JSON.stringify(message, null, 2));
}
}
}
main().catch(console.error);
```
### Output
```json
{
"type": "result",
"subtype": "success",
"is_error": false,
"duration_ms": 1598,
"duration_api_ms": 2567,
"num_turns": 1,
"result": "4",
"stop_reason": null,
"session_id": "022cc5a2-5eab-46af-94f4-9fcf58d71c28",
"total_cost_usd": 0.04073925,
"usage": {
"input_tokens": 3,
"cache_creation_input_tokens": 5293,
"cache_read_input_tokens": 13930,
"output_tokens": 5,
"server_tool_use": {
"web_search_requests": 0,
"web_fetch_requests": 0
},
"service_tier": "standard",
"cache_creation": {
"ephemeral_1h_input_tokens": 5293,
"ephemeral_5m_input_tokens": 0
},
"inference_geo": "",
"iterations": [],
"speed": "standard"
},
"modelUsage": {
"claude-haiku-4-5-20251001": {
"inputTokens": 123,
"outputTokens": 86,
"cacheReadInputTokens": 0,
"cacheCreationInputTokens": 0,
"webSearchRequests": 0,
"costUSD": 0.0005530000000000001,
"contextWindow": 200000,
"maxOutputTokens": 32000
},
"claude-sonnet-4-6": {
"inputTokens": 3,
"outputTokens": 5,
"cacheReadInputTokens": 13930,
"cacheCreationInputTokens": 5293,
"webSearchRequests": 0,
"costUSD": 0.04018625,
"contextWindow": 200000,
"maxOutputTokens": 32000
}
}
}
```
All 5,293 cache creation tokens go to `ephemeral_1h_input_tokens` with zero in `ephemeral_5m_input_tokens`. The developer has no control over this — the SDK makes this choice internally.
## Expected behavior
- The default cache TTL should remain **5 minutes** (as documented in the [prompt caching docs](https://platform.claude.com/docs/en/build-with-claude/prompt-caching): _"By default, the cache has a 5-minute lifetime"_)
- OR there should be an explicit configuration option to control the cache TTL (e.g. `cacheTTL: "5m" | "1h"`) so developers can choose based on their use case
## Environment
- `@anthropic-ai/claude-agent-sdk`: latest
- Model: `claude-sonnet-4-6`
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.