#[non_exhaustive]pub struct ContextState<'a> {
pub agent: &'a mut LocalAgent,
pub utilization: f64,
pub overflow: bool,
pub archive: Option<Archive>,
pub invocation_context: Option<InvocationContext>,
}Expand description
What a strategy sees when it runs (ContextState).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.agent: &'a mut LocalAgentThe agent; its messages are the context window, changed in place.
utilization: f64Context utilization, 0 to 1 and above; above 1 is an overflow.
overflow: boolSet when running for a context window overflow. Strategies should bypass their utilization gates then: the provider rejected the request, so the estimate is off.
archive: Option<Archive>The archive for offloaded content, when one is configured.
invocation_context: Option<InvocationContext>The request this reduction runs for; a nested call adds to its usage, but its limits do not apply.
Implementations§
Source§impl<'a> ContextState<'a>
impl<'a> ContextState<'a>
Sourcepub fn new(agent: &'a mut LocalAgent, utilization: f64) -> Self
pub fn new(agent: &'a mut LocalAgent, utilization: f64) -> Self
A state for agent at utilization.
Sourcepub fn with_overflow(self, overflow: bool) -> Self
pub fn with_overflow(self, overflow: bool) -> Self
Marks the run as overflow recovery.
Sourcepub fn with_archive(self, archive: Option<Archive>) -> Self
pub fn with_archive(self, archive: Option<Archive>) -> Self
Sets the archive.
Sourcepub fn with_invocation_context(
self,
invocation_context: Option<InvocationContext>,
) -> Self
pub fn with_invocation_context( self, invocation_context: Option<InvocationContext>, ) -> Self
Sets the invocation context.
Sourcepub fn messages_mut(&mut self) -> &mut Vec<Message>
pub fn messages_mut(&mut self) -> &mut Vec<Message>
The agent’s messages, to change in place.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ContextState<'a>
impl<'a> !UnwindSafe for ContextState<'a>
impl<'a> Freeze for ContextState<'a>
impl<'a> Send for ContextState<'a>
impl<'a> Sync for ContextState<'a>
impl<'a> Unpin for ContextState<'a>
impl<'a> UnsafeUnpin for ContextState<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.