auto session-reset: fix default cache TTL to 1h, clarify state-preservation purpose

This commit is contained in:
damocles 2026-05-20 14:32:20 +02:00 committed by Mara
parent 44c903f265
commit fb951c1004

View file

@ -55,20 +55,25 @@ const RATE_LIMIT_MARKERS: &[&str] = &[
const DEFAULT_RATE_LIMIT_SLEEP_SECS: u64 = 300; const DEFAULT_RATE_LIMIT_SLEEP_SECS: u64 = 300;
/// Token watermark for *auto session-reset*. When context is at or above this /// Token watermark for *auto session-reset*. When context is at or above this
/// many tokens AND the prompt cache has gone cold (idle time ≥ `CACHE_TTL_SECS`), /// many tokens AND the prompt cache has gone cold (idle time >= `CACHE_TTL_SECS`),
/// the harness runs a notes-checkpoint turn then drops `--continue` so the /// the harness runs a notes-checkpoint turn (so the agent can persist state)
/// next turn starts fresh. Sending a large context uncached costs the same as /// then drops `--continue` so the next turn starts with a clean, compact
/// a fresh start; the reset avoids paying for a long history the model won't /// context. The checkpoint re-uploads the full transcript either way, so the
/// benefit from. Default is ~50% of a 200k-token window; override via /// purpose is state preservation (not cost savings). Default is ~50% of a
/// `HIVE_AUTO_RESET_WATERMARK_TOKENS`, or set to `0` to disable. /// 200k-token window; override via `HIVE_AUTO_RESET_WATERMARK_TOKENS`, or set
/// to `0` to disable.
const DEFAULT_AUTO_RESET_WATERMARK_TOKENS: u64 = 100_000; const DEFAULT_AUTO_RESET_WATERMARK_TOKENS: u64 = 100_000;
/// Assumed prompt-cache TTL. Claude's API caches prompt prefixes for ~5 /// Assumed prompt-cache TTL. Claude caches prompt prefixes — ~5 minutes on
/// minutes; after that the prefix must be re-uploaded on the next turn. /// the API (pay-per-token), ~1 hour on Claude Max (subscription). When the
/// When the idle gap exceeds this, a large context costs the same whether /// idle gap exceeds this, the cache prefix has likely expired and the next
/// we resume or start fresh — so we start fresh. Override via /// turn re-uploads the full transcript regardless of whether we resume or
/// `HIVE_CACHE_TTL_SECS`. /// start fresh. A fresh session with a small context is therefore just as
const DEFAULT_CACHE_TTL_SECS: u64 = 300; /// cheap AND gives the model a clean slate. Default is 3600s (1h) matching
/// the subscription TTL. API (pay-per-token) users should set
/// `HIVE_CACHE_TTL_SECS=300` to match their shorter cache window. Override
/// via `HIVE_CACHE_TTL_SECS`; set to `0` to disable (always resume).
const DEFAULT_CACHE_TTL_SECS: u64 = 3600;
/// Synthetic checkpoint prompt injected before an auto-reset turn. Unlike the /// Synthetic checkpoint prompt injected before an auto-reset turn. Unlike the
/// proactive-compaction checkpoint (which is followed by `/compact`), this one /// proactive-compaction checkpoint (which is followed by `/compact`), this one
@ -77,8 +82,8 @@ const DEFAULT_CACHE_TTL_SECS: u64 = 300;
const AUTO_RESET_CHECKPOINT_PROMPT: &str = const AUTO_RESET_CHECKPOINT_PROMPT: &str =
"[system] Context checkpoint before session auto-reset — no inbox message to handle.\n\n\ "[system] Context checkpoint before session auto-reset — no inbox message to handle.\n\n\
The harness detected that the prompt-cache TTL has elapsed while your context is large. \ The harness detected that the prompt-cache TTL has elapsed while your context is large. \
Resuming with --continue would re-upload the full transcript uncached; starting a fresh \ The session will be reset after this turn so you start the next message with a clean, \
session is cheaper and equally effective since the cache is already cold.\n\n\ compact context instead of a long accumulated transcript.\n\n\
Use THIS turn to flush anything worth keeping into your durable state files: update \ Use THIS turn to flush anything worth keeping into your durable state files: update \
your notes / TODO.md with in-flight task state, open questions, important paths, and \ your notes / TODO.md with in-flight task state, open questions, important paths, and \
anything else you would need to resume cleanly from a fresh session. Do not start \ anything else you would need to resume cleanly from a fresh session. Do not start \