pub struct ModelContext {
pub capabilities: ModelCapabilities,
pub tags: Vec<String>,
pub dialect: Option<DialectSpec>,
pub inference_defaults: Option<InferenceConfig>,
pub defaults_origin: Option<DefaultsOrigin>,
pub context_length: Option<u64>,
pub template_caps: Option<TemplateCaps>,
pub catalog_resolved: bool,
}Expand description
Everything a request pipeline needs to know about the target model, gathered in a single catalog round-trip.
The fields feed the resolution and shaping stages, which is why they travel together rather than being looked up where each is needed:
capabilities— request-side transforms (strict-turn coalescing and friends).dialect— response-stream parser selection and decode-time grammar origination.tags— the sampling floor (via thereasoningtag) and launch narration.inference_defaults— the per-model layer of the sampling hierarchy.defaults_origin— which runginference_defaultsoccupies in that hierarchy.context_length— the history-truncation budget.
Before this type was shared, the proxy resolved all of them while every
other surface resolved the same row and kept only tags, so capability
coalescing and per-model defaults were unreachable outside the proxy.
Fields§
§capabilities: ModelCapabilitiesStored capability bitfield — drives request-side transforms.
The model’s tags — the sampling floor (reasoning) and narration.
dialect: Option<DialectSpec>Resolved tool-call dialect — drives response-stream parser selection and decode-time grammar origination.
Populated from the model’s persisted spec when one exists, else from
the format:* tag fallback (see From<&ModelSummary>); None
selects the identity passthrough parser.
inference_defaults: Option<InferenceConfig>Per-model inference defaults to merge into each request.
defaults_origin: Option<DefaultsOrigin>Whether inference_defaults was set by
the user or auto-detected. See DefaultsOrigin.
context_length: Option<u64>Maximum context the model supports, in tokens — the history-truncation budget for every surface that cannot measure a live serving context.
template_caps: Option<TemplateCaps>llama-server’s template-capability self-report, when a launch has recorded one (ADR 0007).
None — on a passthrough context or a resolved row nobody has
launched yet — means “never observed”, which per decision 3 licenses
nothing: unknown never gates. Nothing consumes this yet; the effort
gate arrives in a later PR of the arc.
catalog_resolved: boolWhether this context came from an actual catalog row.
false for passthrough — the fallback for
unknown or unresolvable models. Transforms that act on the absence
of a capability (tool stripping) must check this: an empty bitfield on
a passthrough context means “nobody knows”, not “the model can’t”.
Implementations§
Source§impl ModelContext
impl ModelContext
Sourcepub fn passthrough() -> Self
pub fn passthrough() -> Self
The zeroed context: empty capabilities so every transform is a no-op, empty tags so the identity passthrough parser is selected, no per-model defaults, and no truncation budget.
This is the conservative fallback used whenever the model cannot be resolved — an unresolvable model must never block a request, only lose its model-specific handling.
Sourcepub fn context_budget_chars(&self) -> Option<usize>
pub fn context_budget_chars(&self) -> Option<usize>
The history-truncation budget in characters, from the model’s own
capacity: context_length tokens converted at
CHARS_PER_TOKEN_APPROX.
None when the context size is unknown, which
apply reads as do not truncate. Guessing a budget
for an unresolvable model would risk rejecting a request over a number
nobody actually knows; losing model-specific handling is the whole
fallback policy of this module.
Callers that know the live serving context — the proxy, which also learns a per-model chars-per-token ratio from observed usage frames — compute a better number and pass that instead. This is the answer for everyone else.
Trait Implementations§
Source§impl Clone for ModelContext
impl Clone for ModelContext
Source§fn clone(&self) -> ModelContext
fn clone(&self) -> ModelContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModelContext
impl Debug for ModelContext
Source§impl Default for ModelContext
impl Default for ModelContext
Source§fn default() -> ModelContext
fn default() -> ModelContext
Source§impl From<&ModelSummary> for ModelContext
impl From<&ModelSummary> for ModelContext
Source§fn from(summary: &ModelSummary) -> Self
fn from(summary: &ModelSummary) -> Self
Source§impl PartialEq for ModelContext
impl PartialEq for ModelContext
Source§fn eq(&self, other: &ModelContext) -> bool
fn eq(&self, other: &ModelContext) -> bool
self and other values to be equal, and is used by ==.