Skip to main content

ModelContextLimits

Struct ModelContextLimits 

Source
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: String

Provider label (e.g. "umans", "opencode-go").

§model: String

Model id as selected by the user (e.g. "umans-coder").

§context_window: u64

Total context window in tokens (input + output).

§max_completion_tokens: u64

Maximum completion tokens the model accepts.

§recommended_completion_tokens: u64

Recommended completion tokens for typical turns.

§source: ModelLimitSource

Where the limits came from.

§confidence: ModelLimitConfidence

How trustworthy the limits are.

Implementations§

Source§

impl ModelContextLimits

Source

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.

Source

pub fn target_budget(&self) -> u64

Token budget the selection policy targets (80% of available input).

Source

pub fn auto_compaction_threshold(&self) -> u64

Token budget above which auto-compaction may trigger (92% of available input).

Source

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

Source§

fn clone(&self) -> ModelContextLimits

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ModelContextLimits

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ModelContextLimits

Source§

impl PartialEq for ModelContextLimits

Source§

fn eq(&self, other: &ModelContextLimits) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ModelContextLimits

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.