pub struct ModelContextLimits {
pub provider: String,
pub model: String,
pub context_window: u64,
pub max_completion_tokens: u64,
pub recommended_completion_tokens: u64,
pub source: ModelLimitSource,
pub confidence: ModelLimitConfidence,
}Expand description
Provider-neutral model context limits.
Adapters translate provider-specific metadata into this shape so the ledger
stays free of provider-client types. See ModelContextLimits::resolve.
Fields§
§provider: StringProvider label (e.g. "umans", "opencode-go").
model: StringModel id as selected by the user (e.g. "umans-coder").
context_window: u64Total context window in tokens (input + output).
max_completion_tokens: u64Maximum completion tokens the model accepts.
recommended_completion_tokens: u64Recommended completion tokens for typical turns.
source: ModelLimitSourceWhere the limits came from.
confidence: ModelLimitConfidenceHow trustworthy the limits are.
Implementations§
Source§impl ModelContextLimits
impl ModelContextLimits
Sourcepub fn available_input_budget(&self) -> u64
pub fn available_input_budget(&self) -> u64
Available input budget = context window minus reserved completion budget and provider overhead.
Selection targets TARGET_BUDGET_RATIO of this value.
Auto-compaction may trigger above AUTO_COMPACTION_RATIO.
Sourcepub fn target_budget(&self) -> u64
pub fn target_budget(&self) -> u64
Token budget the selection policy targets (80% of available input).
Sourcepub fn auto_compaction_threshold(&self) -> u64
pub fn auto_compaction_threshold(&self) -> u64
Token budget above which auto-compaction may trigger (92% of available input).
Sourcepub fn resolve(
provider: &str,
model: &str,
override_entry: Option<ModelLimitOverride>,
live: Option<&LiveModelMetadata>,
) -> (ModelContextLimits, Vec<ContextDiagnostic>)
pub fn resolve( provider: &str, model: &str, override_entry: Option<ModelLimitOverride>, live: Option<&LiveModelMetadata>, ) -> (ModelContextLimits, Vec<ContextDiagnostic>)
Resolve limits from candidate sources in precedence order: user override → live metadata → static provider metadata → fallback.
Returns the chosen limits plus diagnostics for invalid overrides and fallback usage.
Trait Implementations§
Source§impl Clone for ModelContextLimits
impl Clone for ModelContextLimits
Source§fn clone(&self) -> ModelContextLimits
fn clone(&self) -> ModelContextLimits
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more