pub struct ModelContext<'a> {Show 13 fields
pub model: &'a ModelRouter,
pub provider: &'a str,
pub session_id: &'a str,
pub session_context: &'a SessionContext,
pub metadata: &'a BTreeMap<String, Value>,
pub turn_id: &'a str,
pub model_step: usize,
pub context_window: i64,
pub instructions: &'a str,
pub last_usage: Option<&'a TokenUsage>,
pub tools: &'a Catalog,
pub events: &'a mut Vec<EventMsg>,
pub usage: &'a mut Vec<TokenUsage>,
/* private fields */
}Expand description
Mutable state exposed immediately before a model request.
Fields§
§model: &'a ModelRouterThe model.
provider: &'a strThe provider.
session_id: &'a strThe session identifier.
session_context: &'a SessionContextThe session context.
metadata: &'a BTreeMap<String, Value>The metadata.
turn_id: &'a strThe turn identifier.
model_step: usizeThe model step.
context_window: i64The context window.
instructions: &'a strThe instructions.
last_usage: Option<&'a TokenUsage>The last usage.
tools: &'a CatalogThe tools.
events: &'a mut Vec<EventMsg>The events.
usage: &'a mut Vec<TokenUsage>The usage.
Implementations§
Source§impl ModelContext<'_>
impl ModelContext<'_>
Sourcepub fn disable_hosted_tools(&mut self)
pub fn disable_hosted_tools(&mut self)
Prevents provider-hosted tools for this model step.
Sourcepub fn rewrite_input(
&mut self,
reason: ContextRewriteReason,
input: Vec<Value>,
) -> Result<()>
pub fn rewrite_input( &mut self, reason: ContextRewriteReason, input: Vec<Value>, ) -> Result<()>
Replaces active model context and advances its rewrite epoch once per boundary.
§Errors
Returns an error if validation or an operation required by this function fails.
Sourcepub fn append_model_input(&mut self, item: Value)
pub fn append_model_input(&mut self, item: Value)
Appends durable provider context without adding synthetic replay history.
Sourcepub fn push_input(&mut self, item: Value) -> Result<MessageTarget>
pub fn push_input(&mut self, item: Value) -> Result<MessageTarget>
Appends durable input to model context and its transcript journal.
§Errors
Returns an error if validation or an operation required by this function fails.
Sourcepub fn estimated_input_tokens(&self) -> i64
pub fn estimated_input_tokens(&self) -> i64
Estimates visible history, instructions, and tool schemas at four bytes per token.