pub struct Capped<P> {
pub inner: P,
pub context_hard_cap: usize,
}Expand description
A ceiling on request size, on top of whatever else a policy decides.
The second implementation, and the one the missing capability calls for: a deployment that has to guarantee it never sends a request past some size — a provider hard limit, a cost ceiling, a compliance rule — wraps its policy in this. A turn whose context is still above the cap after compaction ends rather than sending the request anyway.
Fields§
§inner: P§context_hard_cap: usizeTrait Implementations§
Source§impl<P: BudgetPolicy> BudgetPolicy for Capped<P>
impl<P: BudgetPolicy> BudgetPolicy for Capped<P>
Source§fn on_usage(&self, spend: &Spend) -> Spending
fn on_usage(&self, spend: &Spend) -> Spending
After a model call, against the root turn’s reading
(
SpendNode::whole_turn) then. A turn the engine’s ceilings
already ended does not ask.Source§fn remaining(&self, spend: &Spend) -> Option<Remaining>
fn remaining(&self, spend: &Spend) -> Option<Remaining>
Before a model call, against the root turn’s reading. The call is not
sent when less than
MIN_CALL_TOKENS remain under this or any of
the engine’s ceilings, and otherwise asks for no more output than the
tightest leaves. None: no ceiling of the policy’s own.Source§fn on_output_target(&self, progress: &OutputProgress) -> OutputTarget
fn on_output_target(&self, progress: &OutputProgress) -> OutputTarget
When the model has stopped and a volume of output was asked for. Read more
Source§fn context_budget(&self, scene: &TokenBudget) -> ContextBudget
fn context_budget(&self, scene: &TokenBudget) -> ContextBudget
What the scene asked for, and what the deployment will actually allow.
Auto Trait Implementations§
impl<P> Forget for Capped<P>
impl<P> Freeze for Capped<P>where
P: Freeze,
impl<P> Move for Capped<P>
impl<P> RefUnwindSafe for Capped<P>where
P: RefUnwindSafe,
impl<P> Send for Capped<P>where
P: Send,
impl<P> Sync for Capped<P>where
P: Sync,
impl<P> Unpin for Capped<P>where
P: Unpin,
impl<P> UnsafeUnpin for Capped<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for Capped<P>where
P: UnwindSafe,
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