pub struct ContextPolicyConfig {
pub compact_at: f64,
pub protect_last_n: usize,
pub judge: bool,
pub judge_timeout_secs: u64,
pub window_tokens: usize,
pub handoff_chars: usize,
}Expand description
[context]: how a request that no longer fits is shortened. The head (first turn) and
the tail (newest turns) stay verbatim; what pays is the middle.
Fields§
§compact_at: f64Share of the model’s window at which a request is compacted, e.g. 0.85. 0 turns the
threshold off, which leaves only an explicit provider.context_budget_tokens as a rail.
protect_last_n: usizeTurns kept verbatim at the tail. 0 is read as 1: the newest turn is never dropped.
judge: boolAsk one model one bounded question about why the dropped turns went the way they did, and take its answer only if every name in it appears in the digest it was written from. Off by default: it is the one part of compaction that spends a provider request.
judge_timeout_secs: u64How long that one call may take before the deterministic handoff ships without it.
window_tokens: usizeThe window to assume when the endpoint advertises none (/props, /v1/models). 0
means assume nothing: a request is never shortened on a guessed window.
handoff_chars: usizeHard cap, in characters, on the compiled handoff that stands in for the dropped middle. A handoff that grows to fill the window would defeat the point of compacting it.
Implementations§
Source§impl ContextPolicyConfig
impl ContextPolicyConfig
Sourcepub fn budget_for(&self, window_tokens: usize) -> usize
pub fn budget_for(&self, window_tokens: usize) -> usize
The budget this policy derives from a window, or 0 when the policy is off.