pub struct PromptCachingConfig {
pub enabled: bool,
pub cache_dir: String,
pub max_entries: usize,
pub max_age_days: u64,
pub enable_auto_cleanup: bool,
pub min_quality_threshold: f64,
pub cache_friendly_prompt_shaping: bool,
pub stable_tool_catalog_across_modes: bool,
pub gap_warning_enabled: bool,
pub gap_warning_threshold_secs: Option<u64>,
pub providers: ProviderPromptCachingConfig,
}Expand description
Global prompt caching configuration loaded from vtcode.toml
Fields§
§enabled: boolEnable prompt caching features globally
cache_dir: StringBase directory for local prompt cache storage (supports ~ expansion)
max_entries: usizeMaximum number of cached prompt entries to retain on disk
max_age_days: u64Maximum age (in days) before cached entries are purged
enable_auto_cleanup: boolAutomatically evict stale entries on startup/shutdown
min_quality_threshold: f64Minimum quality score required before persisting an entry
cache_friendly_prompt_shaping: boolEnable prompt-shaping optimizations that improve provider-side cache locality. When enabled, VT Code keeps volatile runtime context at the end of prompt text.
stable_tool_catalog_across_modes: boolKeep the wire tool catalog identical across planning and execution turns (union of both modes’ tools). Planning toggles then do not rewrite the tool prefix. The fail-closed execution gate still blocks mutations during planning.
gap_warning_enabled: boolWarn before a request when the pause since the previous request likely exceeded the provider prompt cache lifetime (advisory only).
gap_warning_threshold_secs: Option<u64>Override for the cache-gap warning threshold in seconds. When unset, a provider-specific default is used (Anthropic 300s, OpenAI 600s).
providers: ProviderPromptCachingConfigProvider specific overrides
Implementations§
Source§impl PromptCachingConfig
impl PromptCachingConfig
Sourcepub fn resolve_cache_dir(&self, workspace_root: Option<&Path>) -> PathBuf
pub fn resolve_cache_dir(&self, workspace_root: Option<&Path>) -> PathBuf
Resolve the configured cache directory to an absolute path
~is expanded to the user’s home directory when available- Relative paths are resolved against the provided workspace root when supplied
- Falls back to the configured string when neither applies
Sourcepub fn is_provider_enabled(&self, provider_name: &str) -> bool
pub fn is_provider_enabled(&self, provider_name: &str) -> bool
Returns true when prompt caching is active for the given provider runtime name.
Sourcepub fn gap_threshold_secs(&self, provider_name: &str) -> Option<u64>
pub fn gap_threshold_secs(&self, provider_name: &str) -> Option<u64>
Resolve the cache-gap warning threshold in seconds for a provider.
Returns None when gap warnings or provider caching are disabled.
Call the model-aware resolver when the active model is known.
Sourcepub fn gap_threshold_secs_for_route(
&self,
provider: &str,
model: &str,
ttl: Option<PromptCacheTtl>,
) -> Option<u64>
pub fn gap_threshold_secs_for_route( &self, provider: &str, model: &str, ttl: Option<PromptCacheTtl>, ) -> Option<u64>
Prefer the lifetime emitted by the route; otherwise preserve model-aware baseline advisories.
Trait Implementations§
Source§impl Clone for PromptCachingConfig
impl Clone for PromptCachingConfig
Source§impl Debug for PromptCachingConfig
impl Debug for PromptCachingConfig
Source§impl Default for PromptCachingConfig
impl Default for PromptCachingConfig
Source§impl<'de> Deserialize<'de> for PromptCachingConfig
impl<'de> Deserialize<'de> for PromptCachingConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for PromptCachingConfig
impl JsonSchema for PromptCachingConfig
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more