Skip to content

Commit 29f5b8b

Browse files
committed
Raise stale-costly defaults to 100k tokens / 60 min
Bump DEFAULT_STALE_COSTLY_THRESHOLD from 40k/5min to 100k/60min: - tokens 100k: ~10% of the 1M context window, so the warning only fires when a cold prefix rebuild is a genuine cost (40k was ~$0.25 at Opus rates — too small to warrant a dialog). - staleMs 60 min: the 5-minute value was the *default* ephemeral TTL, but the 1-hour opt-in TTL may be in effect (the Agent SDK decides, and we don't observe it). Using the longer bound means we only warn once the cache is almost certainly cold, avoiding false-positive nags while a still-warm cache makes continuation cheap. Also corrects the misleading "5-minute TTL" doc comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RkLQSsdj7o4wQjcmjM1SD1
1 parent 199a7fc commit 29f5b8b

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

packages/core/src/sessions/contextUsage.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,22 +119,31 @@ export interface StaleCostlyThreshold {
119119
/** Minimum context tokens for a conversation to count as "large". */
120120
tokens: number;
121121
/**
122-
* Minimum idle time (ms) before a conversation counts as "stale". Set to
123-
* roughly the Anthropic prompt-cache TTL: once the cache expires, the next
124-
* turn re-processes the whole prefix at full input price instead of the
125-
* ~10% cached-read rate.
122+
* Minimum idle time (ms) before a conversation counts as "stale" — set at or
123+
* above the prompt-cache TTL so that, once exceeded, the cache is expired and
124+
* the next turn re-processes the whole prefix at full input price instead of
125+
* the ~10% cached-read rate.
126126
*/
127127
staleMs: number;
128128
}
129129

130130
/**
131-
* Defaults for the stale-costly conversation warning: a conversation large
132-
* enough that a cold cache rebuild is noticeable, left idle past the default
133-
* 5-minute prompt-cache TTL.
131+
* Defaults for the stale-costly conversation warning.
132+
*
133+
* `tokens` (100k): only conversations big enough that a cold prefix rebuild is
134+
* a real cost — roughly 10% of the 1M context window — trip the warning.
135+
*
136+
* `staleMs` (60 min): Anthropic ephemeral caches default to a 5-minute TTL and
137+
* can opt into a 1-hour one; the effective value depends on what the Agent SDK
138+
* requests, which we don't control or observe. We deliberately use the longer
139+
* 1-hour bound so the cache is almost certainly cold before we warn — warning
140+
* while it is still warm would nag about a continuation that is in fact cheap,
141+
* the worse failure. Erring long only means we occasionally skip a warning,
142+
* never that we nag needlessly.
134143
*/
135144
export const DEFAULT_STALE_COSTLY_THRESHOLD: StaleCostlyThreshold = {
136-
tokens: 40_000,
137-
staleMs: 5 * 60 * 1000,
145+
tokens: 100_000,
146+
staleMs: 60 * 60 * 1000,
138147
};
139148

140149
/**

0 commit comments

Comments
 (0)