#[non_exhaustive]pub enum CacheHint {
None,
StablePrefix {
key: Option<String>,
},
}Expand description
Provider-agnostic hint about caching a request’s stable prefix.
A multi-step turn re-sends a growing conversation behind an unchanging prefix — the system text plus the tool-spec block (built once per turn). This hint marks that prefix as stable so a provider that supports prompt caching can cache it and skip re-processing it on every step, the single biggest latency lever on multi-step turns. It is purely advisory: a provider maps it to its native mechanism, and a provider with no caching ignores it with no behavior change.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
None
No caching is requested; a provider processes the full prompt on every call. The default so auxiliary calls that bypass the answering loop never opt in accidentally.
StablePrefix
The request’s leading stable prefix (system text + tool-spec block) stays byte-identical across the steps of a turn — and across turns of a conversation — so a provider that supports prompt caching should cache it.
Implementations§
Source§impl CacheHint
impl CacheHint
Sourcepub fn from_key(key: String) -> Self
pub fn from_key(key: String) -> Self
Reconstructs a hint from its flat single-string form: a non-empty key
is a keyed CacheHint::StablePrefix; an empty one is
CacheHint::None. The inverse of Self::key — together they carry
the hint across a boundary that has one string field (the control-plane
→ harness turn input), which cannot express a keyless stable-prefix
hint (the control plane always keys by conversation).
Sourcepub fn key(&self) -> Option<&str>
pub fn key(&self) -> Option<&str>
The cache-routing key this hint carries, if any. See Self::from_key
for the flat form the pair round-trips.